[3] | 1 | // %flair:license{
|
---|
[15] | 2 | // This file is part of the Flair framework distributed under the
|
---|
| 3 | // CECILL-C License, Version 1.0.
|
---|
[3] | 4 | // %flair:license}
|
---|
| 5 | // created: 2014/01/16
|
---|
| 6 | // filename: Imu.cpp
|
---|
| 7 | //
|
---|
| 8 | // author: Guillaume Sanahuja
|
---|
| 9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
| 10 | //
|
---|
| 11 | // version: $Id: $
|
---|
| 12 | //
|
---|
| 13 | // purpose: Virtual class for Imu
|
---|
| 14 | //
|
---|
| 15 | //
|
---|
| 16 | /*********************************************************************/
|
---|
| 17 |
|
---|
| 18 | #include "Imu.h"
|
---|
| 19 | #include <FrameworkManager.h>
|
---|
| 20 | #include <Tab.h>
|
---|
| 21 | #include <TabWidget.h>
|
---|
| 22 | #include <GroupBox.h>
|
---|
| 23 | #include <GridLayout.h>
|
---|
| 24 | #include <DataPlot1D.h>
|
---|
| 25 | #include <ImuData.h>
|
---|
| 26 | #include <OneAxisRotation.h>
|
---|
| 27 |
|
---|
| 28 | using std::string;
|
---|
| 29 | using namespace flair::core;
|
---|
| 30 | using namespace flair::gui;
|
---|
| 31 |
|
---|
[15] | 32 | namespace flair {
|
---|
| 33 | namespace sensor {
|
---|
[3] | 34 |
|
---|
[137] | 35 | Imu::Imu(string name) : IODevice(getFrameworkManager(), name) {
|
---|
[15] | 36 | imuData = new ImuData(this);
|
---|
[3] | 37 |
|
---|
[15] | 38 | // station sol
|
---|
[137] | 39 | mainTab = new Tab(getFrameworkManager()->GetTabWidget(), name);
|
---|
[15] | 40 | tab = new TabWidget(mainTab->NewRow(), name);
|
---|
| 41 | sensorTab = new Tab(tab, "Reglages");
|
---|
| 42 | setupGroupbox = new GroupBox(sensorTab->NewRow(), name);
|
---|
[187] | 43 | rotation = new OneAxisRotation(sensorTab->NewRow(), "post rotation",OneAxisRotation::PostRotation);
|
---|
[186] | 44 | AddDataToLog(imuData);
|
---|
[3] | 45 | }
|
---|
| 46 |
|
---|
[137] | 47 | Imu::Imu(const IODevice *parent,std::string name) : IODevice(parent, name) {
|
---|
[15] | 48 | imuData = new ImuData(this);
|
---|
| 49 | mainTab = NULL;
|
---|
| 50 | tab = NULL;
|
---|
| 51 | sensorTab = NULL;
|
---|
| 52 | setupGroupbox = NULL;
|
---|
| 53 | rotation = NULL;
|
---|
[3] | 54 | }
|
---|
| 55 |
|
---|
| 56 | Imu::~Imu() {
|
---|
[15] | 57 | if (mainTab != NULL)
|
---|
| 58 | delete mainTab;
|
---|
[3] | 59 | }
|
---|
| 60 |
|
---|
[179] | 61 | const ImuData *Imu::GetDatas(void) const {
|
---|
| 62 | return imuData;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
[15] | 65 | void Imu::GetDatas(ImuData **outImuData) const { *outImuData = imuData; }
|
---|
[55] | 66 |
|
---|
[99] | 67 | OneAxisRotation *Imu::GetOneAxisRotation(void) const {
|
---|
| 68 | return rotation;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[173] | 71 | void Imu::ApplyRotation(Vector3Df& vector) {
|
---|
[15] | 72 | if (rotation == NULL) {
|
---|
| 73 | Err("not applicable for simulation part.\n");
|
---|
| 74 | return;
|
---|
| 75 | }
|
---|
[173] | 76 | rotation->ComputeRotation(vector);
|
---|
[3] | 77 | }
|
---|
| 78 |
|
---|
[173] | 79 | void Imu::ApplyRotation(Quaternion& quaternion) {
|
---|
| 80 | if (rotation == NULL) {
|
---|
| 81 | Err("not applicable for simulation part.\n");
|
---|
| 82 | return;
|
---|
| 83 | }
|
---|
| 84 | rotation->ComputeRotation(quaternion);
|
---|
| 85 | }
|
---|
| 86 |
|
---|
[15] | 87 | GroupBox *Imu::GetGroupBox(void) const { return setupGroupbox; }
|
---|
[3] | 88 |
|
---|
[15] | 89 | Layout *Imu::GetLayout(void) const { return sensorTab; }
|
---|
[3] | 90 |
|
---|
| 91 | void Imu::LockUserInterface(void) const {
|
---|
[15] | 92 | if (sensorTab == NULL) {
|
---|
| 93 | Err("not applicable for simulation part.\n");
|
---|
| 94 | return;
|
---|
| 95 | }
|
---|
| 96 | sensorTab->setEnabled(false);
|
---|
[3] | 97 | }
|
---|
| 98 |
|
---|
| 99 | void Imu::UnlockUserInterface(void) const {
|
---|
[15] | 100 | if (sensorTab == NULL) {
|
---|
| 101 | Err("not applicable for simulation part.\n");
|
---|
| 102 | return;
|
---|
| 103 | }
|
---|
| 104 | sensorTab->setEnabled(true);
|
---|
[3] | 105 | }
|
---|
| 106 |
|
---|
| 107 | void Imu::UseDefaultPlot(void) {
|
---|
[15] | 108 | if (tab == NULL) {
|
---|
| 109 | Err("not applicable for simulation part.\n");
|
---|
| 110 | return;
|
---|
| 111 | }
|
---|
[3] | 112 |
|
---|
[15] | 113 | plotTab = new Tab(tab, "IMU");
|
---|
| 114 | axPlot = new DataPlot1D(plotTab->NewRow(), "acc_x", -10, 10);
|
---|
| 115 | axPlot->AddCurve(imuData->Element(ImuData::RawAx));
|
---|
| 116 | ayPlot = new DataPlot1D(plotTab->LastRowLastCol(), "acc_y", -10, 10);
|
---|
| 117 | ayPlot->AddCurve(imuData->Element(ImuData::RawAy));
|
---|
| 118 | azPlot = new DataPlot1D(plotTab->LastRowLastCol(), "acc_z", -10, 10);
|
---|
| 119 | azPlot->AddCurve(imuData->Element(ImuData::RawAz));
|
---|
[3] | 120 |
|
---|
[15] | 121 | if (plotTab == NULL)
|
---|
| 122 | plotTab = new Tab(tab, "IMU");
|
---|
| 123 | gxPlot = new DataPlot1D(plotTab->NewRow(), "gyr_x", -500, 500);
|
---|
| 124 | gxPlot->AddCurve(imuData->Element(ImuData::RawGxDeg));
|
---|
| 125 | gyPlot = new DataPlot1D(plotTab->LastRowLastCol(), "gyr_y", -500, 500);
|
---|
| 126 | gyPlot->AddCurve(imuData->Element(ImuData::RawGyDeg));
|
---|
| 127 | gzPlot = new DataPlot1D(plotTab->LastRowLastCol(), "gyr_z", -500, 500);
|
---|
| 128 | gzPlot->AddCurve(imuData->Element(ImuData::RawGzDeg));
|
---|
[3] | 129 |
|
---|
[15] | 130 | if (plotTab == NULL)
|
---|
| 131 | plotTab = new Tab(tab, "IMU");
|
---|
| 132 | mxPlot = new DataPlot1D(plotTab->NewRow(), "mag_x", -500, 500);
|
---|
| 133 | mxPlot->AddCurve(imuData->Element(ImuData::RawMx));
|
---|
| 134 | myPlot = new DataPlot1D(plotTab->LastRowLastCol(), "mag_y", -500, 500);
|
---|
| 135 | myPlot->AddCurve(imuData->Element(ImuData::RawMy));
|
---|
| 136 | mzPlot = new DataPlot1D(plotTab->LastRowLastCol(), "mag_z", -500, 500);
|
---|
| 137 | mzPlot->AddCurve(imuData->Element(ImuData::RawMz));
|
---|
[3] | 138 | }
|
---|
| 139 |
|
---|
[15] | 140 | Tab *Imu::GetPlotTab(void) const { return plotTab; }
|
---|
[3] | 141 |
|
---|
| 142 | } // end namespace sensor
|
---|
| 143 | } // end namespace flair
|
---|