[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] | 30 | using std::string;
|
---|
[7] | 31 | using namespace flair::core;
|
---|
| 32 | using namespace flair::gui;
|
---|
| 33 | using namespace flair::sensor;
|
---|
| 34 | using namespace flair::filter;
|
---|
| 35 |
|
---|
[15] | 36 | namespace flair {
|
---|
| 37 | namespace meta {
|
---|
| 38 |
|
---|
[286] | 39 | MetaVrpnObject::MetaVrpnObject(string name,VrpnClient *client)
|
---|
| 40 | : VrpnObject( name, client->GetTabWidget(),client) {
|
---|
| 41 | ConstructorCommon(name,client);
|
---|
[7] | 42 | }
|
---|
| 43 |
|
---|
[286] | 44 | MetaVrpnObject::MetaVrpnObject(std::string name,uint8_t id,VrpnClient *client)
|
---|
| 45 | : VrpnObject(name, id, client->GetTabWidget(),client) {
|
---|
| 46 | ConstructorCommon( name,client);
|
---|
[7] | 47 | }
|
---|
| 48 |
|
---|
[286] | 49 | void MetaVrpnObject::ConstructorCommon(string name,VrpnClient *client) {
|
---|
[135] | 50 | cvmatrix_descriptor *desc = new cvmatrix_descriptor(7, 1);
|
---|
| 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 |
|
---|
[135] | 61 | desc = new cvmatrix_descriptor(7, 1);
|
---|
| 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] | 84 | MetaVrpnObject::~MetaVrpnObject() { delete plot_tab; }
|
---|
[7] | 85 |
|
---|
[15] | 86 | DataPlot1D *MetaVrpnObject::VxPlot(void) const { return vx_opti_plot; }
|
---|
[7] | 87 |
|
---|
[15] | 88 | DataPlot1D *MetaVrpnObject::VyPlot(void) const { return vy_opti_plot; }
|
---|
[7] | 89 |
|
---|
[15] | 90 | DataPlot1D *MetaVrpnObject::VzPlot(void) const { return vz_opti_plot; }
|
---|
[7] | 91 |
|
---|
[15] | 92 | DataPlot2D *MetaVrpnObject::XyPlot(void) const { return xy_plot; }
|
---|
[7] | 93 |
|
---|
[167] | 94 | void 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 |
|
---|
| 100 | } // end namespace sensor
|
---|
[170] | 101 | } // end namespace flair
|
---|