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

Last change on this file since 5 was 3, checked in by Sanahuja Guillaume, 9 years ago

sensoractuator

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 { namespace sensor {
33
34Imu::Imu(const FrameworkManager* parent,string name) : IODevice(parent,name) {
35 imuData=new ImuData(this);
36
37 //station sol
38 mainTab=new Tab(parent->GetTabWidget(),name);
39 tab=new TabWidget(mainTab->NewRow(),name);
40 sensorTab=new Tab(tab,"Reglages");
41 setupGroupbox=new GroupBox(sensorTab->NewRow(),name);
42 rotation=new OneAxisRotation(sensorTab->NewRow(),"post rotation");
43}
44
45Imu::Imu(const IODevice* parent,std::string name) : IODevice(parent,name) {
46 imuData=new ImuData(this);
47 mainTab=NULL;
48 tab=NULL;
49 sensorTab=NULL;
50 setupGroupbox=NULL;
51 rotation=NULL;
52}
53
54Imu::~Imu() {
55 if(mainTab!=NULL) delete mainTab;
56}
57
58void Imu::GetDatas(ImuData **outImuData) const {
59 *outImuData=imuData;
60}
61void Imu::UpdateImu() {
62 if(rotation==NULL) {
63 Err("not applicable for simulation part.\n");
64 return;
65 }
66 Vector3D rawAcc,rawMag,rawGyr;
67 imuData->GetRawAccMagAndGyr(rawAcc,rawMag,rawGyr);
68 rotation->ComputeRotation(rawAcc);
69 rotation->ComputeRotation(rawGyr);
70 rotation->ComputeRotation(rawMag);
71 imuData->SetRawAccMagAndGyr(rawAcc,rawMag,rawGyr);
72}
73
74GroupBox* Imu::GetGroupBox(void) const {
75 return setupGroupbox;
76}
77
78Layout* Imu::GetLayout(void) const {
79 return sensorTab;
80}
81
82void Imu::LockUserInterface(void) const {
83 if(sensorTab==NULL) {
84 Err("not applicable for simulation part.\n");
85 return;
86 }
87 sensorTab->setEnabled(false);
88}
89
90void Imu::UnlockUserInterface(void) const {
91 if(sensorTab==NULL) {
92 Err("not applicable for simulation part.\n");
93 return;
94 }
95 sensorTab->setEnabled(true);
96}
97
98void Imu::UseDefaultPlot(void) {
99 if(tab==NULL) {
100 Err("not applicable for simulation part.\n");
101 return;
102 }
103
104 plotTab=new Tab(tab,"IMU");
105 axPlot=new DataPlot1D(plotTab->NewRow(),"acc_x",-10,10);
106 axPlot->AddCurve(imuData->Element(ImuData::RawAx));
107 ayPlot=new DataPlot1D(plotTab->LastRowLastCol(),"acc_y",-10,10);
108 ayPlot->AddCurve(imuData->Element(ImuData::RawAy));
109 azPlot=new DataPlot1D(plotTab->LastRowLastCol(),"acc_z",-10,10);
110 azPlot->AddCurve(imuData->Element(ImuData::RawAz));
111
112 if(plotTab==NULL) plotTab=new Tab(tab,"IMU");
113 gxPlot=new DataPlot1D(plotTab->NewRow(),"gyr_x",-500,500);
114 gxPlot->AddCurve(imuData->Element(ImuData::RawGxDeg));
115 gyPlot=new DataPlot1D(plotTab->LastRowLastCol(),"gyr_y",-500,500);
116 gyPlot->AddCurve(imuData->Element(ImuData::RawGyDeg));
117 gzPlot=new DataPlot1D(plotTab->LastRowLastCol(),"gyr_z",-500,500);
118 gzPlot->AddCurve(imuData->Element(ImuData::RawGzDeg));
119
120 if(plotTab==NULL) plotTab=new Tab(tab,"IMU");
121 mxPlot=new DataPlot1D(plotTab->NewRow(),"mag_x",-500,500);
122 mxPlot->AddCurve(imuData->Element(ImuData::RawMx));
123 myPlot=new DataPlot1D(plotTab->LastRowLastCol(),"mag_y",-500,500);
124 myPlot->AddCurve(imuData->Element(ImuData::RawMy));
125 mzPlot=new DataPlot1D(plotTab->LastRowLastCol(),"mag_z",-500,500);
126 mzPlot->AddCurve(imuData->Element(ImuData::RawMz));
127}
128
129Tab* Imu::GetPlotTab(void) const {
130 return plotTab;
131}
132
133} // end namespace sensor
134} // end namespace flair
Note: See TracBrowser for help on using the repository browser.