Changeset 160 in flair-src for trunk/lib


Ignore:
Timestamp:
Mar 5, 2017, 12:21:41 PM (8 years ago)
Author:
Sanahuja Guillaume
Message:

cam

Location:
trunk/lib/FlairMeta/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairMeta/src/SimuX4.cpp

    r158 r160  
    5353  GetBatteryMonitor()->SetBatteryValue(12);
    5454 
    55   string camvOpts=FindArgument(options,"camv=",false);
    5655  uint16_t camvWidth=320,camvHeight=240;
    57         if(camvOpts=="") {
    58     Info("using default vertical camera resolution: %ix%i\n",camvWidth, camvHeight);
    59         }
     56        ReadCameraResolutionOption(options,"camv",camvWidth,camvHeight);
     57  Info("using vertical camera resolution: %ix%i\n",camvWidth, camvHeight);
     58  SetVerticalCamera(new SimuCamera("simu_cam_v", camvWidth, camvHeight, 3, simu_id,0, 10));
    6059 
    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));
     60  uint16_t camhWidth=320,camhHeight=240;
     61  ReadCameraResolutionOption(options,"camh",camhWidth,camhHeight);
     62  Info("using horizontal camera resolution: %ix%i\n",camhWidth, camhHeight);
     63  SetHorizontalCamera(new SimuCamera("simu_cam_h", camhWidth, camhHeight, 3, simu_id,1, 10));
    6364}
    6465
     
    6970  ((SimuUs *)GetUsRangeFinder())->Start();
    7071  ((SimuCamera *)GetVerticalCamera())->Start();
     72  ((SimuCamera *)GetHorizontalCamera())->Start();
    7173}
    7274
     75void SimuX4::ReadCameraResolutionOption(string options,string cameraName,uint16_t &camWidth,uint16_t &camHeight) const {
     76  string camOpts=FindArgument(options,cameraName +"=",false);
     77        if(camOpts!="") {
     78    size_t position=camOpts.find("x");
     79    if(position!=std::string::npos) {
     80        camWidth=std::stoi(camOpts.substr(0,position));
     81        camHeight=std::stoi(camOpts.substr(position+1,std::string::npos));
     82    } else {
     83      Warn("bad camera resolution parameter (%s) should be WIDTHxHEIGHT format\n",camOpts.c_str());
     84    }
     85  }
     86}
    7387
    7488} // end namespace meta
  • trunk/lib/FlairMeta/src/SimuX4.h

    r158 r160  
    1818namespace flair {
    1919namespace meta {
     20 
    2021/*! \class SimuX4
    2122*
     
    2324*/
    2425class SimuX4 : public Uav {
    25 public:
    26   // simu_id: 0 if simulating only one UAV
    27   //>0 otherwise
    28   SimuX4(std::string name, uint32_t simu_id = 0,std::string options="",
    29          filter::UavMultiplex *multiplex = NULL);
    30   ~SimuX4();
    31   void StartSensors(void);
     26  public:
     27    // simu_id: 0 if simulating only one UAV
     28    //>0 otherwise
     29    SimuX4(std::string name, uint32_t simu_id = 0,std::string options="",
     30           filter::UavMultiplex *multiplex = NULL);
     31    ~SimuX4();
     32    void StartSensors(void);
     33
     34  private:
     35    void ReadCameraResolutionOption(std::string options,std::string cameraName,uint16_t &camWidth,uint16_t &camHeight) const;
     36 
    3237};
    3338} // end namespace meta
  • trunk/lib/FlairMeta/src/SimuX8.cpp

    r158 r160  
    2626#include <BatteryMonitor.h>
    2727#include <Tab.h>
     28#include <FindArgument.h>
    2829
    2930using std::string;
     
    5152  SetBatteryMonitor(new BatteryMonitor(bat_tab->NewRow(), "battery"));
    5253  GetBatteryMonitor()->SetBatteryValue(12);
    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));
     54 
     55  uint16_t camvWidth=320,camvHeight=240;
     56        ReadCameraResolutionOption(options,"camv",camvWidth,camvHeight);
     57  Info("using vertical camera resolution: %ix%i\n",camvWidth, camvHeight);
     58  SetVerticalCamera(new SimuCamera("simu_cam_v", camvWidth, camvHeight, 3, simu_id,0, 10));
     59 
     60  uint16_t camhWidth=320,camhHeight=240;
     61  ReadCameraResolutionOption(options,"camh",camhWidth,camhHeight);
     62  Info("using horizontal camera resolution: %ix%i\n",camhWidth, camhHeight);
     63  SetHorizontalCamera(new SimuCamera("simu_cam_h", camhWidth, camhHeight, 3, simu_id,1, 10));
    5564}
    5665
     
    6170  ((SimuUs *)GetUsRangeFinder())->Start();
    6271  ((SimuCamera *)GetVerticalCamera())->Start();
     72  ((SimuCamera *)GetHorizontalCamera())->Start();
     73}
     74
     75void SimuX8::ReadCameraResolutionOption(string options,string cameraName,uint16_t &camWidth,uint16_t &camHeight) const {
     76  string camOpts=FindArgument(options,cameraName +"=",false);
     77        if(camOpts!="") {
     78    size_t position=camOpts.find("x");
     79    if(position!=std::string::npos) {
     80        camWidth=std::stoi(camOpts.substr(0,position));
     81        camHeight=std::stoi(camOpts.substr(position+1,std::string::npos));
     82    } else {
     83      Warn("bad camera resolution parameter (%s) should be WIDTHxHEIGHT format\n",camOpts.c_str());
     84    }
     85  }
    6386}
    6487
  • trunk/lib/FlairMeta/src/SimuX8.h

    r158 r160  
    2323*/
    2424class SimuX8 : public Uav {
    25 public:
    26   // simu_id: 0 if simulating only one UAV
    27   //>0 otherwise
    28   SimuX8(std::string name, uint32_t simu_id = 0,std::string options="",
    29          filter::UavMultiplex *multiplex = NULL);
    30   ~SimuX8();
    31   void StartSensors(void);
     25  public:
     26    // simu_id: 0 if simulating only one UAV
     27    //>0 otherwise
     28    SimuX8(std::string name, uint32_t simu_id = 0,std::string options="",
     29           filter::UavMultiplex *multiplex = NULL);
     30    ~SimuX8();
     31    void StartSensors(void);
     32 
     33  private:
     34    void ReadCameraResolutionOption(std::string options,std::string cameraName,uint16_t &camWidth,uint16_t &camHeight) const;
     35 
    3236};
    3337} // end namespace meta
Note: See TracChangeset for help on using the changeset viewer.