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