int main(int argc, char *argv[]) { int rc = 0; try { Miro::Log::init(argc, argv); Miro::Configuration::init(argc, argv); // Init TAO Factories TAO_Notify_Default_CO_Factory::init_svc(); TAO_Notify_Default_POA_Factory::init_svc(); TAO_Notify_Default_Collection_Factory::init_svc(); TAO_Notify_Default_EMO_Factory::init_svc(); // Parameters to be passed to the services Miro::RobotParameters * robotParameters = Miro::RobotParameters::instance(); Base::Parameters * baseParameters = Base::Parameters::instance(); Msp::Parameters * mspParameters = Msp::Parameters::instance(); // Config file processing Miro::ConfigDocument * config = Miro::Configuration::document(); config->setSection("Robot"); config->getParameters("Miro::RobotParameters", *robotParameters); config->setSection("B21"); config->getParameters("B21::Parameters", *baseParameters); config->getParameters("Msp::Parameters", *mspParameters); MIRO_LOG_OSTR(LL_NOTICE , " robot parameters:\n" << robotParameters); MIRO_LOG_OSTR(LL_NOTICE , " base parameters:\n" << baseParameters); MIRO_LOG_OSTR(LL_NOTICE , " msp parameters:\n" << mspParameters); MIRO_LOG(LL_NOTICE,"Initialize server daemon."); B21Base b21Base(argc, argv); try { MIRO_LOG(LL_NOTICE , "Loop forever handling events." ); b21Base.run(8); MIRO_LOG(LL_NOTICE , "b21Base ended, exiting." ); } catch (const Miro::EOutOfBounds& e) { MIRO_LOG(LL_ERROR , "OutOfBounds exception: Wrong parameter for device initialization." ); rc = 1; } catch (const Miro::EDevIO& e) { MIRO_LOG(LL_ERROR , "DevIO exception: Device access failed." ); rc = 1; } catch (const CORBA::Exception & e) { MIRO_LOG_OSTR(LL_ERROR , "Uncaught CORBA exception: " << e ); rc = 1; } } catch (const Miro::Exception& e) { MIRO_LOG_OSTR(LL_ERROR , "Miro exception: " << e ); rc = 1; } return rc; }
int main(int argc, char *argv[]) { Miro::RobotParameters * robotParameters = Miro::RobotParameters::instance(); Laser::Parameters * parameters = Laser::Parameters::instance(); // Config file processing Miro::ConfigDocument * config = new Miro::ConfigDocument(argc, argv); config->setSection("Robot"); config->getParameters("Robot", *robotParameters); config->setSection("Sick"); config->getParameters("Laser", *parameters); delete config; log(Miro::INFO, "Initialize server daemon."); Miro::LaserServer laserServer(argc, argv); #ifdef DEBUG cout << " robot parameters:" << endl << *robotParameters << endl; cout << " parameters:" << endl << *parameters << endl; #endif try { log(Miro::INFO, "Ready for service."); laserServer.run(8); log(Miro::INFO, "Service loop ended, exiting."); } catch (const Miro::CException& e) { log(Miro::FATAL_ERROR, "Miro exception: "); cerr << e << endl; return 1; } catch (const CORBA::Exception & e) { log(Miro::FATAL_ERROR, "Uncaught CORBA exception: "); cerr << e << endl; return 1; } catch (const Miro::Exception& e) { log(Miro::FATAL_ERROR, "Miro exception: "); cerr << e << endl; return 1; } catch (...) { log(Miro::FATAL_ERROR, "Uncaught exception."); return 1; } return 0; }
void FrameStoreInit::addXmlFrames(Miro::ConfigDocument& xmlConfig) { // get all frames defined in the config file xmlConfig.setSection("Frames"); typedef Miro::ConfigDocument::StringVector StringVector; StringVector frames = xmlConfig.getInstances("rapid::FrameRpyParameters"); // add all frames specified in RPY StringVector::iterator first, last = frames.end(); for (first = frames.begin(); first != last; ++first) { FrameRpyParameters frame; xmlConfig.getType("rapid::FrameRpyParameters", *first, frame); keyFrameSubstitute(frame.parent); addRpyFrame(keyFrameSubstitute(*first), frame); } // add all frames specified in Quaternios frames = xmlConfig.getInstances("rapid::FrameQParameters"); last = frames.end(); for (first = frames.begin(); first != last; ++first) { FrameQParameters frame; xmlConfig.getType("rapid::FrameQParameters", *first, frame); keyFrameSubstitute(frame.parent); addQFrame(keyFrameSubstitute(*first), frame); } }
int main(int argc, char *argv[]) { int rc = 0; // command line paramter parsing // -> increase log level for verbosity (-MLL 7) Miro::Log::init(argc, argv); // -> specify the config file (-MCF Config.xml) Miro::Configuration::init(argc, argv); // Get global configuration document Miro::ConfigDocument * config = Miro::Configuration::document(); // Read parameters from document... try { // global parameters // -> those are accessed through singletons Test::MyParameters * params = Test::MyParameters::instance(); Test::MoreParameters * more_params = Test::MoreParameters::instance(); // individual parameters // -> those are locally allocated Test::FriendsParameters tom; Test::FriendsParameters cherry; // selecting the paramter section config->setSection("My_test_section"); // reading global parameters (if present) // -> no name required config->getParameters("Test::MyParameters", *params); config->getParameters("Test::MoreParameters", *more_params); // reading individual parameter settings (if present) // -> referred by name config->getType("Test::FriendsParameters", "Tom", tom); config->getType("Test::FriendsParameters", "Cherry", cherry); // debug output cout << " my paramters:" << endl << *params << endl << endl; cout << " more paramters:" << endl << *more_params << endl << endl; cout << " tom's paramters:" << endl << tom << endl << endl; cout << " cherry's paramters:" << endl << cherry << endl << endl; } catch (const Miro::CException& e) { cerr << "Miro exception: " << e << endl; rc = 1; } catch (const Miro::Exception& e) { cerr << "Miro exception: " << e << endl; rc = 1; } return rc; }
/** * parse command line arguments */ int parseArgs(int& argc, char* argv[]) { int rc = 0; int c; // initialize parameters with global instance FileReceiverParameters* params = FileReceiverParameters::instance(); // initialize parameters from config file Miro::ConfigDocument* config = Miro::Configuration::document(); config->setSection("Rapid"); config->getParameters("kn::FileReceiverParameters", *params); // initialize parameters from command line ACE_Get_Opt get_opts(argc, argv, "D:S:v?"); while ((c = get_opts()) != -1) { switch (c) { case 'D': params->dataDestinationDir = get_opts.optarg; break; case 'S': params->dataStagingDir = get_opts.optarg; break; case 'v': verbose = true; break; case '?': default: cerr << "usage: " << argv[0] << "[-v?]" << endl << " -D <path> Destination root directory (default: " << params->dataDestinationDir << ")" << endl << " -S <path> Staging directory (default: " << params->dataStagingDir << ")" << endl << " -v verbose mode" << endl << " -? help: emit this text and stop" << endl; rc = 1; } } if (verbose) { cerr << "RAFT FileReceiver parameters:" << endl; cerr << *params << endl; } return rc; }
int FrameStoreUpdaterSvc::parseArgs(int& argc, char * argv[]) { int rc = 0; int c; m_verbose = 0; // initialize parameters from command line ACE_Get_Opt get_opts (argc, argv, "v?"); while ((c = get_opts()) != -1) { switch (c) { case 'v': ++m_verbose; break; case '?': default: ACE_OS::last_error(EINVAL); rc = -1; } } // debug output if (rc != 0) { cerr << "usage: " << argv[0] << " [-n name] [-v?]\n" << " -v verbose mode\n" << " -? help: print this text and stop" << endl; } // initialize parameters with global instance m_params = FrameStoreUpdaterSvcParameters::instance(); // initialize parameters from config file Miro::ConfigDocument * config = Miro::Configuration::document(); config->setSection("FrameStore"); config->getParameters("kn::FrameStoreUpdaterSvcParameters", *m_params); if (m_verbose) { cerr << "FrameStoreUpdater Parameters: " << endl << *m_params << endl; } return rc; }
int SystemInfoSvc::parseArgs(int& argc, char* argv[]) { int rc = 0; int c; // initialize parameters with global instance m_params = SystemInfoSvcParameters::instance(); // reset defaults SystemInfoSvcParameters default_params; *m_params = default_params; // initialize parameters from config file Miro::ConfigDocument * config = Miro::Configuration::document(); config->setSection("Rapid"); config->getParameters("kn::SystemInfoSvcParameters", *m_params); // initialize parameters from command line ACE_Get_Opt get_opts (argc, argv, "r:v?"); while ((c = get_opts()) != -1) { switch (c) { case 'r': m_params->refreshInterval.set(atof(get_opts.optarg)); case 'v': ++m_verbose; break; case '?': default: cerr << "usage: " << argv[0] << "[-r interval] [-vV?]" << endl << " -r [interval] how often to refresh info (default: 1s)" << endl << " -v verbose mode" << endl << " -? help: emit this text and stop" << endl; rc = 1; } } if (m_verbose) { cerr << "SystemInfoSvc parameters:" << endl << *m_params << endl; } return rc; }
int main(int argc, char * argv[]) { // Parameters to be passed to the services Sparrow::Parameters * parameters = Sparrow::Parameters::instance(); // Config file processing Miro::ConfigDocument * config = new Miro::ConfigDocument(argc, argv); config->setSection("Sparrow99"); config->getParameters("sparrowBoard", *parameters); delete config; #ifdef DEBUG cout << " sparrow paramters:" << endl << *parameters << endl; #endif // Initialize server daemon. Service service; cout << "initialized" << endl; Miro::PositionIDL startPos, current; service.reactorTask.open(NULL); int ticks = 0; int niterations = 10; if (argc > 1) niterations = ACE_OS::atoi(argv[1]); cout << "start test" << endl; try { ACE_Sample_History history (niterations); ACE_hrtime_t test_start = ACE_OS::gethrtime (); for (int i = 0; i < niterations; ++i) { service.connection.setPower(0, 0); ACE_OS::sleep(ACE_Time_Value(1, (int)floor(rand1() * 100000.))); startPos = service.odometryImpl->getPosition(); cout << "start position:" << startPos << endl; ACE_hrtime_t start = ACE_OS::gethrtime (); service.connection.setPower(10000, 10000); do { current = service.odometryImpl->getWaitPosition(); ++ticks; } while (startPos.point.x == current.point.x && startPos.point.y == current.point.y && startPos.heading == current.heading); ACE_hrtime_t now = ACE_OS::gethrtime (); history.sample (now - start); } service.connection.setPower(0, 0); ACE_hrtime_t test_end = ACE_OS::gethrtime (); ACE_DEBUG ((LM_DEBUG, "test finished\n")); ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration....")); ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor (); ACE_DEBUG ((LM_DEBUG, "done\n")); history.dump_samples ("HISTORY", gsf); ACE_Basic_Stats stats; history.collect_basic_stats (stats); stats.dump_results ("Total", gsf); ACE_Throughput_Stats::dump_throughput ("Total", gsf, test_end - test_start, stats.samples_count ()); // data evaluation cout << "ticks: " << ticks << endl; cout << "end position: " << current << endl; } catch (const Miro::Exception & e) { cerr << "Miro exception thrown:" << e << endl; return 1; } service.reactorTask.cancel(); return 0; }
int main(int argc, char * argv[]) { // Parameters to be passed to the services Sparrow::Parameters * parameters = Sparrow::Parameters::instance(); // Config file processing Miro::ConfigDocument * config = new Miro::ConfigDocument(argc, argv); config->setSection("Sparrow99"); config->getParameters("sparrowBoard", *parameters); delete config; #ifdef DEBUG cout << " sparrow paramters:" << endl << *parameters << endl; #endif // Initialize server daemon. Service service; cout << "initialized" << endl; int time; service.reactorTask.open(NULL); ACE_OS::sleep(ACE_Time_Value(2)); if (argc > 1) time = atoi(argv[1]); else { cerr << "usage: kickerTest <kick msec>" << endl; return 1; } try { int digital = 1; while (true) { Miro::Guard guard(service.pSparrowConsumer->digitalMutex); service.pSparrowConsumer->digitalCond.wait(); cout << "button" << endl; if ((service.pSparrowConsumer->digital[1] & 0x01) && digital == 0) { cout << "time (msec): " << time << endl; service.connection.kick(time); } digital = service.pSparrowConsumer->digital[1] & (0x01); } } catch (const Miro::Exception & e) { cerr << "Miro exception thrown:" << e << endl; return 1; } catch (...) { cerr << "Uncaught exception: " << endl; return 1; } service.reactorTask.cancel(); return 0; }
int main(int argc, char *argv[]) { int rc = 0; Miro::RobotParameters * robotParameters = Miro::RobotParameters::instance(); Laser::Parameters * parameters = Laser::Parameters::instance(); try { Miro::Log::init(argc, argv); // Config file processing Miro::ConfigDocument * config = new Miro::ConfigDocument(argc, argv); config->setSection("Robot"); config->getParameters("Miro::RobotParameters", *robotParameters); config->setSection("Sick"); config->getParameters("Laser::Parameters", *parameters); delete config; calculateLaserDescription(parameters); MIRO_LOG_OSTR(LL_NOTICE, "Configuration:\n" << " robot parameters:" << std::endl << *robotParameters << std::endl << " parameters:" << std::endl << *parameters); MIRO_LOG(LL_NOTICE, "Initialize server daemon.\n"); Miro::LaserServer laserServer(argc, argv); try { MIRO_LOG(LL_NOTICE, "Loop forever handling events.\n"); laserServer.run(8); MIRO_LOG(LL_NOTICE, "Server loop ended, exiting.\n"); } catch (const Miro::EOutOfBounds& e) { MIRO_LOG_OSTR(LL_CRITICAL, "OutOfBounds exception: Wrong parameter for device initialization." << e); rc = 1; } catch (const Miro::EDevIO& e) { MIRO_LOG_OSTR(LL_CRITICAL, "DevIO exception: Device access failed." << e); rc = 1; } catch (const CORBA::Exception & e) { MIRO_LOG_OSTR(LL_CRITICAL, "Uncaught CORBA exception: " << e); rc = 1; } } catch (const Miro::CException& e) { MIRO_LOG_OSTR(LL_CRITICAL, "Miro C exception: " << e); rc = 1; } catch (const Miro::Exception& e) { MIRO_LOG_OSTR(LL_CRITICAL,"Miro exception: " << e); rc = 1; } return rc; }
int main(int argc, char *argv[]) { int rc = 0; // Init TAO Factories TAO_Notify_Default_CO_Factory::init_svc(); TAO_Notify_Default_POA_Factory::init_svc(); TAO_Notify_Default_Collection_Factory::init_svc(); TAO_Notify_Default_EMO_Factory::init_svc(); // Parameters to be passed to the services Miro::RobotParameters * robotParameters = Miro::RobotParameters::instance(); Pioneer::Parameters * pioneerParameters = Pioneer::Parameters::instance(); try { // Config file processing Miro::ConfigDocument * config = new Miro::ConfigDocument(argc, argv); config->setSection("Robot"); config->getParameters("Robot", *robotParameters); config->setSection("ActiveMedia"); config->getParameters("PioneerBoard", *pioneerParameters); delete config; #ifdef DEBUG cout << " robot parameters:" << endl << *robotParameters << endl; cout << " pioneer parameters:" << endl << *pioneerParameters << endl; #endif DBG(cout << "Initialize server daemon." << endl); PioneerBase pioneerBase(argc, argv); try { DBG(cout << "Loop forever handling events." << endl); pioneerBase.run(8); DBG(cout << "pioneerBase ended, exiting." << endl); } catch (const Miro::EOutOfBounds& e) { cerr << "OutOfBounds exception: Wrong parameter for device initialization." << endl; } catch (const Miro::EDevIO& e) { cerr << "DevIO exception: Device access failed." << endl; } catch (const CORBA::Exception & e) { cerr << "Uncaught CORBA exception: " << e << endl; rc = 1; } } catch (const Miro::CException& e) { cerr << "Miro exception: " << e << endl; rc = 1; } catch (const Miro::Exception& e) { cerr << "Miro exception: " << e << endl; rc = 1; } catch (...) { cerr << "Uncaught exception: " << endl; rc = 1; } return rc; }
int main(int argc, char *argv[]) { int rc = 1; std::string fileName; // read syslog options Miro::Log::init(argc, argv); // Parameters to be passed to the services Miro::RobotParameters * robotParameters = Miro::RobotParameters::instance(); Miro::LogNotifyParameters * parameters = Miro::LogNotifyParameters::instance(); // Config file processing Miro::ConfigDocument * config = new Miro::ConfigDocument(argc, argv); config->setSection("Robot"); config->getParameters("Robot", *robotParameters); config->setSection("Notification"); config->getParameters("Logging", *parameters); delete config; MIRO_DBG_OSTR(MIRO , LL_PRATTLE , " robot parameters:\n" << robotParameters); MIRO_DBG_OSTR(MIRO , LL_PRATTLE , " logging parameters:\n" << parameters); MIRO_LOG(LL_NOTICE,"Initialize server daemon."); Miro::Server server(argc, argv); // override default logfile name with command line parameter if (argc > 1) fileName = argv[1]; try { // The one channel that we create using the factory. CosNotifyChannelAdmin::EventChannel_var ec(server.resolveName<CosNotifyChannelAdmin::EventChannel>("EventChannel")); // The consumer, that gets the events Miro::LogNotifyConsumer pushConsumer(server, ec.in(), server.namingContextName, fileName, *parameters, false); try { MIRO_LOG(LL_NOTICE , "Loop forever handling events." ); server.run(1); MIRO_LOG(LL_NOTICE , "Server loop ended, exiting." ); rc = 0; } catch (const Miro::Exception& e) { MIRO_LOG_OSTR(LL_CRITICAL , "Uncought Miro excepition: " << e); } server.detach(1); MIRO_LOG(LL_NOTICE , "shutting down server."); pushConsumer.disconnect(); server.shutdown(); server.wait(); } catch (const CORBA::Exception & e) { MIRO_LOG_OSTR(LL_CRITICAL , "Uncaught CORBA exception: " << e); } return rc; }
int main(int argc, char *argv[]) { int rc = 1; // Init TAO Factories TAO_Notify_Default_CO_Factory::init_svc(); TAO_Notify_Default_POA_Factory::init_svc(); TAO_Notify_Default_Collection_Factory::init_svc(); TAO_Notify_Default_EMO_Factory::init_svc(); try { Miro::Log::init(argc, argv); Miro::Configuration::init(argc, argv); // Parameters to be passed to the services Miro::RobotParameters * robotParameters = Miro::RobotParameters::instance(); Pioneer::Parameters * pioneerParameters = Pioneer::Parameters::instance(); // Config file processing MIRO_LOG(LL_NOTICE,"Getting config document"); Miro::ConfigDocument * config = Miro::Configuration::document(); config->setSection("Robot"); config->getParameters("Miro::RobotParameters", *robotParameters); MIRO_LOG(LL_NOTICE,"Got Robot Parameters"); config->setSection("ActiveMedia"); config->getParameters("Pioneer::Parameters", *pioneerParameters); MIRO_LOG_OSTR(LL_NOTICE, " robot parameters:" << std::endl << *robotParameters << std::endl << " pioneer parameters:" << std::endl << *pioneerParameters << std::endl ); MIRO_LOG(LL_NOTICE, "Initialize server daemon."); PioneerBase pioneerBase(argc, argv); try { MIRO_LOG(LL_NOTICE, "Loop forever handling events."); pioneerBase.run(8); MIRO_LOG(LL_NOTICE, "pioneerBase ended, exiting."); rc = 0; } catch (const Miro::EOutOfBounds& e) { MIRO_LOG_OSTR(LL_CRITICAL, "OutOfBounds exception: Wrong parameter for device initialization." << std::endl << e.what); } catch (const Miro::EDevIO& e) { MIRO_LOG_OSTR(LL_CRITICAL, "DevIO exception: Device access failed." << std::endl << e.what); } catch (const CORBA::Exception & e) { MIRO_LOG_OSTR(LL_CRITICAL, "Uncaught CORBA exception: " << e); } } catch (const Miro::Exception& e) { MIRO_LOG_OSTR(LL_CRITICAL, "Miro exception: " << e); rc = 1; } return rc; }