Changeset 15 in flair-src for trunk/lib/FlairMeta/src/Uav.cpp


Ignore:
Timestamp:
Apr 8, 2016, 3:40:57 PM (6 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

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

    r10 r15  
    3838using namespace flair::actuator;
    3939
    40 namespace flair { namespace meta {
     40namespace flair {
     41namespace meta {
    4142
    42 Uav::Uav(FrameworkManager* parent,string name,UavMultiplex *multiplex): Object(parent,name) {
    43     vrpnclient=NULL;
    44     uav_vrpn=NULL;
    45     verticalCamera=NULL;
    46     this->multiplex=multiplex;
     43Uav::Uav(FrameworkManager *parent, string name, UavMultiplex *multiplex)
     44    : Object(parent, name) {
     45  vrpnclient = NULL;
     46  uav_vrpn = NULL;
     47  verticalCamera = NULL;
     48  this->multiplex = multiplex;
    4749}
    4850
    49 Uav::~Uav() {
    50 }
     51Uav::~Uav() {}
    5152
    5253void Uav::SetUsRangeFinder(const UsRangeFinder *inUs) {
    53     us=(UsRangeFinder*)inUs;
    54     meta_us=new MetaUsRangeFinder(us);
    55     getFrameworkManager()->AddDeviceToLog(us);
     54  us = (UsRangeFinder *)inUs;
     55  meta_us = new MetaUsRangeFinder(us);
     56  getFrameworkManager()->AddDeviceToLog(us);
    5657}
    5758
    5859void Uav::SetAhrs(const Ahrs *inAhrs) {
    59     ahrs=(Ahrs*)inAhrs;
    60     imu=(Imu*)ahrs->GetImu();
    61     getFrameworkManager()->AddDeviceToLog(imu);
     60  ahrs = (Ahrs *)inAhrs;
     61  imu = (Imu *)ahrs->GetImu();
     62  getFrameworkManager()->AddDeviceToLog(imu);
    6263}
    6364
    64 void Uav::SetBldc(const Bldc* inBldc) {
    65     bldc=(Bldc*)inBldc;
    66 }
     65void Uav::SetBldc(const Bldc *inBldc) { bldc = (Bldc *)inBldc; }
    6766
    68 void Uav::SetBatteryMonitor(const BatteryMonitor* inBattery) {
    69     battery=(BatteryMonitor*)inBattery;
     67void Uav::SetBatteryMonitor(const BatteryMonitor *inBattery) {
     68  battery = (BatteryMonitor *)inBattery;
    7069}
    7170
    7271void Uav::SetMultiplex(const UavMultiplex *inMultiplex) {
    73     multiplex=(UavMultiplex*)inMultiplex;
    74     getFrameworkManager()->AddDeviceToLog(multiplex);
     72  multiplex = (UavMultiplex *)inMultiplex;
     73  getFrameworkManager()->AddDeviceToLog(multiplex);
    7574}
    7675
    77 void Uav::SetVerticalCamera(const Camera* inVerticalCamera) {
    78     verticalCamera=(Camera*)inVerticalCamera;
     76void Uav::SetVerticalCamera(const Camera *inVerticalCamera) {
     77  verticalCamera = (Camera *)inVerticalCamera;
    7978}
    8079/*
    81 void Uav::SetupVRPNSerial(SerialPort *vrpn_port,string name,int VRPNSerialObjectId) {
     80void Uav::SetupVRPNSerial(SerialPort *vrpn_port,string name,int
     81VRPNSerialObjectId) {
    8282    vrpnclient=new VrpnClient(getFrameworkManager(),"vrpn",vrpn_port,10000,80);
    8383    uav_vrpn=new MetaVrpnObject(vrpnclient,name,VRPNSerialObjectId);
     
    8787*/
    8888void Uav::SetupVRPNAutoIP(string name) {
    89     SetupVRPN("192.168.147.197:3883",name);
     89  SetupVRPN("192.168.147.197:3883", name);
    9090}
    9191
    92 void Uav::SetupVRPN(string optitrack_address,string name) {
    93     vrpnclient=new VrpnClient(getFrameworkManager(),"vrpn",optitrack_address,10000,80);
    94     uav_vrpn=new MetaVrpnObject(vrpnclient,name);
     92void Uav::SetupVRPN(string optitrack_address, string name) {
     93  vrpnclient = new VrpnClient(getFrameworkManager(), "vrpn", optitrack_address,
     94                              10000, 80);
     95  uav_vrpn = new MetaVrpnObject(vrpnclient, name);
    9596
    96     getFrameworkManager()->AddDeviceToLog(uav_vrpn);
     97  getFrameworkManager()->AddDeviceToLog(uav_vrpn);
    9798
    98     GetAhrs()->YawPlot()->AddCurve(uav_vrpn->State()->Element(2),DataPlot::Green);
    99     //GetAhrs()->RollPlot()->AddCurve(uav_vrpn->State()->Element(0),DataPlot::Green);
    100     //GetAhrs()->PitchPlot()->AddCurve(uav_vrpn->State()->Element(1),DataPlot::Green);
     99  GetAhrs()->YawPlot()->AddCurve(uav_vrpn->State()->Element(2),
     100                                 DataPlot::Green);
     101  // GetAhrs()->RollPlot()->AddCurve(uav_vrpn->State()->Element(0),DataPlot::Green);
     102  // GetAhrs()->PitchPlot()->AddCurve(uav_vrpn->State()->Element(1),DataPlot::Green);
    101103}
    102104
    103 void Uav::StartSensors(void)  {
    104     if(vrpnclient!=NULL) {
    105         vrpnclient->Start();
    106     }
     105void Uav::StartSensors(void) {
     106  if (vrpnclient != NULL) {
     107    vrpnclient->Start();
     108  }
    107109}
    108110void Uav::UseDefaultPlot(void) {
    109     multiplex->UseDefaultPlot();
     111  multiplex->UseDefaultPlot();
    110112
    111     if(bldc->HasSpeedMeasurement()) {
    112         Tab* plot_tab=new Tab(multiplex->GetTabWidget(),"Speeds");
    113         DataPlot1D* plots[4];
    114         plots[0]=new DataPlot1D(plot_tab->NewRow(),"front left",0,7000);
    115         plots[1]=new DataPlot1D(plot_tab->LastRowLastCol(),"front right",0,7000);
    116         plots[2]=new DataPlot1D(plot_tab->NewRow(),"rear left",0,7000);
    117         plots[3]=new DataPlot1D(plot_tab->LastRowLastCol(),"rear right",0,7000);
     113  if (bldc->HasSpeedMeasurement()) {
     114    Tab *plot_tab = new Tab(multiplex->GetTabWidget(), "Speeds");
     115    DataPlot1D *plots[4];
     116    plots[0] = new DataPlot1D(plot_tab->NewRow(), "front left", 0, 7000);
     117    plots[1] =
     118        new DataPlot1D(plot_tab->LastRowLastCol(), "front right", 0, 7000);
     119    plots[2] = new DataPlot1D(plot_tab->NewRow(), "rear left", 0, 7000);
     120    plots[3] =
     121        new DataPlot1D(plot_tab->LastRowLastCol(), "rear right", 0, 7000);
    118122
    119         if(bldc->MotorsCount()==8) {
    120             for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i),0),DataPlot::Red,"top");
    121             for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i+4),0),DataPlot::Blue,"bottom");
    122         } else {
    123             for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i),0));
    124         }
     123    if (bldc->MotorsCount() == 8) {
     124      for (int i = 0; i < 4; i++)
     125        plots[i]->AddCurve(
     126            bldc->Output()->Element(multiplex->MultiplexValue(i), 0),
     127            DataPlot::Red, "top");
     128      for (int i = 0; i < 4; i++)
     129        plots[i]->AddCurve(
     130            bldc->Output()->Element(multiplex->MultiplexValue(i + 4), 0),
     131            DataPlot::Blue, "bottom");
     132    } else {
     133      for (int i = 0; i < 4; i++)
     134        plots[i]->AddCurve(
     135            bldc->Output()->Element(multiplex->MultiplexValue(i), 0));
    125136    }
     137  }
    126138
    127     if(bldc->HasCurrentMeasurement()) {
    128         Tab* plot_tab=new Tab(multiplex->GetTabWidget(),"Currents");
    129         DataPlot1D* plots[4];
    130         plots[0]=new DataPlot1D(plot_tab->NewRow(),"front left",0,10);
    131         plots[1]=new DataPlot1D(plot_tab->LastRowLastCol(),"front right",0,10);
    132         plots[2]=new DataPlot1D(plot_tab->NewRow(),"rear left",0,10);
    133         plots[3]=new DataPlot1D(plot_tab->LastRowLastCol(),"rear right",0,10);
     139  if (bldc->HasCurrentMeasurement()) {
     140    Tab *plot_tab = new Tab(multiplex->GetTabWidget(), "Currents");
     141    DataPlot1D *plots[4];
     142    plots[0] = new DataPlot1D(plot_tab->NewRow(), "front left", 0, 10);
     143    plots[1] = new DataPlot1D(plot_tab->LastRowLastCol(), "front right", 0, 10);
     144    plots[2] = new DataPlot1D(plot_tab->NewRow(), "rear left", 0, 10);
     145    plots[3] = new DataPlot1D(plot_tab->LastRowLastCol(), "rear right", 0, 10);
    134146
    135         if(bldc->MotorsCount()==8) {
    136             for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i),1),DataPlot::Red,"top");
    137             for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i+4),1),DataPlot::Blue,"bottom");
    138         } else {
    139             for(int i=0;i<4;i++) plots[i]->AddCurve(bldc->Output()->Element(multiplex->MultiplexValue(i),1));
    140         }
     147    if (bldc->MotorsCount() == 8) {
     148      for (int i = 0; i < 4; i++)
     149        plots[i]->AddCurve(
     150            bldc->Output()->Element(multiplex->MultiplexValue(i), 1),
     151            DataPlot::Red, "top");
     152      for (int i = 0; i < 4; i++)
     153        plots[i]->AddCurve(
     154            bldc->Output()->Element(multiplex->MultiplexValue(i + 4), 1),
     155            DataPlot::Blue, "bottom");
     156    } else {
     157      for (int i = 0; i < 4; i++)
     158        plots[i]->AddCurve(
     159            bldc->Output()->Element(multiplex->MultiplexValue(i), 1));
    141160    }
     161  }
    142162
    143     meta_us->UseDefaultPlot();
    144     ahrs->UseDefaultPlot();
     163  meta_us->UseDefaultPlot();
     164  ahrs->UseDefaultPlot();
    145165}
    146166
    147 UavMultiplex* Uav::GetUavMultiplex(void) const {
    148     return multiplex;
     167UavMultiplex *Uav::GetUavMultiplex(void) const { return multiplex; }
     168
     169Bldc *Uav::GetBldc(void) const { return bldc; }
     170
     171Ahrs *Uav::GetAhrs(void) const { return ahrs; }
     172
     173Imu *Uav::GetImu(void) const { return imu; }
     174
     175MetaUsRangeFinder *Uav::GetMetaUsRangeFinder(void) const { return meta_us; }
     176
     177UsRangeFinder *Uav::GetUsRangeFinder(void) const { return us; }
     178
     179BatteryMonitor *Uav::GetBatteryMonitor(void) const { return battery; }
     180
     181VrpnClient *Uav::GetVrpnClient(void) const {
     182  if (vrpnclient == NULL)
     183    Err("vrpn is not setup, call SetupVRPN before\n");
     184  return vrpnclient;
    149185}
    150186
    151 Bldc* Uav::GetBldc(void) const {
    152     return bldc;
    153 }
     187MetaVrpnObject *Uav::GetVrpnObject(void) const { return uav_vrpn; }
    154188
    155 Ahrs* Uav::GetAhrs(void) const {
    156     return ahrs;
    157 }
    158 
    159 Imu* Uav::GetImu(void) const {
    160     return imu;
    161 }
    162 
    163 MetaUsRangeFinder* Uav::GetMetaUsRangeFinder(void) const {
    164     return meta_us;
    165 }
    166 
    167 UsRangeFinder* Uav::GetUsRangeFinder(void) const {
    168     return us;
    169 }
    170 
    171 BatteryMonitor* Uav::GetBatteryMonitor(void) const {
    172     return battery;
    173 }
    174 
    175 VrpnClient* Uav::GetVrpnClient(void) const {
    176     if(vrpnclient==NULL) Err("vrpn is not setup, call SetupVRPN before\n");
    177     return vrpnclient;
    178 }
    179 
    180 MetaVrpnObject* Uav::GetVrpnObject(void) const {
    181     return uav_vrpn;
    182 }
    183 
    184 Camera* Uav::GetVerticalCamera(void) const {
    185     return verticalCamera;
    186 }
     189Camera *Uav::GetVerticalCamera(void) const { return verticalCamera; }
    187190
    188191} // end namespace meta
Note: See TracChangeset for help on using the changeset viewer.