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

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

m

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