[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 |
|
---|
[198] | 35 | Imu::Imu(string name,bool needRotation) : 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);
|
---|
[198] | 43 | if(needRotation) {
|
---|
| 44 | rotation = new OneAxisRotation(sensorTab->NewRow(), "post rotation",OneAxisRotation::PostRotation);
|
---|
| 45 | } else {
|
---|
| 46 | rotation=NULL;
|
---|
| 47 | }
|
---|
[186] | 48 | AddDataToLog(imuData);
|
---|
[3] | 49 | }
|
---|
| 50 |
|
---|
| 51 | Imu::~Imu() {
|
---|
[340] | 52 | delete mainTab;
|
---|
[3] | 53 | }
|
---|
| 54 |
|
---|
[179] | 55 | const ImuData *Imu::GetDatas(void) const {
|
---|
| 56 | return imuData;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
[15] | 59 | void Imu::GetDatas(ImuData **outImuData) const { *outImuData = imuData; }
|
---|
[55] | 60 |
|
---|
[99] | 61 | OneAxisRotation *Imu::GetOneAxisRotation(void) const {
|
---|
[198] | 62 | if (rotation == NULL) {
|
---|
| 63 | Err("not applicable\n");
|
---|
| 64 | }
|
---|
[99] | 65 | return rotation;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[173] | 68 | void Imu::ApplyRotation(Vector3Df& vector) {
|
---|
[15] | 69 | if (rotation == NULL) {
|
---|
[198] | 70 | Err("not applicable\n");
|
---|
[15] | 71 | return;
|
---|
| 72 | }
|
---|
[173] | 73 | rotation->ComputeRotation(vector);
|
---|
[3] | 74 | }
|
---|
| 75 |
|
---|
[173] | 76 | void Imu::ApplyRotation(Quaternion& quaternion) {
|
---|
| 77 | if (rotation == NULL) {
|
---|
[198] | 78 | Err("not applicable\n");
|
---|
[173] | 79 | return;
|
---|
| 80 | }
|
---|
| 81 | rotation->ComputeRotation(quaternion);
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[15] | 84 | GroupBox *Imu::GetGroupBox(void) const { return setupGroupbox; }
|
---|
[3] | 85 |
|
---|
[15] | 86 | Layout *Imu::GetLayout(void) const { return sensorTab; }
|
---|
[3] | 87 |
|
---|
| 88 | void Imu::LockUserInterface(void) const {
|
---|
[15] | 89 | sensorTab->setEnabled(false);
|
---|
[3] | 90 | }
|
---|
| 91 |
|
---|
| 92 | void Imu::UnlockUserInterface(void) const {
|
---|
[15] | 93 | sensorTab->setEnabled(true);
|
---|
[3] | 94 | }
|
---|
| 95 |
|
---|
| 96 | void Imu::UseDefaultPlot(void) {
|
---|
| 97 |
|
---|
[15] | 98 | plotTab = new Tab(tab, "IMU");
|
---|
| 99 | axPlot = new DataPlot1D(plotTab->NewRow(), "acc_x", -10, 10);
|
---|
| 100 | axPlot->AddCurve(imuData->Element(ImuData::RawAx));
|
---|
| 101 | ayPlot = new DataPlot1D(plotTab->LastRowLastCol(), "acc_y", -10, 10);
|
---|
| 102 | ayPlot->AddCurve(imuData->Element(ImuData::RawAy));
|
---|
| 103 | azPlot = new DataPlot1D(plotTab->LastRowLastCol(), "acc_z", -10, 10);
|
---|
| 104 | azPlot->AddCurve(imuData->Element(ImuData::RawAz));
|
---|
[3] | 105 |
|
---|
[15] | 106 | gxPlot = new DataPlot1D(plotTab->NewRow(), "gyr_x", -500, 500);
|
---|
| 107 | gxPlot->AddCurve(imuData->Element(ImuData::RawGxDeg));
|
---|
| 108 | gyPlot = new DataPlot1D(plotTab->LastRowLastCol(), "gyr_y", -500, 500);
|
---|
| 109 | gyPlot->AddCurve(imuData->Element(ImuData::RawGyDeg));
|
---|
| 110 | gzPlot = new DataPlot1D(plotTab->LastRowLastCol(), "gyr_z", -500, 500);
|
---|
| 111 | gzPlot->AddCurve(imuData->Element(ImuData::RawGzDeg));
|
---|
[3] | 112 |
|
---|
[15] | 113 | mxPlot = new DataPlot1D(plotTab->NewRow(), "mag_x", -500, 500);
|
---|
| 114 | mxPlot->AddCurve(imuData->Element(ImuData::RawMx));
|
---|
| 115 | myPlot = new DataPlot1D(plotTab->LastRowLastCol(), "mag_y", -500, 500);
|
---|
| 116 | myPlot->AddCurve(imuData->Element(ImuData::RawMy));
|
---|
| 117 | mzPlot = new DataPlot1D(plotTab->LastRowLastCol(), "mag_z", -500, 500);
|
---|
| 118 | mzPlot->AddCurve(imuData->Element(ImuData::RawMz));
|
---|
[3] | 119 | }
|
---|
| 120 |
|
---|
[15] | 121 | Tab *Imu::GetPlotTab(void) const { return plotTab; }
|
---|
[3] | 122 |
|
---|
| 123 | } // end namespace sensor
|
---|
| 124 | } // end namespace flair
|
---|