source: flair-src/trunk/lib/FlairSensorActuator/src/Imu.cpp@ 251

Last change on this file since 251 was 198, checked in by Sanahuja Guillaume, 7 years ago

modifs imu

File size: 4.0 KB
RevLine 
[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
28using std::string;
29using namespace flair::core;
30using namespace flair::gui;
31
[15]32namespace flair {
33namespace sensor {
[3]34
[198]35Imu::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
[137]51Imu::Imu(const IODevice *parent,std::string name) : IODevice(parent, name) {
[15]52 imuData = new ImuData(this);
53 mainTab = NULL;
54 tab = NULL;
55 sensorTab = NULL;
56 setupGroupbox = NULL;
57 rotation = NULL;
[3]58}
59
60Imu::~Imu() {
[15]61 if (mainTab != NULL)
62 delete mainTab;
[3]63}
64
[179]65const ImuData *Imu::GetDatas(void) const {
66 return imuData;
67}
68
[15]69void Imu::GetDatas(ImuData **outImuData) const { *outImuData = imuData; }
[55]70
[99]71OneAxisRotation *Imu::GetOneAxisRotation(void) const {
[198]72 if (rotation == NULL) {
73 Err("not applicable\n");
74 }
[99]75 return rotation;
76}
77
[173]78void Imu::ApplyRotation(Vector3Df& vector) {
[15]79 if (rotation == NULL) {
[198]80 Err("not applicable\n");
[15]81 return;
82 }
[173]83 rotation->ComputeRotation(vector);
[3]84}
85
[173]86void Imu::ApplyRotation(Quaternion& quaternion) {
87 if (rotation == NULL) {
[198]88 Err("not applicable\n");
[173]89 return;
90 }
91 rotation->ComputeRotation(quaternion);
92}
93
[15]94GroupBox *Imu::GetGroupBox(void) const { return setupGroupbox; }
[3]95
[15]96Layout *Imu::GetLayout(void) const { return sensorTab; }
[3]97
98void Imu::LockUserInterface(void) const {
[15]99 if (sensorTab == NULL) {
100 Err("not applicable for simulation part.\n");
101 return;
102 }
103 sensorTab->setEnabled(false);
[3]104}
105
106void Imu::UnlockUserInterface(void) const {
[15]107 if (sensorTab == NULL) {
108 Err("not applicable for simulation part.\n");
109 return;
110 }
111 sensorTab->setEnabled(true);
[3]112}
113
114void Imu::UseDefaultPlot(void) {
[15]115 if (tab == NULL) {
116 Err("not applicable for simulation part.\n");
117 return;
118 }
[3]119
[15]120 plotTab = new Tab(tab, "IMU");
121 axPlot = new DataPlot1D(plotTab->NewRow(), "acc_x", -10, 10);
122 axPlot->AddCurve(imuData->Element(ImuData::RawAx));
123 ayPlot = new DataPlot1D(plotTab->LastRowLastCol(), "acc_y", -10, 10);
124 ayPlot->AddCurve(imuData->Element(ImuData::RawAy));
125 azPlot = new DataPlot1D(plotTab->LastRowLastCol(), "acc_z", -10, 10);
126 azPlot->AddCurve(imuData->Element(ImuData::RawAz));
[3]127
[15]128 if (plotTab == NULL)
129 plotTab = new Tab(tab, "IMU");
130 gxPlot = new DataPlot1D(plotTab->NewRow(), "gyr_x", -500, 500);
131 gxPlot->AddCurve(imuData->Element(ImuData::RawGxDeg));
132 gyPlot = new DataPlot1D(plotTab->LastRowLastCol(), "gyr_y", -500, 500);
133 gyPlot->AddCurve(imuData->Element(ImuData::RawGyDeg));
134 gzPlot = new DataPlot1D(plotTab->LastRowLastCol(), "gyr_z", -500, 500);
135 gzPlot->AddCurve(imuData->Element(ImuData::RawGzDeg));
[3]136
[15]137 if (plotTab == NULL)
138 plotTab = new Tab(tab, "IMU");
139 mxPlot = new DataPlot1D(plotTab->NewRow(), "mag_x", -500, 500);
140 mxPlot->AddCurve(imuData->Element(ImuData::RawMx));
141 myPlot = new DataPlot1D(plotTab->LastRowLastCol(), "mag_y", -500, 500);
142 myPlot->AddCurve(imuData->Element(ImuData::RawMy));
143 mzPlot = new DataPlot1D(plotTab->LastRowLastCol(), "mag_z", -500, 500);
144 mzPlot->AddCurve(imuData->Element(ImuData::RawMz));
[3]145}
146
[15]147Tab *Imu::GetPlotTab(void) const { return plotTab; }
[3]148
149} // end namespace sensor
150} // end namespace flair
Note: See TracBrowser for help on using the repository browser.