Changeset 158 in flair-src


Ignore:
Timestamp:
Mar 5, 2017, 10:50:56 AM (8 years ago)
Author:
Sanahuja Guillaume
Message:

corrected simu/device id for sensors

Location:
trunk
Files:
49 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/CircleFollower/simulator/src/main.cpp

    r123 r158  
    2323#endif
    2424
    25 
    2625using namespace TCLAP;
    2726using namespace std;
     
    3837string address;
    3938
    40 void parseOptions(int argc, char** argv) {
    41         try {
    42         CmdLine cmd("Command description message", ' ', "0.1");
     39void parseOptions(int argc, char** argv)
     40{
     41  try {
     42    CmdLine cmd("Command description message", ' ', "0.1");
    4343
    44         ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
    45         cmd.add( nameArg );
     44    ValueArg<string> nameArg("n", "name", "uav name, also used for vrpn", true, "x4", "string");
     45    cmd.add(nameArg);
    4646
    47         ValueArg<string> xmlArg("x","xml","xml file",true,"./reglages.xml","string");
    48         cmd.add( xmlArg );
     47    ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string");
     48    cmd.add(xmlArg);
    4949
    50         ValueArg<int> portArg("p","port","ground station port",true,9002,"int");
    51         cmd.add( portArg );
     50    ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int");
     51    cmd.add(portArg);
    5252
    53         ValueArg<string> addressArg("a","address","ground station address",true,"127.0.0.1","string");
    54         cmd.add( addressArg );
     53    ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string");
     54    cmd.add(addressArg);
    5555
    56         ValueArg<string> typeArg("t","type","uav type, x4 or x8",true,"x4","string");
    57         cmd.add( typeArg );
     56    ValueArg<string> typeArg("t", "type", "uav type, x4 or x8", true, "x4", "string");
     57    cmd.add(typeArg);
    5858
    59         ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int");
    60         cmd.add( optiArg );
     59    ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int");
     60    cmd.add(optiArg);
    6161
    6262#ifdef GL
    63         ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");
    64         cmd.add( mediaArg );
     63    ValueArg<string> mediaArg("m", "media", "path to media files", true, "./", "string");
     64    cmd.add(mediaArg);
    6565
    66         ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");
    67         cmd.add( sceneArg );
     66    ValueArg<string> sceneArg("s", "scene", "path to scene file", true, "./voliere.xml", "string");
     67    cmd.add(sceneArg);
    6868#endif
    6969
    70         cmd.parse( argc, argv );
     70    cmd.parse(argc, argv);
    7171
    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();
     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();
    7979#ifdef GL
    80         media_path=mediaArg.getValue();
    81         scene_file=sceneArg.getValue();
     80    media_path = mediaArg.getValue();
     81    scene_file = sceneArg.getValue();
    8282#endif
    8383
    84         } catch (ArgException &e) {
    85             cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
    86     }
     84  } catch(ArgException& e) {
     85    cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
     86  }
    8787}
    8888
    89 int main(int argc, char* argv[]) {
    90     Simulator *simu;
    91     Model *drone;
    92     SimuImu* imu;
     89int main(int argc, char* argv[])
     90{
     91  Simulator* simu;
     92  Model* drone;
     93  SimuImu* imu;
    9394#ifdef GL
    94     SimuUsGL* us_gl;
    95     Parser *gui;
    96     Man *man;
     95  SimuUsGL* us_gl;
     96  Parser* gui;
     97  Man* man;
    9798#endif
    98     parseOptions(argc,argv);
     99  parseOptions(argc, argv);
    99100
    100     simu= new Simulator("simulator",opti_time,90);
    101     simu->SetupConnection(address,port);
    102     simu->SetupUserInterface(xml_file);
     101  simu = new Simulator("simulator", opti_time, 90);
     102  simu->SetupConnection(address, port);
     103  simu->SetupUserInterface(xml_file);
    103104
    104105#ifdef GL
    105     gui=new Parser(simu,1024,768,1024,768,media_path,scene_file);
     106  gui = new Parser(1024, 768, 1024, 768, media_path, scene_file);
    106107#endif
    107108
    108     if(type=="x4") {
    109         drone=new X4(simu,name,0);
    110     } else {
    111         drone=new X8(simu,name,0);
    112     }
     109  if(type == "x4") {
     110    drone = new X4(name, 0);
     111  } else {
     112    drone = new X8(name, 0);
     113  }
    113114
    114     imu=new SimuImu(drone,"imu",0);
     115  imu = new SimuImu(drone, "imu", 0,0);
    115116
    116117#ifdef GL
    117     us_gl=new SimuUsGL(drone,"us",0);
    118    
     118  us_gl = new SimuUsGL(drone, "us", 0,0);
    119119
    120     man=new Man(simu,"target");
     120  man = new Man("target",1);
    121121#endif
    122122
    123     simu->RunSimu();
     123  simu->RunSimu();
    124124
    125     delete simu;
     125  delete simu;
    126126
    127         return 0;
     127  return 0;
    128128}
    129 
  • trunk/demos/Gps/simulator/src/main.cpp

    r123 r158  
    2424#endif
    2525
    26 
    2726using namespace TCLAP;
    2827using namespace std;
     
    3938string address;
    4039
    41 void parseOptions(int argc, char** argv) {
    42         try {
    43         CmdLine cmd("Command description message", ' ', "0.1");
     40void parseOptions(int argc, char** argv)
     41{
     42  try {
     43    CmdLine cmd("Command description message", ' ', "0.1");
    4444
    45         ValueArg<string> nameArg("n","name","uav name, also used for vrpn",true,"x4","string");
    46         cmd.add( nameArg );
     45    ValueArg<string> nameArg("n", "name", "uav name, also used for vrpn", true, "x4", "string");
     46    cmd.add(nameArg);
    4747
    48         ValueArg<string> xmlArg("x","xml","xml file",true,"./reglages.xml","string");
    49         cmd.add( xmlArg );
     48    ValueArg<string> xmlArg("x", "xml", "xml file", true, "./reglages.xml", "string");
     49    cmd.add(xmlArg);
    5050
    51         ValueArg<int> portArg("p","port","ground station port",true,9002,"int");
    52         cmd.add( portArg );
     51    ValueArg<int> portArg("p", "port", "ground station port", true, 9002, "int");
     52    cmd.add(portArg);
    5353
    54         ValueArg<string> addressArg("a","address","ground station address",true,"127.0.0.1","string");
    55         cmd.add( addressArg );
     54    ValueArg<string> addressArg("a", "address", "ground station address", true, "127.0.0.1", "string");
     55    cmd.add(addressArg);
    5656
    57         ValueArg<string> typeArg("t","type","uav type, x4 or x8",true,"x4","string");
    58         cmd.add( typeArg );
     57    ValueArg<string> typeArg("t", "type", "uav type, x4 or x8", true, "x4", "string");
     58    cmd.add(typeArg);
    5959
    60         ValueArg<int> optiArg("o","opti","optitrack time ms",false,0,"int");
    61         cmd.add( optiArg );
     60    ValueArg<int> optiArg("o", "opti", "optitrack time ms", false, 0, "int");
     61    cmd.add(optiArg);
    6262
    6363#ifdef GL
    64         ValueArg<string> mediaArg("m","media","path to media files",true,"./","string");
    65         cmd.add( mediaArg );
     64    ValueArg<string> mediaArg("m", "media", "path to media files", true, "./", "string");
     65    cmd.add(mediaArg);
    6666
    67         ValueArg<string> sceneArg("s","scene","path to scene file",true,"./voliere.xml","string");
    68         cmd.add( sceneArg );
     67    ValueArg<string> sceneArg("s", "scene", "path to scene file", true, "./voliere.xml", "string");
     68    cmd.add(sceneArg);
    6969#endif
    7070
    71         cmd.parse( argc, argv );
     71    cmd.parse(argc, argv);
    7272
    73         // Get the value parsed by each arg.
    74         port=portArg.getValue();
    75         xml_file = xmlArg.getValue();
    76         opti_time = optiArg.getValue();
    77         type = typeArg.getValue();
    78         name=nameArg.getValue();
    79         address=addressArg.getValue();
     73    // Get the value parsed by each arg.
     74    port = portArg.getValue();
     75    xml_file = xmlArg.getValue();
     76    opti_time = optiArg.getValue();
     77    type = typeArg.getValue();
     78    name = nameArg.getValue();
     79    address = addressArg.getValue();
    8080#ifdef GL
    81         media_path=mediaArg.getValue();
    82         scene_file=sceneArg.getValue();
     81    media_path = mediaArg.getValue();
     82    scene_file = sceneArg.getValue();
    8383#endif
    8484
    85         } catch (ArgException &e) {
    86             cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
    87     }
     85  } catch(ArgException& e) {
     86    cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
     87  }
    8888}
    8989
    90 int main(int argc, char* argv[]) {
    91     Simulator *simu;
    92     Model *drone;
    93     SimuImu *imu;
    94     SimuGps *gps;
     90int main(int argc, char* argv[])
     91{
     92  Simulator* simu;
     93  Model* drone;
     94  SimuImu* imu;
     95  SimuGps* gps;
    9596#ifdef GL
    96     SimuUsGL *us_gl;
    97     Parser *gui;
    98     Man *man;
     97  SimuUsGL* us_gl;
     98  Parser* gui;
    9999#endif
    100     parseOptions(argc,argv);
     100  parseOptions(argc, argv);
    101101
    102     simu= new Simulator("simulator",opti_time,0);
    103     simu->SetupConnection(address,port);
    104     simu->SetupUserInterface(xml_file);
     102  simu = new Simulator("simulator", opti_time, 0);
     103  simu->SetupConnection(address, port);
     104  simu->SetupUserInterface(xml_file);
    105105
    106106#ifdef GL
    107     gui=new Parser(simu,1024,768,1024,768,media_path,scene_file);
     107  gui = new Parser(1024, 768, 1024, 768, media_path, scene_file);
    108108#endif
    109109
    110     if(type=="x4") {
    111         drone=new X4(simu,name,0);
    112     } else {
    113         drone=new X8(simu,name,0);
    114     }
     110  if(type == "x4") {
     111    drone = new X4(name, 0);
     112  } else {
     113    drone = new X8(name, 0);
     114  }
    115115
    116     imu=new SimuImu(drone,"imu",90);
     116  imu = new SimuImu(drone, "imu", 0,0);
    117117
    118118#ifdef GL
    119     us_gl=new SimuUsGL(drone,"us",0);
    120     man=new Man(simu,"target");
     119  us_gl = new SimuUsGL(drone, "us", 0,0);
    121120#endif
    122     gps=new SimuGps(drone,"gps",0);
     121  gps = new SimuGps(drone, "gps", 0,0);
    123122
    124     simu->RunSimu();
     123  simu->RunSimu();
    125124
    126     delete simu;
     125  delete simu;
    127126
    128         return 0;
     127  return 0;
    129128}
    130 
  • trunk/demos/OpticalFlow/simulator/src/main.cpp

    r122 r158  
    2323#endif
    2424
    25 
    2625using namespace TCLAP;
    2726using namespace std;
     
    4039void parseOptions(int argc, char** argv)
    4140{
    42         try
    43         {
    44         CmdLine cmd("Command description message", ' ', "0.1");
     41  try {
     42    CmdLine cmd("Command description message", ' ', "0.1");
    4543
    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);
    4846
    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);
    5149
    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);
    5452
    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);
    5755
    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);
    6058
    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);
    6461
    6562#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);
    6865
    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);
    7168#endif
    7269
    73         cmd.parse( argc, argv );
     70    cmd.parse(argc, argv);
    7471
    75         // Get the value parsed by each arg.
    76         port=portArg.getValue();
    77         xml_file = xmlArg.getValue();
    78         opti_time = optiArg.getValue();
    79         type = typeArg.getValue();
    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();
    8279#ifdef GL
    83         media_path=mediaArg.getValue();
    84         scene_file=sceneArg.getValue();
     80    media_path = mediaArg.getValue();
     81    scene_file = sceneArg.getValue();
    8582#endif
    8683
    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  }
    8988}
    90 
    9189
    9290int main(int argc, char* argv[])
    9391{
    94     Simulator *simu;
    95     Model *drone;
    96     SimuImu* imu;
     92  Simulator* simu;
     93  Model* drone;
     94  SimuImu* imu;
    9795#ifdef GL
    98     SimuUsGL* us_gl;
     96  SimuUsGL* us_gl;
    9997
    100     SimuCameraGL *cam_bas;
    101     Parser *gui;
     98  SimuCameraGL* cam_bas;
     99  Parser* gui;
    102100#endif
    103     parseOptions(argc,argv);
     101  parseOptions(argc, argv);
    104102
    105     simu= new Simulator("simulator",opti_time,90);
    106     simu->SetupConnection(address,port);
    107     simu->SetupUserInterface(xml_file);
     103  simu = new Simulator("simulator", opti_time, 90);
     104  simu->SetupConnection(address, port);
     105  simu->SetupUserInterface(xml_file);
    108106
    109107#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);
    111109#endif
    112110
    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);
    122117
    123118#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);
    126121#endif
    127122
    128     simu->RunSimu();
     123  simu->RunSimu();
    129124
    130     delete simu;
     125  delete simu;
    131126
    132         return 0;
     127  return 0;
    133128}
    134 
  • trunk/demos/SimpleFleet/simulator/src/main.cpp

    r33 r158  
    8484int main(int argc, char* argv[])
    8585{
    86     Simulator *simu;
     86  Simulator *simu;
    8787
    88     parseOptions(argc,argv);
     88  parseOptions(argc,argv);
    8989
    90     simu= new Simulator("simulator",opti_time,90);
    91     simu->SetupConnection(address,port);
    92     simu->SetupUserInterface(xml_file);
     90  simu= new Simulator("simulator",opti_time,90);
     91  simu->SetupConnection(address,port);
     92  simu->SetupUserInterface(xml_file);
     93  #ifdef GL
     94  Parser *gui=new Parser(1024,768,1024,768,media_path,scene_file);
     95  #endif
     96  for(int i=0; i<2;i++) {
     97    stringstream uavName;
     98    uavName << name.c_str() << "_" << i;
     99    Model *drone=new X8(uavName.str(),i);
    93100#ifdef GL
    94     Parser *gui=new Parser(simu,640,480,640,480,media_path,scene_file);
     101    SimuUsGL *us_gl=new SimuUsGL(drone,"us",i,0);
    95102#endif
    96     for(int i=0; i<2;i++)
    97         {
    98                 stringstream s;
    99                 s << name.c_str() << "_" << i;
    100         Model *drone=new X8(simu,s.str(),i);
    101 #ifdef GL
    102         SimuUsGL *us_gl=new SimuUsGL(drone,"us",i);
    103 #endif
    104         SimuImu *imu=new SimuImu(drone,"imu",i);
    105         }
     103    SimuImu *imu=new SimuImu(drone,"imu",i,0);
     104  }
    106105
    107     simu->RunSimu();
     106  simu->RunSimu();
    108107
    109     delete simu;
     108  delete simu;
    110109
    111110        return 0;
  • trunk/demos/SimpleFleet/uav/build_x86_64/bin/setup_x8.xml

    r91 r158  
    135135    </DataPlot1D>
    136136   </Tab>
    137   </TabWidget>
     137  <Tab name="Quaternion"><DataPlot1D name="q0" period="100" enabled="0"/><DataPlot1D name="q1" period="100" enabled="0"/><DataPlot1D name="q2" period="100" enabled="0"/><DataPlot1D name="q3" period="100" enabled="0"/></Tab><Tab name="IMU"><DataPlot1D name="acc_x" period="100" enabled="0"/><DataPlot1D name="acc_y" period="100" enabled="0"/><DataPlot1D name="acc_z" period="100" enabled="0"/><DataPlot1D name="gyr_x" period="100" enabled="0"/><DataPlot1D name="gyr_y" period="100" enabled="0"/><DataPlot1D name="gyr_z" period="100" enabled="0"/><DataPlot1D name="mag_x" period="100" enabled="0"/><DataPlot1D name="mag_y" period="100" enabled="0"/><DataPlot1D name="mag_z" period="100" enabled="0"/></Tab></TabWidget>
    138138 </Tab>
    139139 <Tab name="battery">
     
    340340 </Tab>
    341341</TabWidget>
    342 <TabWidget name="App_TabWidget"><Tab name="x8_0"><PushButton name="save config on target" value="1"/></Tab><Tab name="x8_1"><PushButton name="save config on target" value="1"/></Tab></TabWidget></root>
     342<TabWidget name="App_TabWidget"><Tab name="x8_0"><PushButton name="save config on target" value="1"/></Tab><Tab name="x8_1"><PushButton name="save config on target" value="1"/></Tab></TabWidget><PushButton name="save config on target (x8_0)" value="1"/></root>
  • trunk/lib/FlairFilter/src/SimuAhrs.cpp

    r157 r158  
    2727namespace filter {
    2828
    29 SimuAhrs::SimuAhrs(string name, uint32_t dev_id,
     29SimuAhrs::SimuAhrs(string name, uint32_t modelId,uint32_t deviceId,
    3030                   uint8_t priority)
    31     : Ahrs(new SimuImu(name, dev_id, priority), name) {
     31    : Ahrs(new SimuImu(name, modelId,deviceId, priority), name) {
    3232  SetIsReady(true);
    3333}
  • trunk/lib/FlairFilter/src/SimuAhrs.h

    r157 r158  
    3333  *
    3434  * \param name name
    35   * \param dev_id number id of the simulated Ahrs
     35  * \param modelId Model id
     36  * \param deviceId Ahrs id of the Model
    3637  * \param priority priority of the SimuImu Thread
    3738  */
    3839  SimuAhrs(std::string name,
    39            uint32_t dev_id, uint8_t priority);
     40           uint32_t modelId,uint32_t deviceId, uint8_t priority);
    4041
    4142  /*!
  • trunk/lib/FlairMeta/src/SimuX4.cpp

    r157 r158  
    3838namespace meta {
    3939
    40 SimuX4::SimuX4(string name, int simu_id,string options,
     40SimuX4::SimuX4(string name, uint32_t simu_id,string options,
    4141               filter::UavMultiplex *multiplex)
    4242    : Uav(name, multiplex) {
     
    4646
    4747  SetBldc(new SimuBldc(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
    48                        "motors", GetUavMultiplex()->MotorsCount(), simu_id));
    49   SetUsRangeFinder(new SimuUs("us", simu_id, 60));
    50   SetAhrs(new SimuAhrs("imu", simu_id, 70));
     48                       "motors", GetUavMultiplex()->MotorsCount(), simu_id,0));
     49  SetUsRangeFinder(new SimuUs("us", simu_id,0, 60));
     50  SetAhrs(new SimuAhrs("imu", simu_id, 0,70));
    5151  Tab *bat_tab = new Tab(getFrameworkManager()->GetTabWidget(), "battery");
    5252  SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
     
    5959        }
    6060 
    61   SetVerticalCamera(
    62       new SimuCamera("simu_cam_v", camvWidth, camvHeight, 3, simu_id, 10));
     61  SetVerticalCamera(new SimuCamera("simu_cam_v", camvWidth, camvHeight, 3, simu_id,0, 10));
     62  //SetHorizontalCamera(new SimuCamera("simu_cam_h", 320, 240, 3, simu_id,1, 10));
    6363}
    6464
  • trunk/lib/FlairMeta/src/SimuX4.h

    r157 r158  
    2626  // simu_id: 0 if simulating only one UAV
    2727  //>0 otherwise
    28   SimuX4(std::string name, int simu_id = 0,std::string options="",
     28  SimuX4(std::string name, uint32_t simu_id = 0,std::string options="",
    2929         filter::UavMultiplex *multiplex = NULL);
    3030  ~SimuX4();
  • trunk/lib/FlairMeta/src/SimuX8.cpp

    r157 r158  
    3737namespace meta {
    3838
    39 SimuX8::SimuX8(string name, int simu_id,string options,
     39SimuX8::SimuX8(string name, uint32_t simu_id,string options,
    4040               filter::UavMultiplex *multiplex)
    4141    : Uav(name, multiplex) {
     
    4545
    4646  SetBldc(new SimuBldc(GetUavMultiplex(), GetUavMultiplex()->GetLayout(),
    47                        "motors", GetUavMultiplex()->MotorsCount(), simu_id));
    48   SetUsRangeFinder(new SimuUs("us", simu_id, 60));
    49   SetAhrs(new SimuAhrs("imu", simu_id, 70));
     47                       "motors", GetUavMultiplex()->MotorsCount(), simu_id,0));
     48  SetUsRangeFinder(new SimuUs("us", simu_id,0, 60));
     49  SetAhrs(new SimuAhrs("imu", simu_id, 0,70));
    5050  Tab *bat_tab = new Tab(getFrameworkManager()->GetTabWidget(), "battery");
    5151  SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
    5252  GetBatteryMonitor()->SetBatteryValue(12);
    53   SetVerticalCamera(
    54       new SimuCamera("simu_cam_v", 320, 240, 3, simu_id, 10));
     53  SetVerticalCamera(new SimuCamera("simu_cam_v", 320, 240, 3, simu_id,0, 10));
     54  //SetHorizontalCamera(new SimuCamera("simu_cam_h", 320, 240, 3, simu_id,1, 10));
    5555}
    5656
  • trunk/lib/FlairMeta/src/SimuX8.h

    r157 r158  
    2626  // simu_id: 0 if simulating only one UAV
    2727  //>0 otherwise
    28   SimuX8(std::string name, int simu_id = 0,std::string options="",
     28  SimuX8(std::string name, uint32_t simu_id = 0,std::string options="",
    2929         filter::UavMultiplex *multiplex = NULL);
    3030  ~SimuX8();
  • trunk/lib/FlairSensorActuator/src/SimuBldc.cpp

    r157 r158  
    3333
    3434SimuBldc::SimuBldc(const IODevice *parent, Layout *layout, string name,
    35                    uint8_t motors_count, uint32_t dev_id)
     35                   uint8_t motors_count, uint32_t modelId,uint32_t deviceId)
    3636    : Bldc(parent, layout, name, motors_count) {
    37   ostringstream dev_name;
    38   dev_name << "simu_bldc_" << dev_id;
    3937  shmem =
    40       new SharedMem(this, dev_name.str().c_str(), motors_count * sizeof(float));
     38      new SharedMem(this, ShMemName(modelId, deviceId), motors_count * sizeof(float));
    4139
    4240  GroupBox *groupbox = new GroupBox(layout->NewRow(), "simubldc");
     
    4745
    4846SimuBldc::SimuBldc(const Object *parent, string name, uint8_t motors_count,
    49                    uint32_t dev_id)
     47                   uint32_t modelId,uint32_t deviceId)
    5048    : Bldc(parent, name, motors_count) {
    51   ostringstream dev_name;
    52   dev_name << "simu_bldc_" << dev_id;
    5349  shmem =
    54       new SharedMem(this, dev_name.str().c_str(), motors_count * sizeof(float));
     50      new SharedMem(this, ShMemName(modelId, deviceId), motors_count * sizeof(float));
    5551
    5652  // reset values
     
    6561
    6662SimuBldc::~SimuBldc() {}
     63
     64string SimuBldc::ShMemName(uint32_t modelId,uint32_t deviceId) {
     65  ostringstream dev_name;
     66  dev_name << "simu" <<  modelId << "_bldc_" << deviceId;
     67  return dev_name.str().c_str();
     68}
    6769
    6870void SimuBldc::SetMotors(float *value) {
  • trunk/lib/FlairSensorActuator/src/SimuBldc.h

    r15 r158  
    4646  * \param name name
    4747  * \param motors_count number of motors
    48   * \param dev_id device id
     48  * \param modelId Model id
     49  * \param deviceId Bldc id of the Model
    4950  */
    5051  SimuBldc(const core::IODevice *parent, gui::Layout *layout, std::string name,
    51            uint8_t motors_count, uint32_t dev_id);
     52           uint8_t motors_count, uint32_t modelId,uint32_t deviceId);
    5253
    5354  /*!
     
    5960  * \param name name
    6061  * \param motors_count number of motors
    61   * \param dev_id device id
     62  * \param modelId Model id
     63  * \param deviceId Bldc id of the Model
    6264  */
    6365  SimuBldc(const core::Object *parent, std::string name, uint8_t motors_count,
    64            uint32_t dev_id);
     66           uint32_t modelId,uint32_t deviceId);
    6567
    6668  /*!
     
    107109  */
    108110  void SetMotors(float *value);
    109 
     111 
     112  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    110113  core::SharedMem *shmem;
    111114  gui::DoubleSpinBox *k;
  • trunk/lib/FlairSensorActuator/src/SimuCamera.cpp

    r157 r158  
    3333SimuCamera::SimuCamera(string name,
    3434                       uint16_t width, uint16_t height, uint8_t channels,
    35                        uint32_t dev_id, uint8_t priority)
     35                       uint32_t modelId,uint32_t deviceId, uint8_t priority)
    3636    : Thread(getFrameworkManager(), name, priority),
    3737      Camera(name, width, height, cvimage::Type::Format::BGR) {
     
    4343
    4444  ostringstream dev_name;
    45   dev_name << "simu_cam_" << dev_id;
    46   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), buf_size, SharedMem::Type::producerConsumer);
     45  dev_name << "simu" <<  modelId << "_cam_" << deviceId;
     46  shmem = new SharedMem((Thread *)this,ShMemName(modelId, deviceId), buf_size, SharedMem::Type::producerConsumer);
    4747 
    4848  SetIsReady(true);
     
    5151//simulation part
    5252SimuCamera::SimuCamera(const IODevice *parent, string name, uint16_t width,
    53                        uint16_t height, uint8_t channels, uint32_t dev_id)
     53                       uint16_t height, uint8_t channels, uint32_t modelId,uint32_t deviceId)
    5454    : Thread(parent, name, 0), Camera(parent,name) {
    5555
    5656  buf_size = width * height * channels+sizeof(Time);
    5757 
    58   ostringstream dev_name;
    59   dev_name << "simu_cam_" << dev_id;
    60   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     58  shmem = new SharedMem((Thread *)this,ShMemName(modelId, deviceId),
    6159                        buf_size, SharedMem::Type::producerConsumer);
    6260  shmemReadBuf=NULL;
     
    6967  Join();
    7068  if(shmemReadBuf!=NULL) delete shmemReadBuf;
     69}
     70
     71string SimuCamera::ShMemName(uint32_t modelId,uint32_t deviceId) {
     72  ostringstream dev_name;
     73  dev_name << "simu" <<  modelId << "_cam_" << deviceId;
     74  return dev_name.str().c_str();
    7175}
    7276
  • trunk/lib/FlairSensorActuator/src/SimuCamera.h

    r151 r158  
    4242  * \param height height
    4343  * \param channels number of channels
    44   * \param dev_id device id
     44  * \param modelId Model id
     45  * \param deviceId Camera id of the Model
    4546  * \param priority priority of the Thread
    4647  */
    4748  SimuCamera(std::string name,
    48              uint16_t width, uint16_t height, uint8_t channels, uint32_t dev_id,
     49             uint16_t width, uint16_t height, uint8_t channels, uint32_t modelId,uint32_t deviceId,
    4950             uint8_t priority);
    5051
     
    6061  * \param height height
    6162  * \param channels number of channels
    62   * \param dev_id device id
     63  * \param modelId Model id
     64  * \param deviceId Camera id of the Model
    6365  */
    6466  SimuCamera(const core::IODevice *parent, std::string name, uint16_t width,
    65              uint16_t height, uint8_t channels, uint32_t dev_id);
     67             uint16_t height, uint8_t channels, uint32_t modelId,uint32_t deviceId);
    6668
    6769  /*!
     
    9597  */
    9698  void UpdateFrom(const core::io_data *data){};
     99 
     100  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    97101
    98102  size_t buf_size;
  • trunk/lib/FlairSensorActuator/src/SimuGps.cpp

    r157 r158  
    3939
    4040SimuGps::SimuGps(string name,
    41                  NmeaGps::NMEAFlags_t NMEAFlags, uint32_t deviceId,uint8_t priority)
     41                 NmeaGps::NMEAFlags_t NMEAFlags, uint32_t modelId,uint32_t deviceId,uint8_t priority)
    4242    : NmeaGps(name, NMEAFlags),Thread(getFrameworkManager(), name, priority) {
    4343
     
    4949  numberOfSatellites = new SpinBox(GetGroupBox()->NewRow(), "number of satellites", 1, 15, 1, 5);
    5050
    51   ostringstream dev_name;
    52   dev_name << "simu_gps_" << deviceId;
    53   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     51  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    5452                        sizeof(gps_states_t));
    5553                       
     
    5856
    5957
    60 SimuGps::SimuGps(const IODevice *parent, string name, uint32_t deviceId)
     58SimuGps::SimuGps(const IODevice *parent, string name, uint32_t modelId,uint32_t deviceId)
    6159    : NmeaGps(parent, name), Thread(parent, name, 0) {
    6260  dataRate = NULL;
    6361
    64   ostringstream dev_name;
    65   dev_name << "simu_gps_" << deviceId;
    66   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     62  shmem = new SharedMem((Thread *)this,ShMemName(modelId, deviceId),
    6763                        sizeof(gps_states_t));
    6864 
     
    7369  SafeStop();
    7470  Join();
     71}
     72
     73string SimuGps::ShMemName(uint32_t modelId,uint32_t deviceId) {
     74  ostringstream dev_name;
     75  dev_name << "simu" <<  modelId << "_gps_" << deviceId;
     76  return dev_name.str().c_str();
    7577}
    7678
  • trunk/lib/FlairSensorActuator/src/SimuGps.h

    r137 r158  
    4343  * \param name name
    4444  * \param NMEAFlags NMEA sentances to enable
    45   * \param deviceId device id
     45  * \param modelId Model id
     46  * \param deviceId Gps id of the Model
    4647  * \param priority priority of the Thread
    4748  */
    4849  SimuGps(std::string name,
    49           NmeaGps::NMEAFlags_t NMEAFlags, uint32_t deviceId,uint8_t priority);
     50          NmeaGps::NMEAFlags_t NMEAFlags, uint32_t modelId,uint32_t deviceId,uint8_t priority);
    5051
    5152  /*!
     
    5758  * \param parent parent
    5859  * \param name name
    59   * \param deviceId device id
     60  * \param modelId Model id
     61  * \param deviceId Gps id of the Model
    6062  */
    61   SimuGps(const core::IODevice *parent, std::string name, uint32_t deviceId);
     63  SimuGps(const core::IODevice *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    6264
    6365  /*!
     
    9294    float vn;
    9395  } gps_states_t;
     96 
     97  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    9498
    9599  core::SharedMem *shmem;
  • trunk/lib/FlairSensorActuator/src/SimuImu.cpp

    r157 r158  
    3434namespace sensor {
    3535
    36 SimuImu::SimuImu(string name, uint32_t dev_id,
     36SimuImu::SimuImu(string name, uint32_t modelId,uint32_t deviceId,
    3737                 uint8_t priority)
    3838    : Imu(name), Thread(getFrameworkManager(), name, priority) {
     
    4040      new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 200);
    4141  ahrsData = new AhrsData((Imu *)this);
    42 
    43   ostringstream dev_name;
    44   dev_name << "simu_imu_" << dev_id;
    45   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     42 
     43  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    4644                        sizeof(imu_states_t));
    4745  SetIsReady(true);
    4846}
    4947
    50 SimuImu::SimuImu(const IODevice *parent, string name, uint32_t dev_id)
     48SimuImu::SimuImu(const IODevice *parent, string name, uint32_t modelId,uint32_t deviceId)
    5149    : Imu(parent,name), Thread(parent, name, 0) {
    5250  dataRate = NULL;
    5351
    54   ostringstream dev_name;
    55   dev_name << "simu_imu_" << dev_id;
    56   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     52  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    5753                        sizeof(imu_states_t));
    5854  SetIsReady(true);
     
    6258  SafeStop();
    6359  Join();
     60}
     61
     62string SimuImu::ShMemName(uint32_t modelId,uint32_t deviceId) {
     63  ostringstream dev_name;
     64  dev_name << "simu" <<  modelId << "_imu_" << deviceId;
     65  return dev_name.str().c_str();
    6466}
    6567
  • trunk/lib/FlairSensorActuator/src/SimuImu.h

    r137 r158  
    4242  *
    4343  * \param name name
    44   * \param dev_id device id
     44  * \param modelId Model id
     45  * \param deviceId Imu id of the Model
    4546  * \param priority priority of the Thread
    4647  */
    4748  SimuImu(std::string name,
    48           uint32_t dev_id, uint8_t priority);
     49          uint32_t modelId,uint32_t deviceId, uint8_t priority);
    4950
    5051  /*!
     
    5657  * \param parent parent
    5758  * \param name name
    58   * \param dev_id device id
     59  * \param modelId Model id
     60  * \param deviceId Imu id of the Model
    5961  */
    60   SimuImu(const core::IODevice *parent, std::string name, uint32_t dev_id);
     62  SimuImu(const core::IODevice *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    6163
    6264  /*!
     
    9395    float wz;
    9496  } imu_states_t;
     97 
     98  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    9599
    96100  gui::SpinBox *dataRate;
  • trunk/lib/FlairSensorActuator/src/SimuLaser.cpp

    r157 r158  
    3333
    3434SimuLaser::SimuLaser(string name,
    35                      uint32_t dev_id, uint8_t priority)
     35                     uint32_t modelId,uint32_t deviceId, uint8_t priority)
    3636    : Thread(getFrameworkManager(), name, priority), LaserRangeFinder(name) {
    3737  data_rate =
    3838      new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 50);
    3939
    40   ostringstream dev_name;
    41   dev_name << "simu_Laser_" << dev_id;
    42   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     40  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    4341                        360 * sizeof(float));
    4442  SetIsReady(true);
    4543}
    4644
    47 SimuLaser::SimuLaser(const IODevice *parent, string name, uint32_t dev_id)
     45SimuLaser::SimuLaser(const IODevice *parent, string name, uint32_t modelId,uint32_t deviceId)
    4846    : Thread(parent, name, 0), LaserRangeFinder(parent, name) {
    4947  data_rate = NULL;
    5048
    51   ostringstream dev_name;
    52   dev_name << "simu_Laser_" << dev_id;
    53   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(),
     49  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId),
    5450                        360 * sizeof(float));
    5551  SetIsReady(true);
     
    5955  SafeStop();
    6056  Join();
     57}
     58
     59string SimuLaser::ShMemName(uint32_t modelId,uint32_t deviceId) {
     60  ostringstream dev_name;
     61  dev_name << "simu" <<  modelId << "_laser_" << deviceId;
     62  return dev_name.str().c_str();
    6163}
    6264
  • trunk/lib/FlairSensorActuator/src/SimuLaser.h

    r137 r158  
    4141  *
    4242  * \param name name
    43   * \param dev_id device id
     43  * \param modelId Model id
     44  * \param deviceId LaserRangeFinder id of the Model
    4445  * \param priority priority of the Thread
    4546  */
    4647  SimuLaser(std::string name,
    47             uint32_t dev_id, uint8_t priority);
     48            uint32_t modelId,uint32_t deviceId, uint8_t priority);
    4849
    4950  /*!
     
    5556  * \param parent parent
    5657  * \param name name
    57   * \param dev_id device id
     58  * \param modelId Model id
     59  * \param deviceId LaserRangeFinder id of the Model
    5860  */
    59   SimuLaser(const core::IODevice *parent, std::string name, uint32_t dev_id);
     61  SimuLaser(const core::IODevice *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    6062
    6163  /*!
     
    8991  */
    9092  void Run(void);
    91 
     93 
     94  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    9295  gui::SpinBox *data_rate;
    9396};
  • trunk/lib/FlairSensorActuator/src/SimuUs.cpp

    r157 r158  
    3232namespace sensor {
    3333
    34 SimuUs::SimuUs(string name, uint32_t dev_id,
     34SimuUs::SimuUs(string name, uint32_t modelId,uint32_t deviceId,
    3535               uint8_t priority)
    3636    : Thread(getFrameworkManager(), name, priority), UsRangeFinder( name) {
     
    3838      new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 500, 1, 50);
    3939
    40   ostringstream dev_name;
    41   dev_name << "simu_us_" << dev_id;
    42   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), sizeof(float));
     40  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId), sizeof(float));
    4341
    4442  SetIsReady(true);
    4543}
    4644
    47 SimuUs::SimuUs(const IODevice *parent, string name, uint32_t dev_id)
     45SimuUs::SimuUs(const IODevice *parent, string name,uint32_t modelId,uint32_t deviceId)
    4846    : Thread(parent, name, 0), UsRangeFinder(parent,name) {
    4947  data_rate = NULL;
    5048
    51   ostringstream dev_name;
    52   dev_name << "simu_us_" << dev_id;
    53   shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), sizeof(float));
     49  shmem = new SharedMem((Thread *)this, ShMemName(modelId, deviceId), sizeof(float));
    5450 
    5551  SetIsReady(true);
     
    5955  SafeStop();
    6056  Join();
     57}
     58
     59string SimuUs::ShMemName(uint32_t modelId,uint32_t deviceId) {
     60  ostringstream dev_name;
     61  dev_name << "simu" <<  modelId << "_us_" << deviceId;
     62  return dev_name.str().c_str();
    6163}
    6264
  • trunk/lib/FlairSensorActuator/src/SimuUs.h

    r137 r158  
    4141  *
    4242  * \param name name
    43   * \param dev_id device id
     43  * \param modelId Model id
     44  * \param deviceId UsRangeFinder id of the Model
    4445  * \param priority priority of the Thread
    4546  */
    4647  SimuUs(std::string name,
    47          uint32_t dev_id, uint8_t priority);
     48         uint32_t modelId,uint32_t deviceId, uint8_t priority);
    4849
    4950  /*!
     
    5556  * \param parent parent
    5657  * \param name name
    57   * \param dev_id device id
     58  * \param modelId Model id
     59  * \param deviceId UsRangeFinder id of the Model
    5860  */
    59   SimuUs(const core::IODevice *parent, std::string name, uint32_t dev_id);
     61  SimuUs(const core::IODevice *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    6062
    6163  /*!
     
    8991  */
    9092  void Run(void);
    91 
     93 
     94  std::string ShMemName(uint32_t modelId,uint32_t deviceId);
    9295  gui::SpinBox *data_rate;
    9396};
  • trunk/lib/FlairSimulator/src/Castle.cpp

    r15 r158  
    1717
    1818#include "Castle.h"
    19 #include "Simulator.h"
    2019#include <IrrlichtDevice.h>
    2120#include <IFileSystem.h>
     
    2726namespace simulator {
    2827
    29 Castle::Castle(const Simulator *parent, int app_width, int app_height,
     28Castle::Castle(int app_width, int app_height,
    3029               int scene_width, int scene_height, std::string media_path)
    31     : Gui(parent, "Castle", app_width, app_height, scene_width, scene_height,
     30    : Gui("Castle", app_width, app_height, scene_width, scene_height,
    3231          media_path) {
    3332  // carte
  • trunk/lib/FlairSimulator/src/Castle.h

    r15 r158  
    2323class Castle : public Gui {
    2424public:
    25   Castle(const flair::simulator::Simulator *parent, int app_width,
     25  Castle(int app_width,
    2626         int app_height, int scene_width, int scene_height,
    2727         std::string media_path);
  • trunk/lib/FlairSimulator/src/GenericObject.cpp

    r134 r158  
    3737namespace simulator {
    3838
    39 GenericObject::GenericObject(Simulator *parent, IMesh *mesh)
     39GenericObject::GenericObject(IMesh *mesh)
    4040{
    4141        meshSceneNode=getGui()->getSceneManager()->addMeshSceneNode(mesh);
     
    4646  meshSceneNode->setMaterialFlag(EMF_LIGHTING, false);
    4747
    48   parent->pimpl_->objects.push_back(this);
     48  getSimulator()->pimpl_->objects.push_back(this);
    4949}
    5050
  • trunk/lib/FlairSimulator/src/Gui.cpp

    r69 r158  
    133133}
    134134
    135 Gui::Gui(const Simulator *parent, std::string name, int app_width,
     135Gui::Gui(std::string name, int app_width,
    136136         int app_height, int scene_width, int scene_height,
    137137         std::string media_path, E_DRIVER_TYPE driver_type)
    138     : Object(parent, name, "Gui") {
     138    : Object(getSimulator(), name, "Gui") {
    139139  if (gui_ != NULL)
    140140    Err("Gui should be instanced only one time\n");
  • trunk/lib/FlairSimulator/src/Gui.h

    r145 r158  
    4848namespace flair {
    4949namespace simulator {
    50 class Simulator;
    5150
    5251class Gui: public core::Object {
     
    5554
    5655public:
    57   Gui(const Simulator *parent, std::string name, int app_width, int app_height,
     56  Gui(std::string name, int app_width, int app_height,
    5857      int scene_width, int scene_height, std::string media_path,
    5958      irr::video::E_DRIVER_TYPE driver_type = irr::video::EDT_OPENGL);
  • trunk/lib/FlairSimulator/src/Man.cpp

    r157 r158  
    1818#include "Man.h"
    1919#include "Gui.h"
    20 #include "Simulator.h"
    21 #include "Simulator_impl.h"
    2220#include "Euler.h"
    2321#include <ISceneManager.h>
     
    3836namespace simulator {
    3937
    40 Man::Man(const Simulator *parent, std::string name) : Model(parent, name) {
     38Man::Man(std::string name,uint32_t modelId) : Model(name,modelId) {
    4139  node = getGui()->getSceneManager()->addAnimatedMeshSceneNode(
    4240      getGui()->getMesh("ninja.b3d"), getSceneNode(), -1, vector3df(0, 0, 0),
  • trunk/lib/FlairSimulator/src/Man.h

    r15 r158  
    3434namespace flair {
    3535namespace simulator {
    36 class Simulator;
    3736
    3837class Man : private Model {
    3938public:
    40   Man(const Simulator *parent, std::string name);
     39  Man(std::string name,uint32_t modelId);
    4140  ~Man();
    4241
  • trunk/lib/FlairSimulator/src/Model.cpp

    r70 r158  
    1818#include "Model_impl.h"
    1919#include "Simulator.h"
    20 #include "Simulator_impl.h"
    2120#include <DoubleSpinBox.h>
    2221
    2322#ifdef GL
    2423#include "FollowMeCamera.h"
    25 #include "Gui.h"
    2624#include <ICameraSceneNode.h>
    2725using namespace irr;
     
    3634namespace simulator {
    3735
    38 Model::Model(const Simulator *parent, std::string name)
    39     : IODevice(parent, name) {
    40 #ifdef GL
    41   pimpl_ =
    42       new Model_impl(this, name, getGui()->getSceneManager(), parent->pimpl_);
    43 #else
    44   pimpl_ = new Model_impl(this, name, parent->pimpl_);
    45 #endif
    46   parent->pimpl_->models.push_back(this);
     36Model::Model(std::string name,uint32_t modelId)
     37    : IODevice(getSimulator(), name) {
     38  pimpl_ = new Model_impl(this, name,modelId);
    4739}
    4840
     
    7971float Model::dT(void) const { return pimpl_->dT->Value(); }
    8072
     73int Model::GetId(void) const {
     74  return pimpl_->modelId;
     75}
     76
    8177} // end namespace simulator
    8278} // end namespace flair
  • trunk/lib/FlairSimulator/src/Model.h

    r69 r158  
    5151namespace flair {
    5252namespace simulator {
    53 class Simulator;
    5453class FollowMeCamera;
    5554
     
    6564
    6665public:
    67   Model(const Simulator *parent, std::string name);
     66  Model(std::string name,uint32_t modelId);
    6867  virtual ~Model();
    6968
     
    9392#endif
    9493  gui::TabWidget *GetTabWidget(void) const;
     94  int GetId(void) const;
    9595
    9696protected:
  • trunk/lib/FlairSimulator/src/Model_impl.cpp

    r151 r158  
    1818#include "Model_impl.h"
    1919#include "Simulator.h"
     20#include "Simulator_impl.h"
    2021#include "TabWidget.h"
    2122#include "Tab.h"
     
    5152
    5253#ifdef GL
    53 Model_impl::Model_impl(Model *self, std::string name,
    54                        ISceneManager *scenemanager, vrpn_Connection_IP *vrpn)
    55     : ISceneNode(scenemanager->getRootSceneNode(), scenemanager, -1),
    56       Thread(self, name, 50), vrpn_Tracker(name.c_str(), vrpn)
     54Model_impl::Model_impl(Model *self, std::string name,uint32_t modelId)
     55    : ISceneNode(getGui()->getSceneManager()->getRootSceneNode(), getGui()->getSceneManager(), -1),
     56      Thread(self, name, 50), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_)
    5757
    5858#else
    59 Model_impl::Model_impl(Model *self, std::string name, vrpn_Connection_IP *vrpn)
    60     : Thread(self, name, 50), vrpn_Tracker(name.c_str(), vrpn)
     59Model_impl::Model_impl(Model *self, std::string name,uint32_t modelId)
     60    : Thread(self, name, 50), vrpn_Tracker(name.c_str(), getSimulator()->pimpl_)
    6161#endif
    6262{
    6363  this->self = self;
     64  this->modelId=modelId;
    6465
    6566#ifdef GL
     
    131132
    132133  self->AddDataToLog(output);
     134 
     135  getSimulator()->pimpl_->models.push_back(self);
    133136}
    134137
  • trunk/lib/FlairSimulator/src/Parser.cpp

    r138 r158  
    4040namespace flair {
    4141namespace simulator {
    42 Parser::Parser(Simulator *parent, int app_width, int app_height,
     42Parser::Parser(int app_width, int app_height,
    4343               int scene_width, int scene_height, std::string media_path,
    4444               std::string xmlFile)
    45     : Gui(parent, "Parser", app_width, app_height, scene_width, scene_height,
     45    : Gui("Parser", app_width, app_height, scene_width, scene_height,
    4646          media_path) {
    4747  this->media_path = media_path;
    48   this->parent = parent;
    4948  xmlNode *root_element = NULL;
    5049  doc = xmlReadFile(xmlFile.c_str(), NULL, 0);
     
    121120      if (fp != NULL) {
    122121        GenericObject *object =
    123             new GenericObject(parent, getGui()->getMesh((char *)xmlGetProp(cur_node, (xmlChar *)"model")));
     122            new GenericObject(getGui()->getMesh((char *)xmlGetProp(cur_node, (xmlChar *)"model")));
    124123        object->setPosition(
    125124            getMeshVect(cur_node->children, (xmlChar *)"position"));
     
    140139          getScolor(cur_node->children));
    141140          //SColor(100, 255, 100, 100));
    142       GenericObject *object = new GenericObject(parent, mesh);
     141      GenericObject *object = new GenericObject(mesh);
    143142      object->setPosition(getMeshVect(cur_node->children, (xmlChar *)"position"));
    144143      object->setRotation(getMeshVect(cur_node->children, (xmlChar *)"rotation"));
     
    152151                    atof((char *)xmlGetProp(cur_node, (xmlChar *)"eight"))));
    153152                       
    154       GenericObject *object =
    155           new GenericObject(parent, mesh);
     153      GenericObject *object =new GenericObject(mesh);
    156154      object->setPosition(
    157155          getMeshVect(cur_node->children, (xmlChar *)"position"));
  • trunk/lib/FlairSimulator/src/Parser.h

    r138 r158  
    3939  */
    4040public:
    41   Parser(Simulator *parent, int app_width, int app_height, int scene_width,
     41  Parser(int app_width, int app_height, int scene_width,
    4242         int scene_height, std::string media_path, std::string xmlFile);
    4343  ~Parser();
     
    4646  xmlDoc *doc;
    4747  std::string media_path;
    48   Simulator *parent;
    4948  void processElements(xmlNode *a_node);
    5049  void processObjects(xmlNode *a_node);
  • trunk/lib/FlairSimulator/src/SimuCameraGL.cpp

    r151 r158  
    4545
    4646SimuCameraGL::SimuCameraGL(const Model *parent, std::string name, int width,
    47                            int height, int x, int y, int dev_id)
    48     : SimuCamera(parent, name, width, height, 3, dev_id), SensorGL(parent) {
     47                           int height, int x, int y, uint32_t modelId,uint32_t deviceId)
     48    : SimuCamera(parent, name, width, height, 3, modelId,deviceId), SensorGL(parent) {
    4949  smgr = getGui()->getSceneManager();
    5050  camera = smgr->addCameraSceneNode();
    5151  camera->addAnimator(this);
    52   camera->setAspectRatio(4.0f / 3.0f); // on force a cause du view port
     52  camera->setAspectRatio((float)width /(float)height); // on force a cause du view port
    5353
    5454  this->width = width;
  • trunk/lib/FlairSimulator/src/SimuCameraGL.h

    r151 r158  
    5151  // top left origin
    5252  SimuCameraGL(const simulator::Model *parent, std::string name, int width,
    53                int height, int x, int y, int dev_id);
     53               int height, int x, int y, uint32_t modelId,uint32_t deviceId);
    5454  ~SimuCameraGL();
    5555  //! Sets the value of the near clipping plane. (default: 1.0f)
  • trunk/lib/FlairSimulator/src/SimuLaserGL.cpp

    r15 r158  
    3838namespace flair {
    3939namespace sensor {
    40 SimuLaserGL::SimuLaserGL(const Model *parent, std::string name, int dev_id)
    41     : SimuLaser(parent, name, dev_id), SensorGL(parent) {
     40SimuLaserGL::SimuLaserGL(const Model *parent, std::string name, uint32_t modelId,uint32_t deviceId)
     41    : SimuLaser(parent, name, modelId,deviceId), SensorGL(parent) {
    4242  Tab *setup_tab = new Tab(parent->GetTabWidget(), name);
    4343  position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01);
  • trunk/lib/FlairSimulator/src/SimuLaserGL.h

    r15 r158  
    3838class SimuLaserGL : public SimuLaser, public SensorGL {
    3939public:
    40   SimuLaserGL(const simulator::Model *parent, std::string name, int dev_id);
     40  SimuLaserGL(const simulator::Model *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    4141  ~SimuLaserGL();
    4242
  • trunk/lib/FlairSimulator/src/SimuUsGL.cpp

    r15 r158  
    3838namespace flair {
    3939namespace sensor {
    40 SimuUsGL::SimuUsGL(const Model *parent, std::string name, int dev_id)
    41     : SimuUs(parent, name, dev_id), SensorGL(parent) {
     40SimuUsGL::SimuUsGL(const Model *parent, std::string name, uint32_t modelId,uint32_t deviceId)
     41    : SimuUs(parent, name, modelId,deviceId), SensorGL(parent) {
    4242  Tab *setup_tab = new Tab(parent->GetTabWidget(), name);
    4343  position = new Vector3DSpinBox(setup_tab->NewRow(), "position", -2, 2, .01);
  • trunk/lib/FlairSimulator/src/SimuUsGL.h

    r15 r158  
    3838class SimuUsGL : public SimuUs, public SensorGL {
    3939public:
    40   SimuUsGL(const simulator::Model *parent, std::string name, int dev_id);
     40  SimuUsGL(const simulator::Model *parent, std::string name, uint32_t modelId,uint32_t deviceId);
    4141  ~SimuUsGL();
    4242
  • trunk/lib/FlairSimulator/src/Simulator.h

    r15 r158  
    2222
    2323class Simulator_impl;
     24class Model_impl;
    2425
    2526namespace flair {
     
    3637
    3738class Simulator : public core::FrameworkManager {
    38   friend class Model;
     39  friend class ::Model_impl;
    3940  friend class Gui;
    4041  friend class GenericObject;
  • trunk/lib/FlairSimulator/src/X4.cpp

    r157 r158  
    1616
    1717#include "X4.h"
    18 #include "Simulator.h"
    1918#include <SimuBldc.h>
    2019#include <TabWidget.h>
     
    4645namespace simulator {
    4746
    48 X4::X4(const Simulator *parent, std::string name, int dev_id)
    49     : Model(parent, name) {
     47X4::X4(std::string name, uint32_t modelId)
     48    : Model(name,modelId) {
    5049  Tab *setup_tab = new Tab(GetTabWidget(), "model");
    5150  m = new DoubleSpinBox(setup_tab->NewRow(), "mass (kg):", 0, 20, 0.1);
     
    7574                            5); // moment d'inertie d'un axe (N.m.s²/rad)
    7675
    77   motors = new SimuBldc(this, name, 4, dev_id);
     76  motors = new SimuBldc(this, name, 4, modelId,0);
    7877 
    7978  SetIsReady(true);
     
    9695
    9796  // cylinders are aligned with y axis
    98   red_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 255, 0, 0));
    99   black_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 128, 128, 128));
    100   motor = geo->createCylinderMesh(7.5, 15, 16); //,SColor(0, 128, 128, 128));
     97  IMesh *red_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 255, 0, 0));
     98  IMesh *black_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 128, 128, 128));
     99  IMesh *motor = geo->createCylinderMesh(7.5, 15, 16); //,SColor(0, 128, 128, 128));
    101100  // geo->drop();
    102101
    103102  ITexture *texture = getGui()->getTexture("carbone.jpg");
    104   fl_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
     103  MeshSceneNode *fl_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
    105104                             vector3df(0, 0, -135));
    106   fr_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
     105  MeshSceneNode *fr_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
    107106                             vector3df(0, 0, -45));
    108   rl_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
     107  MeshSceneNode *rl_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
    109108                             vector3df(0, 0, 135), texture);
    110   rr_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
     109  MeshSceneNode *rr_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
    111110                             vector3df(0, 0, 45), texture);
    112111
    113112  texture = getGui()->getTexture("metal047.jpg");
    114   fl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, 2.5),
     113  MeshSceneNode *fl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, 2.5),
    115114                               vector3df(90, 0, 0), texture);
    116   fr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, 2.5),
     115  MeshSceneNode *fr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, 2.5),
    117116                               vector3df(90, 0, 0), texture);
    118   rl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, 2.5),
     117  MeshSceneNode *rl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, 2.5),
    119118                               vector3df(90, 0, 0), texture);
    120   rr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, 2.5),
     119  MeshSceneNode *rr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, 2.5),
    121120                               vector3df(90, 0, 0), texture);
    122121
  • trunk/lib/FlairSimulator/src/X4.h

    r157 r158  
    3232}
    3333
    34 #ifdef GL
    35 namespace irr {
    36 namespace scene {
    37 class IMesh;
    38 }
    39 }
    40 #endif
    41 
    4234namespace flair {
    4335namespace simulator {
    44 class Simulator;
    4536class Blade;
    46 class MeshSceneNode;
    4737
    4838class X4 : public Model {
    4939public:
    50   X4(const Simulator *parent, std::string name, int dev_id);
     40  X4(std::string name, uint32_t modelId);
    5141  ~X4();
    5242#ifdef GL
     
    5545
    5646protected:
    57   irr::scene::IMesh *red_arm, *black_arm, *motor;
    58   MeshSceneNode *fl_arm, *fr_arm, *rl_arm, *rr_arm;
    59   MeshSceneNode *fl_motor, *fr_motor, *rl_motor, *rr_motor;
    6047  Blade *fl_blade, *fr_blade, *rl_blade, *rr_blade;
    6148  core::Mutex *motor_speed_mutex;
  • trunk/lib/FlairSimulator/src/X8.cpp

    r157 r158  
    1616
    1717#include "X8.h"
    18 #include "Simulator.h"
    1918#include <SimuBldc.h>
    2019#include <TabWidget.h>
     
    4645namespace simulator {
    4746
    48 X8::X8(const Simulator *parent, std::string name, int dev_id)
    49     : Model(parent, name) {
     47X8::X8(std::string name, uint32_t modelId): Model( name,modelId) {
    5048  Tab *setup_tab = new Tab(GetTabWidget(), "model");
    5149  m = new DoubleSpinBox(setup_tab->NewRow(), "mass (kg):", 0, 20, 0.1);
     
    8482      0.1); // coefficient de forme des helices 1<S=1+Ss/Sprop<2 (sans unite)
    8583
    86   motors = new SimuBldc(this, name, 8, dev_id);
     84  motors = new SimuBldc(this, name, 8, modelId,0);
    8785 
    8886  SetIsReady(true);
     
    10199
    102100  // cylinders are aligned with y axis
    103   red_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 255, 0, 0));
    104   black_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 128, 128, 128));
    105   motor = geo->createCylinderMesh(7.5, 15, 16); //,SColor(0, 128, 128, 128));
     101  IMesh *red_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 255, 0, 0));
     102  IMesh *black_arm = geo->createCylinderMesh(2.5, 100, 16, SColor(0, 128, 128, 128));
     103  IMesh *motor = geo->createCylinderMesh(7.5, 15, 16); //,SColor(0, 128, 128, 128));
    106104  // geo->drop();
    107105
    108106  ITexture *texture = getGui()->getTexture("carbone.jpg");
    109   fl_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
     107  MeshSceneNode *fl_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
    110108                             vector3df(0, 0, -135));
    111   fr_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
     109  MeshSceneNode *fr_arm = new MeshSceneNode(this, red_arm, vector3df(0, 0, 0),
    112110                             vector3df(0, 0, -45));
    113   rl_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
     111  MeshSceneNode *rl_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
    114112                             vector3df(0, 0, 135), texture);
    115   rr_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
     113  MeshSceneNode *rr_arm = new MeshSceneNode(this, black_arm, vector3df(0, 0, 0),
    116114                             vector3df(0, 0, 45), texture);
    117115
    118116  texture = getGui()->getTexture("metal047.jpg");
    119   tfl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, 2.5),
    120                                 vector3df(90, 0, 0), texture);
    121   tfr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, 2.5),
    122                                 vector3df(90, 0, 0), texture);
    123   trl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, 2.5),
    124                                 vector3df(90, 0, 0), texture);
    125   trr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, 2.5),
    126                                 vector3df(90, 0, 0), texture);
    127 
    128   bfl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, -17.5),
    129                                 vector3df(90, 0, 0), texture);
    130   bfr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, -17.5),
    131                                 vector3df(90, 0, 0), texture);
    132   brl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, -17.5),
    133                                 vector3df(90, 0, 0), texture);
    134   brr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, -17.5),
     117  MeshSceneNode *tfl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, 2.5),
     118                                vector3df(90, 0, 0), texture);
     119  MeshSceneNode *tfr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, 2.5),
     120                                vector3df(90, 0, 0), texture);
     121  MeshSceneNode *trl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, 2.5),
     122                                vector3df(90, 0, 0), texture);
     123  MeshSceneNode *trr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, 2.5),
     124                                vector3df(90, 0, 0), texture);
     125
     126  MeshSceneNode *bfl_motor = new MeshSceneNode(this, motor, vector3df(70.71, -70.71, -17.5),
     127                                vector3df(90, 0, 0), texture);
     128  MeshSceneNode *bfr_motor = new MeshSceneNode(this, motor, vector3df(70.71, 70.71, -17.5),
     129                                vector3df(90, 0, 0), texture);
     130  MeshSceneNode *brl_motor = new MeshSceneNode(this, motor, vector3df(-70.71, -70.71, -17.5),
     131                                vector3df(90, 0, 0), texture);
     132  MeshSceneNode *brr_motor = new MeshSceneNode(this, motor, vector3df(-70.71, 70.71, -17.5),
    135133                                vector3df(90, 0, 0), texture);
    136134
  • trunk/lib/FlairSimulator/src/X8.h

    r157 r158  
    3232}
    3333
    34 #ifdef GL
    35 namespace irr {
    36 namespace scene {
    37 class IMesh;
    38 }
    39 }
    40 #endif
    41 
    4234namespace flair {
    4335namespace simulator {
    44 class Simulator;
    4536class Blade;
    46 class MeshSceneNode;
    4737
    4838class X8 : public Model {
    4939public:
    50   X8(const Simulator *parent, std::string name, int dev_id);
     40  X8(std::string name, uint32_t modelId);
    5141  ~X8();
    5242  virtual void Draw(void);
     
    5545protected:
    5646#ifdef GL
    57   irr::scene::IMesh *red_arm, *black_arm, *motor;
    58   MeshSceneNode *fl_arm, *fr_arm, *rl_arm, *rr_arm;
    59   MeshSceneNode *tfl_motor, *tfr_motor, *trl_motor, *trr_motor;
    60   MeshSceneNode *bfl_motor, *bfr_motor, *brl_motor, *brr_motor;
    6147  Blade *tfl_blade, *tfr_blade, *trl_blade, *trr_blade;
    6248  Blade *bfl_blade, *bfr_blade, *brl_blade, *brr_blade;
  • trunk/lib/FlairSimulator/src/unexported/GenericObject.h

    r134 r158  
    3434namespace flair {
    3535namespace simulator {
    36 class Simulator;
    3736
    3837class GenericObject {
     
    4039
    4140public:
    42   GenericObject(Simulator *parent,irr::scene::IMesh *mesh);
     41  GenericObject(irr::scene::IMesh *mesh);
    4342  virtual ~GenericObject();
    4443
  • trunk/lib/FlairSimulator/src/unexported/Model_impl.h

    r69 r158  
    6666                   {
    6767public:
    68 #ifdef GL
    69   Model_impl(flair::simulator::Model *self, std::string name,
    70              irr::scene::ISceneManager *scenemanager, vrpn_Connection_IP *vrpn);
    71 #else
    72   Model_impl(flair::simulator::Model *self, std::string name,
    73              vrpn_Connection_IP *vrpn);
    74 #endif
     68  Model_impl(flair::simulator::Model *self, std::string name,uint32_t modelId);
    7569  ~Model_impl();
    7670
     
    10094  flair::gui::TabWidget *tabwidget;
    10195  flair::gui::DoubleSpinBox *dT;
     96  int modelId;
    10297
    10398private:
  • trunk/lib/FlairSimulator/src/unexported/Simulator_impl.h

    r15 r158  
    2929}
    3030
     31class Model_impl;
     32
    3133class Simulator_impl : public vrpn_Connection_IP, private flair::core::Thread {
    32   friend class flair::simulator::Model;
     34  friend class ::Model_impl;
    3335  friend class flair::simulator::GenericObject;
    3436
Note: See TracChangeset for help on using the changeset viewer.