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

Last change on this file since 13 was 10, checked in by Sanahuja Guillaume, 9 years ago

lic

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