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

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

changement post/pre rotation

File size: 3.9 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
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
32namespace flair {
33namespace sensor {
34
35Imu::Imu(string name) : IODevice(getFrameworkManager(), name) {
36 imuData = new ImuData(this);
37
38 // station sol
39 mainTab = new Tab(getFrameworkManager()->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",OneAxisRotation::PostRotation);
44 AddDataToLog(imuData);
45}
46
47Imu::Imu(const IODevice *parent,std::string name) : IODevice(parent, name) {
48 imuData = new ImuData(this);
49 mainTab = NULL;
50 tab = NULL;
51 sensorTab = NULL;
52 setupGroupbox = NULL;
53 rotation = NULL;
54}
55
56Imu::~Imu() {
57 if (mainTab != NULL)
58 delete mainTab;
59}
60
61const ImuData *Imu::GetDatas(void) const {
62 return imuData;
63}
64
65void Imu::GetDatas(ImuData **outImuData) const { *outImuData = imuData; }
66
67OneAxisRotation *Imu::GetOneAxisRotation(void) const {
68 return rotation;
69}
70
71void Imu::ApplyRotation(Vector3Df& vector) {
72 if (rotation == NULL) {
73 Err("not applicable for simulation part.\n");
74 return;
75 }
76 rotation->ComputeRotation(vector);
77}
78
79void 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
87GroupBox *Imu::GetGroupBox(void) const { return setupGroupbox; }
88
89Layout *Imu::GetLayout(void) const { return sensorTab; }
90
91void Imu::LockUserInterface(void) const {
92 if (sensorTab == NULL) {
93 Err("not applicable for simulation part.\n");
94 return;
95 }
96 sensorTab->setEnabled(false);
97}
98
99void Imu::UnlockUserInterface(void) const {
100 if (sensorTab == NULL) {
101 Err("not applicable for simulation part.\n");
102 return;
103 }
104 sensorTab->setEnabled(true);
105}
106
107void Imu::UseDefaultPlot(void) {
108 if (tab == NULL) {
109 Err("not applicable for simulation part.\n");
110 return;
111 }
112
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));
120
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));
129
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));
138}
139
140Tab *Imu::GetPlotTab(void) const { return plotTab; }
141
142} // end namespace sensor
143} // end namespace flair
Note: See TracBrowser for help on using the repository browser.