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

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

add getdata for imu

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