Changeset 15 in flair-src for trunk/lib/FlairSensorActuator/src/Imu.cpp
- Timestamp:
- Apr 8, 2016, 3:40:57 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/Imu.cpp
r3 r15 30 30 using namespace flair::gui; 31 31 32 namespace flair { namespace sensor { 32 namespace flair { 33 namespace sensor { 33 34 34 Imu::Imu(const FrameworkManager * parent,string name) : IODevice(parent,name) {35 imuData=new ImuData(this);35 Imu::Imu(const FrameworkManager *parent, string name) : IODevice(parent, name) { 36 imuData = new ImuData(this); 36 37 37 //station sol38 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"); 43 44 } 44 45 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;46 Imu::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; 52 53 } 53 54 54 55 Imu::~Imu() { 55 if(mainTab!=NULL) delete mainTab; 56 if (mainTab != NULL) 57 delete mainTab; 56 58 } 57 59 58 void Imu::GetDatas(ImuData **outImuData) const { 59 *outImuData=imuData; 60 } 60 void Imu::GetDatas(ImuData **outImuData) const { *outImuData = imuData; } 61 61 void Imu::UpdateImu() { 62 if(rotation==NULL) {63 64 65 66 Vector3D rawAcc,rawMag,rawGyr;67 imuData->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr);68 69 70 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); 72 72 } 73 73 74 GroupBox* Imu::GetGroupBox(void) const { 75 return setupGroupbox; 76 } 74 GroupBox *Imu::GetGroupBox(void) const { return setupGroupbox; } 77 75 78 Layout* Imu::GetLayout(void) const { 79 return sensorTab; 80 } 76 Layout *Imu::GetLayout(void) const { return sensorTab; } 81 77 82 78 void Imu::LockUserInterface(void) const { 83 if(sensorTab==NULL) {84 85 86 87 79 if (sensorTab == NULL) { 80 Err("not applicable for simulation part.\n"); 81 return; 82 } 83 sensorTab->setEnabled(false); 88 84 } 89 85 90 86 void Imu::UnlockUserInterface(void) const { 91 if(sensorTab==NULL) {92 93 94 95 87 if (sensorTab == NULL) { 88 Err("not applicable for simulation part.\n"); 89 return; 90 } 91 sensorTab->setEnabled(true); 96 92 } 97 93 98 94 void Imu::UseDefaultPlot(void) { 99 if(tab==NULL) {100 101 102 95 if (tab == NULL) { 96 Err("not applicable for simulation part.\n"); 97 return; 98 } 103 99 104 plotTab=new Tab(tab,"IMU");105 axPlot=new DataPlot1D(plotTab->NewRow(),"acc_x",-10,10);106 107 ayPlot=new DataPlot1D(plotTab->LastRowLastCol(),"acc_y",-10,10);108 109 azPlot=new DataPlot1D(plotTab->LastRowLastCol(),"acc_z",-10,10);110 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)); 111 107 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)); 119 116 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)); 127 125 } 128 126 129 Tab* Imu::GetPlotTab(void) const { 130 return plotTab; 131 } 127 Tab *Imu::GetPlotTab(void) const { return plotTab; } 132 128 133 129 } // end namespace sensor
Note:
See TracChangeset
for help on using the changeset viewer.