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


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