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