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: 2013/04/08
|
---|
6 | // filename: MetaVrpnObject.cpp
|
---|
7 | //
|
---|
8 | // author: Guillaume Sanahuja
|
---|
9 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
10 | //
|
---|
11 | // version: $Id: $
|
---|
12 | //
|
---|
13 | // purpose: objet integrant objet vrpn et une dérivée
|
---|
14 | // d'euler
|
---|
15 | //
|
---|
16 | //
|
---|
17 | /*********************************************************************/
|
---|
18 |
|
---|
19 | #include "MetaVrpnObject.h"
|
---|
20 | #include "VrpnClient.h"
|
---|
21 | #include <EulerDerivative.h>
|
---|
22 | #include <LowPassFilter.h>
|
---|
23 | #include <IODevice.h>
|
---|
24 | #include <GridLayout.h>
|
---|
25 | #include <DataPlot1D.h>
|
---|
26 | #include <DataPlot2D.h>
|
---|
27 | #include <Tab.h>
|
---|
28 | #include <TabWidget.h>
|
---|
29 | #include <cvmatrix.h>
|
---|
30 |
|
---|
31 | using std::string;
|
---|
32 | using namespace flair::core;
|
---|
33 | using namespace flair::gui;
|
---|
34 | using namespace flair::sensor;
|
---|
35 | using namespace flair::filter;
|
---|
36 |
|
---|
37 | namespace flair {
|
---|
38 | namespace meta {
|
---|
39 |
|
---|
40 | MetaVrpnObject::MetaVrpnObject(string name)
|
---|
41 | : VrpnObject( name, GetVrpnClient()->GetTabWidget()) {
|
---|
42 | ConstructorCommon(name);
|
---|
43 | }
|
---|
44 |
|
---|
45 | MetaVrpnObject::MetaVrpnObject(std::string name,
|
---|
46 | uint8_t id)
|
---|
47 | : VrpnObject(name, id, GetVrpnClient()->GetTabWidget()) {
|
---|
48 | ConstructorCommon( name);
|
---|
49 | }
|
---|
50 |
|
---|
51 | void MetaVrpnObject::ConstructorCommon(string name) {
|
---|
52 | cvmatrix_descriptor *desc = new cvmatrix_descriptor(7, 1);
|
---|
53 | for (int i = 0; i < desc->Rows(); i++) {
|
---|
54 | desc->SetElementName(i, 0, Output()->Name(i, 0));
|
---|
55 | }
|
---|
56 | cvmatrix *prev_value = new cvmatrix(this, desc, floatType, name);
|
---|
57 | delete desc;
|
---|
58 |
|
---|
59 | pbas = new LowPassFilter(this, GetVrpnClient()->GetLayout()->NewRow(),
|
---|
60 | name + " Passe bas", prev_value);
|
---|
61 | delete prev_value;
|
---|
62 |
|
---|
63 | desc = new cvmatrix_descriptor(7, 1);
|
---|
64 | for (int i = 0; i < desc->Rows(); i++) {
|
---|
65 | desc->SetElementName(i, 0, "d" + Output()->Name(i, 0));
|
---|
66 | }
|
---|
67 | prev_value = new cvmatrix(this, desc, floatType, name);
|
---|
68 | delete desc;
|
---|
69 |
|
---|
70 | euler = new EulerDerivative(pbas, GetVrpnClient()->GetLayout()->NewRow(),
|
---|
71 | name + "_euler", prev_value);
|
---|
72 | delete prev_value;
|
---|
73 |
|
---|
74 | vx_opti_plot = new DataPlot1D(GetPlotTab()->NewRow(), "vx", -3, 3);
|
---|
75 | vx_opti_plot->AddCurve(euler->Matrix()->Element(4));
|
---|
76 | vy_opti_plot = new DataPlot1D(GetPlotTab()->LastRowLastCol(), "vy", -3, 3);
|
---|
77 | vy_opti_plot->AddCurve(euler->Matrix()->Element(5));
|
---|
78 | vz_opti_plot = new DataPlot1D(GetPlotTab()->LastRowLastCol(), "vz", -2, 2);
|
---|
79 | vz_opti_plot->AddCurve(euler->Matrix()->Element(6));
|
---|
80 |
|
---|
81 | plot_tab = new Tab(GetVrpnClient()->GetTabWidget(), "Mesures (xy) " + name);
|
---|
82 | xy_plot = new DataPlot2D(plot_tab->NewRow(), "xy", "y", -5, 5, "x", -5, 5);
|
---|
83 | xy_plot->AddCurve(Output()->Element(5, 0), Output()->Element(4, 0));
|
---|
84 | }
|
---|
85 |
|
---|
86 | MetaVrpnObject::~MetaVrpnObject() { delete plot_tab; }
|
---|
87 |
|
---|
88 | DataPlot1D *MetaVrpnObject::VxPlot(void) const { return vx_opti_plot; }
|
---|
89 |
|
---|
90 | DataPlot1D *MetaVrpnObject::VyPlot(void) const { return vy_opti_plot; }
|
---|
91 |
|
---|
92 | DataPlot1D *MetaVrpnObject::VzPlot(void) const { return vz_opti_plot; }
|
---|
93 |
|
---|
94 | DataPlot2D *MetaVrpnObject::XyPlot(void) const { return xy_plot; }
|
---|
95 |
|
---|
96 | void MetaVrpnObject::GetSpeed(Vector3Df &speed) const {
|
---|
97 | speed.x = euler->Output(4, 0);
|
---|
98 | speed.y = euler->Output(5, 0);
|
---|
99 | speed.z = euler->Output(6, 0);
|
---|
100 | }
|
---|
101 |
|
---|
102 | } // end namespace sensor
|
---|
103 | } // end namespace flair
|
---|