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

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

modif imu

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