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

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

matrix

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