Changeset 15 in flair-src for trunk/lib/FlairSensorActuator/src/Imu.cpp


Ignore:
Timestamp:
04/08/16 15:40:57 (8 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairSensorActuator/src/Imu.cpp

    r3 r15  
    3030using namespace flair::gui;
    3131
    32 namespace flair { namespace sensor {
     32namespace flair {
     33namespace sensor {
    3334
    34 Imu::Imu(const FrameworkManager* parent,string name) : IODevice(parent,name) {
    35     imuData=new ImuData(this);
     35Imu::Imu(const FrameworkManager *parent, string name) : IODevice(parent, name) {
     36  imuData = new ImuData(this);
    3637
    37     //station sol
    38     mainTab=new Tab(parent->GetTabWidget(),name);
    39     tab=new TabWidget(mainTab->NewRow(),name);
    40     sensorTab=new Tab(tab,"Reglages");
    41         setupGroupbox=new GroupBox(sensorTab->NewRow(),name);
    42         rotation=new OneAxisRotation(sensorTab->NewRow(),"post rotation");
     38  // station sol
     39  mainTab = new Tab(parent->GetTabWidget(), name);
     40  tab = new TabWidget(mainTab->NewRow(), name);
     41  sensorTab = new Tab(tab, "Reglages");
     42  setupGroupbox = new GroupBox(sensorTab->NewRow(), name);
     43  rotation = new OneAxisRotation(sensorTab->NewRow(), "post rotation");
    4344}
    4445
    45 Imu::Imu(const IODevice* parent,std::string name) : IODevice(parent,name) {
    46     imuData=new ImuData(this);
    47     mainTab=NULL;
    48     tab=NULL;
    49     sensorTab=NULL;
    50         setupGroupbox=NULL;
    51         rotation=NULL;
     46Imu::Imu(const IODevice *parent, std::string name) : IODevice(parent, name) {
     47  imuData = new ImuData(this);
     48  mainTab = NULL;
     49  tab = NULL;
     50  sensorTab = NULL;
     51  setupGroupbox = NULL;
     52  rotation = NULL;
    5253}
    5354
    5455Imu::~Imu() {
    55     if(mainTab!=NULL) delete mainTab;
     56  if (mainTab != NULL)
     57    delete mainTab;
    5658}
    5759
    58 void Imu::GetDatas(ImuData **outImuData) const {
    59     *outImuData=imuData;
    60 }
     60void Imu::GetDatas(ImuData **outImuData) const { *outImuData = imuData; }
    6161void Imu::UpdateImu() {
    62     if(rotation==NULL) {
    63         Err("not applicable for simulation part.\n");
    64         return;
    65     }
    66     Vector3D rawAcc,rawMag,rawGyr;
    67     imuData->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr);
    68     rotation->ComputeRotation(rawAcc);
    69     rotation->ComputeRotation(rawGyr);
    70     rotation->ComputeRotation(rawMag);
    71     imuData->SetRawAccMagAndGyr(rawAcc,rawMag,rawGyr);
     62  if (rotation == NULL) {
     63    Err("not applicable for simulation part.\n");
     64    return;
     65  }
     66  Vector3D rawAcc, rawMag, rawGyr;
     67  imuData->GetRawAccMagAndGyr(rawAcc, rawMag, rawGyr);
     68  rotation->ComputeRotation(rawAcc);
     69  rotation->ComputeRotation(rawGyr);
     70  rotation->ComputeRotation(rawMag);
     71  imuData->SetRawAccMagAndGyr(rawAcc, rawMag, rawGyr);
    7272}
    7373
    74 GroupBox* Imu::GetGroupBox(void) const {
    75     return setupGroupbox;
    76 }
     74GroupBox *Imu::GetGroupBox(void) const { return setupGroupbox; }
    7775
    78 Layout* Imu::GetLayout(void) const {
    79     return sensorTab;
    80 }
     76Layout *Imu::GetLayout(void) const { return sensorTab; }
    8177
    8278void Imu::LockUserInterface(void) const {
    83     if(sensorTab==NULL) {
    84         Err("not applicable for simulation part.\n");
    85         return;
    86     }
    87     sensorTab->setEnabled(false);
     79  if (sensorTab == NULL) {
     80    Err("not applicable for simulation part.\n");
     81    return;
     82  }
     83  sensorTab->setEnabled(false);
    8884}
    8985
    9086void Imu::UnlockUserInterface(void) const {
    91     if(sensorTab==NULL) {
    92         Err("not applicable for simulation part.\n");
    93         return;
    94     }
    95     sensorTab->setEnabled(true);
     87  if (sensorTab == NULL) {
     88    Err("not applicable for simulation part.\n");
     89    return;
     90  }
     91  sensorTab->setEnabled(true);
    9692}
    9793
    9894void Imu::UseDefaultPlot(void) {
    99     if(tab==NULL) {
    100         Err("not applicable for simulation part.\n");
    101         return;
    102     }
     95  if (tab == NULL) {
     96    Err("not applicable for simulation part.\n");
     97    return;
     98  }
    10399
    104     plotTab=new Tab(tab,"IMU");
    105     axPlot=new DataPlot1D(plotTab->NewRow(),"acc_x",-10,10);
    106     axPlot->AddCurve(imuData->Element(ImuData::RawAx));
    107     ayPlot=new DataPlot1D(plotTab->LastRowLastCol(),"acc_y",-10,10);
    108     ayPlot->AddCurve(imuData->Element(ImuData::RawAy));
    109     azPlot=new DataPlot1D(plotTab->LastRowLastCol(),"acc_z",-10,10);
    110     azPlot->AddCurve(imuData->Element(ImuData::RawAz));
     100  plotTab = new Tab(tab, "IMU");
     101  axPlot = new DataPlot1D(plotTab->NewRow(), "acc_x", -10, 10);
     102  axPlot->AddCurve(imuData->Element(ImuData::RawAx));
     103  ayPlot = new DataPlot1D(plotTab->LastRowLastCol(), "acc_y", -10, 10);
     104  ayPlot->AddCurve(imuData->Element(ImuData::RawAy));
     105  azPlot = new DataPlot1D(plotTab->LastRowLastCol(), "acc_z", -10, 10);
     106  azPlot->AddCurve(imuData->Element(ImuData::RawAz));
    111107
    112     if(plotTab==NULL) plotTab=new Tab(tab,"IMU");
    113     gxPlot=new DataPlot1D(plotTab->NewRow(),"gyr_x",-500,500);
    114     gxPlot->AddCurve(imuData->Element(ImuData::RawGxDeg));
    115     gyPlot=new DataPlot1D(plotTab->LastRowLastCol(),"gyr_y",-500,500);
    116     gyPlot->AddCurve(imuData->Element(ImuData::RawGyDeg));
    117     gzPlot=new DataPlot1D(plotTab->LastRowLastCol(),"gyr_z",-500,500);
    118     gzPlot->AddCurve(imuData->Element(ImuData::RawGzDeg));
     108  if (plotTab == NULL)
     109    plotTab = new Tab(tab, "IMU");
     110  gxPlot = new DataPlot1D(plotTab->NewRow(), "gyr_x", -500, 500);
     111  gxPlot->AddCurve(imuData->Element(ImuData::RawGxDeg));
     112  gyPlot = new DataPlot1D(plotTab->LastRowLastCol(), "gyr_y", -500, 500);
     113  gyPlot->AddCurve(imuData->Element(ImuData::RawGyDeg));
     114  gzPlot = new DataPlot1D(plotTab->LastRowLastCol(), "gyr_z", -500, 500);
     115  gzPlot->AddCurve(imuData->Element(ImuData::RawGzDeg));
    119116
    120     if(plotTab==NULL)  plotTab=new Tab(tab,"IMU");
    121     mxPlot=new DataPlot1D(plotTab->NewRow(),"mag_x",-500,500);
    122     mxPlot->AddCurve(imuData->Element(ImuData::RawMx));
    123     myPlot=new DataPlot1D(plotTab->LastRowLastCol(),"mag_y",-500,500);
    124     myPlot->AddCurve(imuData->Element(ImuData::RawMy));
    125     mzPlot=new DataPlot1D(plotTab->LastRowLastCol(),"mag_z",-500,500);
    126     mzPlot->AddCurve(imuData->Element(ImuData::RawMz));
     117  if (plotTab == NULL)
     118    plotTab = new Tab(tab, "IMU");
     119  mxPlot = new DataPlot1D(plotTab->NewRow(), "mag_x", -500, 500);
     120  mxPlot->AddCurve(imuData->Element(ImuData::RawMx));
     121  myPlot = new DataPlot1D(plotTab->LastRowLastCol(), "mag_y", -500, 500);
     122  myPlot->AddCurve(imuData->Element(ImuData::RawMy));
     123  mzPlot = new DataPlot1D(plotTab->LastRowLastCol(), "mag_z", -500, 500);
     124  mzPlot->AddCurve(imuData->Element(ImuData::RawMz));
    127125}
    128126
    129 Tab* Imu::GetPlotTab(void) const {
    130     return plotTab;
    131 }
     127Tab *Imu::GetPlotTab(void) const { return plotTab; }
    132128
    133129} // end namespace sensor
Note: See TracChangeset for help on using the changeset viewer.