RobotClass::RobotClass() : m_index_initial(0), m_index_left(0), m_index_right(0), m_turn_counter(0), m_state(STATE_INIT) { //Linear Velocity //m_autonomous_control.control_servo.x = 1550; //Angular Velocity //double a = RAD_TO_DEG * atan( m_goal.x / m_goal.y * CAR_LENGTH ); //m_autonomous_control.control_servo.y = DEG_TO_SERVO_SIGNAL( a ); std::string filename1; std::string filename2; std::string filename3; std::string path = "/home/tas_group_06/catkin_ws/src/slalom/log_files/" ; // Car //std::string path = "/home/martin/TAS_ws/tas_car_6/trunk/Martin/slalom/log_files/"; // Notebook //std::string path = "/home/martin/Programming/TAS/tas_car_6/trunk/Martin/slalom/log_files/"; // Home PC std::stringstream ss1; ss1 << path << "init_turn_left.txt"; filename1 = ss1.str(); std::stringstream ss2; ss2 << path << "turn_left.txt"; filename2 = ss2.str(); std::stringstream ss3; ss3 << path << "turn_right.txt"; filename3 = ss3.str(); bool result; result = loadInstructionVector(m_initial_turn, filename1); if(!result) throw ErrorType("Could not load initial turn"); result = loadInstructionVector(m_turn_left, filename2); if(!result) throw ErrorType("Could not load left turn"); result = loadInstructionVector(m_turn_right, filename3); if(!result) throw ErrorType("Could not load right turn"); #ifdef USE_PLAYER m_playerClient = new PlayerCc::PlayerClient("localhost"); m_laserProxy = new PlayerCc::RangerProxy(m_playerClient, 1); m_position2dProxy = new PlayerCc::Position2dProxy(m_playerClient, 0); m_playerClient->Read(); #endif }
ErrorType SendMsgState::onShutdown() { if (shouldReset()) { RadioID = 0; AgentName = 0; } return ErrorType(); }
bool RobotClass::FillScanMessage(sensor_msgs::LaserScan& scan) const { #ifdef USE_PLAYER scan.header.stamp = ros::Time::now(); scan.header.frame_id = "laser_frame"; scan.angle_increment = m_laserProxy->GetAngularRes(); scan.angle_max = m_laserProxy->GetMaxAngle(); scan.angle_min = m_laserProxy->GetMinAngle(); scan.range_max = m_laserProxy->GetMaxRange(); scan.range_min = m_laserProxy->GetMinRange(); scan.time_increment = (1 / m_laserProxy->GetFrequency()) / (m_laserProxy->GetRangeCount()); scan.ranges.resize( m_laserProxy->GetRangeCount()); scan.intensities.resize( m_laserProxy->GetIntensityCount()); if (scan.ranges.size() != scan.intensities.size()) throw ErrorType( "Got a different ammount of ranges than intensities"); for (unsigned int i = 0; i < scan.ranges.size(); ++i) { scan.ranges[i] = m_laserProxy->GetRange(i); scan.intensities[i] = m_laserProxy->GetIntensity(i); } return true; #else return false; #endif }
ErrorType SendMsgState::onInit() { if (shouldReset()) { memset(&MsgBuffer[0], 0, sizeof(MsgBuffer)); getKeyboardContext().init(&MsgBuffer[0], sizeof(MsgBuffer)); } else { clearState(DONT_RESET); } InternalState = TYPE_MESSAGE; return ErrorType(); }
void HelperPanel::handleLuaError(LuaErrorEventDetails* const details) { std::string ErrorType(""); switch(details->getStatus()) { case LUA_ERRSYNTAX: //Syntax Error ErrorType = "Lua Syntax Error"; break; case LUA_ERRMEM: //Memory Allocation Error ErrorType = "Lua Memory Allocation Error"; break; case LUA_ERRRUN: //Memory Allocation Error ErrorType = "Lua Runtime Error"; break; case LUA_ERRERR: //Memory Allocation Error ErrorType = "Lua Error in Error Handler"; break; default: //Unknown ErrorType = "Lua Unknown Error"; break; } _ErrorTextArea->clear(); if(_ErrorTextArea->getText().size() != 0) { _ErrorTextArea->write("\n"); } _ErrorTextArea->write(ErrorType + ":\n " + details->getErrorString()); //Select the Error Tab _InfoTabPanel->setSelectedIndex(1); //Fill Stack Trace if(details->getStatus() == LUA_ERRMEM || details->getStatus() == LUA_ERRERR || details->getStatus() == LUA_ERRRUN) { std::stringstream ss; ss << "Lua Stack Trace: " << std::endl; //MFString::StorageType::const_iterator ListItor(details->getMFStackTrace()->begin()); //for(; ListItor != details->getMFStackTrace()->end() ; ++ListItor) //{ //ss << " " << (*ListItor) << std::endl; //} _StackTraceTextArea->clear(); _StackTraceTextArea->write(ss.str()); } }
ErrorType ErrorType::deserialize(BinaryRefReader& brr) { auto type_code = brr.get_uint8_t(); if (type_code != ERRTYPE_CODE) BtcUtils::throw_type_error(ERRTYPE_CODE, type_code); auto size = brr.get_var_int(); if (size > brr.getSizeRemaining()) throw runtime_error("invalid data len"); return ErrorType(string((char*)brr.getCurrPtr(), size)); }
ErrorType EngimaState::onInit() { gui_set_curList(0); memset(&EntryBuffer[0], 0, sizeof(EntryBuffer)); memset(&Wheels[0], 0, sizeof(Wheels)); memset(&EncryptResult[0], 0, sizeof(EncryptResult)); memset(&PlugBoard[0], 0, sizeof(PlugBoard)); memset(&ResultHash[0], 0, sizeof(ResultHash)); InternalState = SET_WHEEL; DisplayOffset = 0; getKeyboardContext().init(&Wheels[0], sizeof(Wheels)); return ErrorType(); }
ConOut() { handle=Win64::GetStdHandle(Win64::StdOutputHandle); if( handle==Win64::InvalidFileHandle ) { error=NonNullError(); } else if( handle==0 ) { error=ErrorType(Win64::ErrorFileNotFound); } else { error=ErrorIf( !Win64::SetConsoleOutputCP(Win64::GetACP()) ); } }
void RenameFile<TRequest>::CoroutineBody(pull_type & yield) { auto self = shared_from_this(); // Hold a reference to our // object until the coroutine // is complete, otherwise // handler will have invalid // reference to this because // the base object has // disappeared from scope std::function<void(const ResponseType & response)> HandleFileGetInfo = [this, self](const ResponseType & response) { if (response.error_code) { // If there was an error, insert into vector and // propagate at the callback. std::string error_str = "No error string provided"; if (response.error_string) error_str = *response.error_string; errors_.push_back(ErrorType( quick_key_, new_name_, response.error_code, error_str)); } else { response_ = response; } // Resume the coroutine request_ = nullptr; // Must free request_ or coroutine cannot be // destructed. Resume(); }; request_ = stm_->Call(RequestType(quick_key_), HandleFileGetInfo); if (cancelled_) request_->Cancel(); yield(); // Coroutine is done, so call the callback. callback_(response_, errors_); }
void LuaDebuggerInterface::handlLuaError(LuaErrorEventDetails* const details) { std::string ErrorType(""); switch(details->getStatus()) { case LUA_ERRSYNTAX: //Syntax Error ErrorType = "Lua Syntax Error"; break; case LUA_ERRMEM: //Memory Allocation Error ErrorType = "Lua Memory Allocation Error"; break; case LUA_ERRRUN: //Memory Allocation Error ErrorType = "Lua Runtime Error"; break; case LUA_ERRERR: //Memory Allocation Error ErrorType = "Lua Error in Error Handler"; break; default: //Unknown ErrorType = "Lua Unknown Error"; break; } _ErrorTextArea->moveCaretToEnd(); if(_ErrorTextArea->getText().size() != 0) { _ErrorTextArea->write("\n"); } _ErrorTextArea->write(ErrorType + ":\n " + details->getErrorString()); //Select the Error Tab _InfoTabPanel->setSelectedIndex(1); //Fill Stack Trace if(details->getStatus() == LUA_ERRMEM || details->getStatus() == LUA_ERRERR || details->getStatus() == LUA_ERRRUN) { std::stringstream ss; ss << "Lua Stack Trace: " << std::endl << TheLuaManager->getCallStack() << std::endl; _StackTraceTextArea->write(ss.str()); } }
ErrorType AddressState::onInit() { gui_set_curList(&AddressList); setNext4Items(0); for (uint16_t i = 0; i < sizeof(DetailItems) / sizeof(DetailItems[0]); ++i) { if (i == (sizeof(DetailItems) / sizeof(DetailItems[0]) - 1)) { DetailItems[i].text = "Send Msg"; } else { DetailItems[i].text = ""; } DetailItems[i].id = 0; DetailItems[i].Scrollable = 0; } memset(&RadioIDBuf[0], 0, sizeof(RadioIDBuf)); memset(&PublicKey[0], 0, sizeof(PublicKey)); memset(&SignatureKey[0], 0, sizeof(SignatureKey)); Index = 0; return ErrorType(); }
ErrorType GameOfLife::onInit() { initGame(); InternalState = GAME; return ErrorType(); }
ErrorType TaskEntry::create() noexcept { pthread_t tid; return ErrorType( pthread_create(&tid,0,Entry,this) ); }
ErrorType AddressState::onShutdown() { gui_set_curList(0); return ErrorType(); }
allocate_iterator_starch_bed_mm(Ext::FPWrap<ErrorType>& fp, const std::string& chr = "all") /* this ASSUMES fp is open and meaningful */ : fp_(fp), _M_ok(fp_ && !std::feof(fp_)), _M_value(0), is_starch_(_M_ok && (fp_ != stdin) && starch::Starch::isStarch(fp_)), all_(0 == std::strcmp(chr.c_str(), "all")), archive_(NULL) { chr_[0] = '\0'; std::size_t sz = std::min(chr.size(), static_cast<std::size_t>(Bed::MAXCHROMSIZE)); std::strncpy(chr_, chr.c_str(), sz); chr_[sz] = '\0'; if ( !_M_ok ) { if ( fp_ ) fp_ = NULL; return; } bool is_namedpipe = false; if ( fp.Name() != "-" ) { struct stat st; if ( stat(fp.Name().c_str(), &st) == -1 ) throw(ErrorType("Error: stat() failed on: " + fp.Name())); is_namedpipe = (S_ISFIFO(st.st_mode) != 0); } is_starch_ = (is_starch_ && !is_namedpipe); if ( (fp_ == stdin || is_namedpipe) && !all_ ) { // BED, chrom-specific, using stdin // stream through until we find what we want while ( (_M_ok = (fp_ && !std::feof(fp_))) ) { _M_value = new BedType(fp_); if ( 0 == std::strcmp(_M_value->chrom(), chr_) ) { _M_ok = (fp_ && !std::feof(fp_)); break; } delete _M_value; } // while if ( !_M_ok && fp_ ) fp_ = NULL; return; } if ( is_starch_ ) { // starch archive can deal with all or specific chromosomes const bool perLineUsage = true; archive_ = new starch::Starch(fp_, chr_, perLineUsage); _M_ok = archive_->getArchiveRecordIter(); if ( !_M_ok ) { fp_ = NULL; delete archive_; } else { _M_value = get_starch(); _M_ok = (static_cast<bool>(_M_value) && (archive_->getArchiveRecordIter() != NULL) && !archive_->isEOF()); } } else if ( !all_ ) { // BED, chromosome-specific // position fp_ to start of correct chromosome std::fseek(fp_, 0, SEEK_END); // apparently dangerous on some platforms in binary mode -> padded nulls; const Bed::ByteOffset at_end = std::ftell(fp_); // I'll assume msft is the problem until I know better std::rewind(fp_); Bed::extract_details::TargetBedType* bt = new Bed::extract_details::TargetBedType(fp_); if ( 0 == std::strcmp(bt->chrom(), chr_) ) { delete bt; std::rewind(fp_); _M_value = new BedType(fp_); _M_ok = (_M_ok && fp_ && !std::feof(fp_)); if ( !_M_ok && fp_ ) fp_ = NULL; } else { delete bt; std::rewind(fp_); const bool done = false; std::vector<Bed::extract_details::TargetBedType*> v; while ( !done ) { bt = new Bed::extract_details::TargetBedType(fp_); bt->start(std::numeric_limits<Bed::CoordType>::max()-1); bt->end(std::numeric_limits<Bed::CoordType>::max()); v.push_back(bt); Visitors::Helpers::DoNothing nada; std::pair<bool, Bed::ByteOffset> lbound; lbound = find_bed_range(fp_, v.begin(), v.end(), nada); // routine deletes bt for us v.clear(); // bt already deleted if ( lbound.first && lbound.second != at_end ) { std::fseek(fp_, lbound.second, SEEK_SET); ByteOffset b = std::ftell(fp_); Bed::extract_details::QueryBedType q(fp_); std::fseek(fp_, b, SEEK_SET); if ( 0 == std::strcmp(q.chrom(), chr_) ) { _M_value = new BedType(fp_); _M_ok = (_M_ok && fp_ && !std::feof(fp_)); if ( !_M_ok && fp_ ) fp_ = NULL; break; } } else { _M_value = static_cast<BedType*>(0); _M_ok = false; break; } } // while } } else { // BED, process everything _M_value = new BedType(fp_); _M_ok = (_M_ok && fp_ && !std::feof(fp_)); if ( !_M_ok && fp_ ) fp_ = NULL; } }
//! Load from XML bool DatapickerCurve::load(XmlStreamReader* reader) { Q_D(DatapickerCurve); if(!reader->isStartElement() || reader->name() != "datapickerCurve") { reader->raiseError(i18n("no dataPicker curve element found")); return false; } if (!readBasicAttributes(reader)) return false; QString attributeWarning = i18n("Attribute '%1' missing or empty, default value is used"); QXmlStreamAttributes attribs; QString str; while (!reader->atEnd()) { reader->readNext(); if (reader->isEndElement() && reader->name() == "datapickerCurve") break; if (!reader->isStartElement()) continue; if (reader->name() == "comment") { if (!readCommentElement(reader)) return false; } else if (reader->name() == "general") { attribs = reader->attributes(); str = attribs.value("curveErrorType_X").toString(); if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("curveErrorType_X")); else d->curveErrorTypes.x = ErrorType(str.toInt()); str = attribs.value("curveErrorType_Y").toString(); if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("curveErrorType_Y")); else d->curveErrorTypes.y = ErrorType(str.toInt()); READ_COLUMN(posXColumn); READ_COLUMN(posYColumn); READ_COLUMN(posZColumn); READ_COLUMN(plusDeltaXColumn); READ_COLUMN(minusDeltaXColumn); READ_COLUMN(plusDeltaYColumn); READ_COLUMN(minusDeltaYColumn); } else if(reader->name() == "symbolProperties") { attribs = reader->attributes(); str = attribs.value("pointRotationAngle").toString(); if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("pointRotationAngle")); else d->pointRotationAngle = str.toFloat(); str = attribs.value("pointOpacity").toString(); if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("pointOpacity")); else d->pointOpacity = str.toFloat(); str = attribs.value("pointSize").toString(); if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("pointSize")); else d->pointSize = str.toFloat(); str = attribs.value("pointStyle").toString(); if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("pointStyle")); else d->pointStyle = (Symbol::Style)str.toInt(); str = attribs.value("pointVisibility").toString(); if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("pointVisibility")); else d->pointVisibility = (bool)str.toInt(); READ_QBRUSH(d->pointBrush); READ_QPEN(d->pointPen); } else if(reader->name() == "errorBarProperties") { attribs = reader->attributes(); str = attribs.value("pointErrorBarSize").toString(); if(str.isEmpty()) reader->raiseWarning(attributeWarning.arg("pointErrorBarSize")); else d->pointErrorBarSize = str.toFloat(); READ_QBRUSH(d->pointErrorBarBrush); READ_QPEN(d->pointErrorBarPen); } else if (reader->name() == "datapickerPoint") { DatapickerPoint* curvePoint = new DatapickerPoint(""); curvePoint->setHidden(true); if (!curvePoint->load(reader)) { delete curvePoint; return false; } else { addChild(curvePoint); curvePoint->initErrorBar(curveErrorTypes()); } } else if (reader->name() == "spreadsheet") { Spreadsheet* datasheet = new Spreadsheet(0, "spreadsheet", true); if (!datasheet->load(reader)) { delete datasheet; return false; } else { addChild(datasheet); m_datasheet = datasheet; } } else { // unknown element reader->raiseWarning(i18n("unknown element '%1'", reader->name().toString())); if (!reader->skipToEndElement()) return false; } } d->retransform(); return true; }
ErrorType EngimaState::onShutdown() { return ErrorType(); }
void ConfigVisitor::Error(const char *message) { if (ignore_errors) LOG_E("option/load/config_visitor") << "Error loading option from user configuration: " << message; else throw ErrorType(message); }
ErrorType GameOfLife::onShutdown() { return ErrorType(); }