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


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