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

Last change on this file since 420 was 420, checked in by Sanahuja Guillaume, 9 months ago

update

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