Changeset 158 in flair-src for trunk/demos/OpticalFlow
- Timestamp:
- Mar 5, 2017, 10:50:56 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/demos/OpticalFlow/simulator/src/main.cpp
r122 r158 23 23 #endif 24 24 25 26 25 using namespace TCLAP; 27 26 using namespace std; … … 40 39 void parseOptions(int argc, char** argv) 41 40 { 42 try 43 { 44 CmdLine cmd("Command description message", ' ', "0.1"); 41 try { 42 CmdLine cmd("Command description message", ' ', "0.1"); 45 43 46 ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");47 cmd.add( nameArg);44 ValueArg<string> nameArg("n", "name", "uav name, also used for vrpn", true, "x4", "string"); 45 cmd.add(nameArg); 48 46 49 ValueArg<string> xmlArg("x","xml","xml file",true,"./reglages.xml","string");50 cmd.add( xmlArg);47 ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string"); 48 cmd.add(xmlArg); 51 49 52 ValueArg<int> portArg("p","port","ground station port",true,9002,"int");53 cmd.add( portArg);50 ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int"); 51 cmd.add(portArg); 54 52 55 ValueArg<string> addressArg("a","address","ground station address",true,"127.0.0.1","string");56 cmd.add( addressArg);53 ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string"); 54 cmd.add(addressArg); 57 55 58 ValueArg<string> typeArg("t","type","uav type, x4 or x8",true,"x4","string");59 cmd.add( typeArg);56 ValueArg<string> typeArg("t", "type", "uav type, x4 or x8", true, "x4", "string"); 57 cmd.add(typeArg); 60 58 61 62 ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int"); 63 cmd.add( optiArg ); 59 ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int"); 60 cmd.add(optiArg); 64 61 65 62 #ifdef GL 66 ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");67 cmd.add( mediaArg);63 ValueArg<string> mediaArg("m", "media", "path to media files", true, "./", "string"); 64 cmd.add(mediaArg); 68 65 69 ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");70 cmd.add( sceneArg);66 ValueArg<string> sceneArg("s", "scene", "path to scene file", true, "./voliere.xml", "string"); 67 cmd.add(sceneArg); 71 68 #endif 72 69 73 cmd.parse( argc, argv);70 cmd.parse(argc, argv); 74 71 75 76 port=portArg.getValue();77 78 79 80 name=nameArg.getValue();81 address=addressArg.getValue();72 // Get the value parsed by each arg. 73 port = portArg.getValue(); 74 xml_file = xmlArg.getValue(); 75 opti_time = optiArg.getValue(); 76 type = typeArg.getValue(); 77 name = nameArg.getValue(); 78 address = addressArg.getValue(); 82 79 #ifdef GL 83 media_path=mediaArg.getValue();84 scene_file=sceneArg.getValue();80 media_path = mediaArg.getValue(); 81 scene_file = sceneArg.getValue(); 85 82 #endif 86 83 87 } catch (ArgException &e) // catch any exceptions 88 { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; } 84 } catch(ArgException& e) // catch any exceptions 85 { 86 cerr << "error: " << e.error() << " for arg " << e.argId() << endl; 87 } 89 88 } 90 91 89 92 90 int main(int argc, char* argv[]) 93 91 { 94 Simulator *simu;95 Model *drone;96 92 Simulator* simu; 93 Model* drone; 94 SimuImu* imu; 97 95 #ifdef GL 98 96 SimuUsGL* us_gl; 99 97 100 SimuCameraGL *cam_bas;101 Parser *gui;98 SimuCameraGL* cam_bas; 99 Parser* gui; 102 100 #endif 103 parseOptions(argc,argv);101 parseOptions(argc, argv); 104 102 105 simu= new Simulator("simulator",opti_time,90);106 simu->SetupConnection(address,port);107 103 simu = new Simulator("simulator", opti_time, 90); 104 simu->SetupConnection(address, port); 105 simu->SetupUserInterface(xml_file); 108 106 109 107 #ifdef GL 110 gui=new Parser(simu,960,480,640,480,media_path,scene_file);108 gui = new Parser(960, 480, 640, 480, media_path, scene_file); 111 109 #endif 112 110 113 if(type=="x4") 114 { 115 drone=new X4(simu,name,0); 116 } 117 else 118 { 119 drone=new X8(simu,name,0); 120 } 121 imu=new SimuImu(drone,"imu",0); 111 if(type == "x4") { 112 drone = new X4(name, 0); 113 } else { 114 drone = new X8(name, 0); 115 } 116 imu = new SimuImu(drone, "imu", 0,0); 122 117 123 118 #ifdef GL 124 us_gl=new SimuUsGL(drone,"us",0);125 cam_bas=new SimuCameraGL(drone,"bottom camera",320,240,640,0,0);119 us_gl = new SimuUsGL(drone, "us", 0,0); 120 cam_bas = new SimuCameraGL(drone, "bottom camera", 320, 240, 640, 0, 0,0); 126 121 #endif 127 122 128 123 simu->RunSimu(); 129 124 130 125 delete simu; 131 126 132 127 return 0; 133 128 } 134
Note:
See TracChangeset
for help on using the changeset viewer.