Main.cc
Go to the documentation of this file.
00001 
00018 /* system includes */
00019 #include <boost/program_options.hpp>
00020 #include <iostream>
00021 /* my includes */
00022 /* (none) */
00023 #include "BirdTrack_impl.h"
00024 #include "tracker_impl.h"
00025 
00026 /*
00027   \brief Start the Flock of Bird Server 
00028 */
00029 unsigned int debugLevel;
00030 const static char* LEFT_DEFAULT_NAME = "TrackLeft";
00031 const static char* RIGHT_DEFAULT_NAME = "TrackRight";
00032 const static char* SERIAL_PORT = "/dev/ttyS0";
00033 
00034 namespace po = boost::program_options;
00035 
00036 
00037 int main(int argc, char **argv)
00038 {
00039   std::string leftname, rightname, dbName, filename, calibFile, device;
00040   bool do_loop=true;
00041 
00042   po::options_description desc("Usage : tracker [options]", 120);
00043   desc.add_options()
00044     ( "help,h","show help screen")
00045     ( "dbname",po::value<std::string>(&dbName)->default_value(""),"database name (on localhost) NOT IMPLEMENTED YET")
00046     ( "device",po::value<std::string>(&device)->default_value(SERIAL_PORT),"serial device, e.g. /dev/ttyS0")
00047     ( "register-as-left",po::value<std::string>(&leftname)->default_value(LEFT_DEFAULT_NAME),"<left-tracker-name>" )
00048     ( "register-as-right",po::value<std::string>(&rightname)->default_value(RIGHT_DEFAULT_NAME),"<right-tracker-name>" ) 
00049     ( "no-left","Don't use left tracker" ) 
00050     ( "no-right","Don't use right tracker " )
00051     ( "calib-file",po::value<std::string>(&calibFile)," <filename>")
00052     ( "debug-level,d",po::value<unsigned int>(&debugLevel)->default_value(0),"the more, the higher ;)")
00053     //    ( "read-from-file <filename> ",po::value< vector<string> >()->composing(),"to read data from file and NOT from tracker NOT IMPLEMENTED" )
00054     ;
00055 
00056 
00057   po::variables_map vm;
00058   po::store(po::parse_command_line(argc, argv, desc), vm);
00059   po::notify(vm);
00060 
00061   if (vm.count("help")) {
00062     cout << desc <<endl;
00063     return 0;
00064   }
00065   
00066   dbName = vm["dbname"].as<std::string>();
00067   leftname = vm["register-as-left"].as<std::string>();
00068   rightname = vm["register-as-right"].as<std::string>();
00069   
00070   // Create new instance of your object.
00071   BirdTrack_impl *fob = new BirdTrack_impl(device);
00072   //fob->initialize_Tracker();
00073   //fob->start();
00074 
00075   tracker_impl *lefttracker;
00076   tracker_impl *righttracker;
00077   
00078   if(!vm.count("no-left")){
00079     lefttracker = new tracker_impl(leftTracker, fob, leftname);
00080     if(vm.count("calib-file"))
00081       lefttracker->loadCalibFile(calibFile.c_str());
00082     lefttracker->start();
00083   }
00084     if(!vm.count("no-right")){
00085       righttracker = new tracker_impl(rightTracker, fob, rightname);
00086       if(vm.count("calib-file"))
00087         righttracker->loadCalibFile(calibFile.c_str());
00088       righttracker->start();
00089   }
00090   
00091   if(!vm.count("no-left")){
00092     cout << "Published name for left tracker will be " << leftname.c_str() << endl;
00093   }
00094   if(!vm.count("no-right")){
00095     cout << "Published name for right tracker will be " << rightname.c_str() << endl;
00096   }
00097 
00098   while (do_loop) {
00099     std::string command;
00100     bool res;
00101     cin >> command;
00102     if (command.find("reload") != command.npos) {
00103       cout << "reloading calibration from file "<< calibFile <<endl;
00104       cout << "reloading calibration left:";
00105       res = lefttracker->loadCalibFile(calibFile.c_str());
00106       cout << (res?"Success":"Failure!") << endl;
00107       cout << "reloading calibration right:";
00108       res = righttracker->loadCalibFile(calibFile.c_str());
00109       cout << (res?"Success":"Failure!") << endl;
00110     }
00111 
00112   }
00113   // Main loop has finished; delete your object.
00114   
00115   if(!vm.count("no-left")) {
00116     lefttracker->stop();
00117     delete lefttracker;
00118   }
00119   if(!vm.count("no-right")) {
00120     righttracker->stop();
00121     delete righttracker;
00122   }
00123   delete fob;
00124 }


asr_flock_of_birds
Author(s): Bernhardt Andre, Engelmann Stephan, Giesler Björn, Heller Florian, Jäkel Rainer, Nguyen Trung, Pardowitz Michael, Weckesser Peter, Yi Xie, Zöllner Raoul
autogenerated on Sat Jun 8 2019 19:36:21