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

Last change on this file since 340 was 340, checked in by Sanahuja Guillaume, 4 years ago

add servos

File size: 3.4 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,bool needRotation) : 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 if(needRotation) {
44 rotation = new OneAxisRotation(sensorTab->NewRow(), "post rotation",OneAxisRotation::PostRotation);
45 } else {
46 rotation=NULL;
47 }
48 AddDataToLog(imuData);
49}
50
51Imu::~Imu() {
52 delete mainTab;
53}
54
55const ImuData *Imu::GetDatas(void) const {
56 return imuData;
57}
58
59void Imu::GetDatas(ImuData **outImuData) const { *outImuData = imuData; }
60
61OneAxisRotation *Imu::GetOneAxisRotation(void) const {
62 if (rotation == NULL) {
63 Err("not applicable\n");
64 }
65 return rotation;
66}
67
68void Imu::ApplyRotation(Vector3Df& vector) {
69 if (rotation == NULL) {
70 Err("not applicable\n");
71 return;
72 }
73 rotation->ComputeRotation(vector);
74}
75
76void Imu::ApplyRotation(Quaternion& quaternion) {
77 if (rotation == NULL) {
78 Err("not applicable\n");
79 return;
80 }
81 rotation->ComputeRotation(quaternion);
82}
83
84GroupBox *Imu::GetGroupBox(void) const { return setupGroupbox; }
85
86Layout *Imu::GetLayout(void) const { return sensorTab; }
87
88void Imu::LockUserInterface(void) const {
89 sensorTab->setEnabled(false);
90}
91
92void Imu::UnlockUserInterface(void) const {
93 sensorTab->setEnabled(true);
94}
95
96void Imu::UseDefaultPlot(void) {
97
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));
105
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));
112
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));
119}
120
121Tab *Imu::GetPlotTab(void) const { return plotTab; }
122
123} // end namespace sensor
124} // end namespace flair
Note: See TracBrowser for help on using the repository browser.