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

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

filter and meta

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