source: flair-src/trunk/lib/FlairMeta/src/MetaVrpnObject.cpp@ 305

Last change on this file since 305 was 286, checked in by Sanahuja Guillaume, 6 years ago

draw vrpn axis in simulator

File size: 3.2 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: 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 <EulerDerivative.h>
21#include <LowPassFilter.h>
22#include <IODevice.h>
23#include <GridLayout.h>
24#include <DataPlot1D.h>
25#include <DataPlot2D.h>
26#include <Tab.h>
27#include <TabWidget.h>
28#include <Matrix.h>
29
30using std::string;
31using namespace flair::core;
32using namespace flair::gui;
33using namespace flair::sensor;
34using namespace flair::filter;
35
36namespace flair {
37namespace meta {
38
39MetaVrpnObject::MetaVrpnObject(string name,VrpnClient *client)
40 : VrpnObject( name, client->GetTabWidget(),client) {
41 ConstructorCommon(name,client);
42}
43
44MetaVrpnObject::MetaVrpnObject(std::string name,uint8_t id,VrpnClient *client)
45 : VrpnObject(name, id, client->GetTabWidget(),client) {
46 ConstructorCommon( name,client);
47}
48
49void MetaVrpnObject::ConstructorCommon(string name,VrpnClient *client) {
50 cvmatrix_descriptor *desc = new cvmatrix_descriptor(7, 1);
51 for (int i = 0; i < desc->Rows(); i++) {
52 desc->SetElementName(i, 0, Output()->Name(i, 0));
53 }
54 Matrix *prev_value = new Matrix(this, desc, floatType, name);
55 delete desc;
56
57 pbas = new LowPassFilter(this, client->GetLayout()->NewRow(),
58 name + " Passe bas", prev_value);
59 delete prev_value;
60
61 desc = new cvmatrix_descriptor(7, 1);
62 for (int i = 0; i < desc->Rows(); i++) {
63 desc->SetElementName(i, 0, "d" + Output()->Name(i, 0));
64 }
65 prev_value = new Matrix(this, desc, floatType, name);
66 delete desc;
67
68 euler = new EulerDerivative(pbas, client->GetLayout()->NewRow(),
69 name + "_euler", prev_value);
70 delete prev_value;
71
72 vx_opti_plot = new DataPlot1D(GetPlotTab()->NewRow(), "vx", -3, 3);
73 vx_opti_plot->AddCurve(euler->GetMatrix()->Element(4));
74 vy_opti_plot = new DataPlot1D(GetPlotTab()->LastRowLastCol(), "vy", -3, 3);
75 vy_opti_plot->AddCurve(euler->GetMatrix()->Element(5));
76 vz_opti_plot = new DataPlot1D(GetPlotTab()->LastRowLastCol(), "vz", -2, 2);
77 vz_opti_plot->AddCurve(euler->GetMatrix()->Element(6));
78
79 plot_tab = new Tab(client->GetTabWidget(), "Mesures (xy) " + name);
80 xy_plot = new DataPlot2D(plot_tab->NewRow(), "xy", "y", -5, 5, "x", -5, 5);
81 xy_plot->AddCurve(Output()->Element(5, 0), Output()->Element(4, 0));
82}
83
84MetaVrpnObject::~MetaVrpnObject() { delete plot_tab; }
85
86DataPlot1D *MetaVrpnObject::VxPlot(void) const { return vx_opti_plot; }
87
88DataPlot1D *MetaVrpnObject::VyPlot(void) const { return vy_opti_plot; }
89
90DataPlot1D *MetaVrpnObject::VzPlot(void) const { return vz_opti_plot; }
91
92DataPlot2D *MetaVrpnObject::XyPlot(void) const { return xy_plot; }
93
94void MetaVrpnObject::GetSpeed(Vector3Df &speed) const {
95 speed.x = euler->Output(4, 0);
96 speed.y = euler->Output(5, 0);
97 speed.z = euler->Output(6, 0);
98}
99
100} // end namespace sensor
101} // end namespace flair
Note: See TracBrowser for help on using the repository browser.