trackerServer/Main.cc
Go to the documentation of this file.
1 
18 /* system includes */
19 #include <boost/program_options.hpp>
20 #include <iostream>
21 /* my includes */
22 /* (none) */
23 #include "BirdTrack_impl.h"
24 #include "tracker_impl.h"
25 
26 /*
27  \brief Start the Flock of Bird Server
28 */
29 unsigned int debugLevel;
30 const static char* LEFT_DEFAULT_NAME = "TrackLeft";
31 const static char* RIGHT_DEFAULT_NAME = "TrackRight";
32 const static char* SERIAL_PORT = "/dev/ttyS0";
33 
34 namespace po = boost::program_options;
35 
36 
37 int main(int argc, char **argv)
38 {
39  std::string leftname, rightname, dbName, filename, calibFile, device;
40  bool do_loop=true;
41 
42  po::options_description desc("Usage : tracker [options]", 120);
43  desc.add_options()
44  ( "help,h","show help screen")
45  ( "dbname",po::value<std::string>(&dbName)->default_value(""),"database name (on localhost) NOT IMPLEMENTED YET")
46  ( "device",po::value<std::string>(&device)->default_value(SERIAL_PORT),"serial device, e.g. /dev/ttyS0")
47  ( "register-as-left",po::value<std::string>(&leftname)->default_value(LEFT_DEFAULT_NAME),"<left-tracker-name>" )
48  ( "register-as-right",po::value<std::string>(&rightname)->default_value(RIGHT_DEFAULT_NAME),"<right-tracker-name>" )
49  ( "no-left","Don't use left tracker" )
50  ( "no-right","Don't use right tracker " )
51  ( "calib-file",po::value<std::string>(&calibFile)," <filename>")
52  ( "debug-level,d",po::value<unsigned int>(&debugLevel)->default_value(0),"the more, the higher ;)")
53  // ( "read-from-file <filename> ",po::value< vector<string> >()->composing(),"to read data from file and NOT from tracker NOT IMPLEMENTED" )
54  ;
55 
56 
57  po::variables_map vm;
58  po::store(po::parse_command_line(argc, argv, desc), vm);
59  po::notify(vm);
60 
61  if (vm.count("help")) {
62  cout << desc <<endl;
63  return 0;
64  }
65 
66  dbName = vm["dbname"].as<std::string>();
67  leftname = vm["register-as-left"].as<std::string>();
68  rightname = vm["register-as-right"].as<std::string>();
69 
70  // Create new instance of your object.
71  BirdTrack_impl *fob = new BirdTrack_impl(device);
72  //fob->initialize_Tracker();
73  //fob->start();
74 
75  tracker_impl *lefttracker;
76  tracker_impl *righttracker;
77 
78  if(!vm.count("no-left")){
79  lefttracker = new tracker_impl(leftTracker, fob, leftname);
80  if(vm.count("calib-file"))
81  lefttracker->loadCalibFile(calibFile.c_str());
82  lefttracker->start();
83  }
84  if(!vm.count("no-right")){
85  righttracker = new tracker_impl(rightTracker, fob, rightname);
86  if(vm.count("calib-file"))
87  righttracker->loadCalibFile(calibFile.c_str());
88  righttracker->start();
89  }
90 
91  if(!vm.count("no-left")){
92  cout << "Published name for left tracker will be " << leftname.c_str() << endl;
93  }
94  if(!vm.count("no-right")){
95  cout << "Published name for right tracker will be " << rightname.c_str() << endl;
96  }
97 
98  while (do_loop) {
99  std::string command;
100  bool res;
101  cin >> command;
102  if (command.find("reload") != command.npos) {
103  cout << "reloading calibration from file "<< calibFile <<endl;
104  cout << "reloading calibration left:";
105  res = lefttracker->loadCalibFile(calibFile.c_str());
106  cout << (res?"Success":"Failure!") << endl;
107  cout << "reloading calibration right:";
108  res = righttracker->loadCalibFile(calibFile.c_str());
109  cout << (res?"Success":"Failure!") << endl;
110  }
111 
112  }
113  // Main loop has finished; delete your object.
114 
115  if(!vm.count("no-left")) {
116  lefttracker->stop();
117  delete lefttracker;
118  }
119  if(!vm.count("no-right")) {
120  righttracker->stop();
121  delete righttracker;
122  }
123  delete fob;
124 }
static const char * SERIAL_PORT
filename
unsigned int debugLevel
int main(int argc, char **argv)
bool loadCalibFile(const char *srcFileName)
static const char * LEFT_DEFAULT_NAME
ROSLIB_DECL std::string command(const std::string &cmd)
static const char * RIGHT_DEFAULT_NAME


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 Mon Jun 10 2019 12:44:40