source: flair-src/trunk/lib/FlairMeta/src/MetaUsRangeFinder.cpp@ 466

Last change on this file since 466 was 432, checked in by Sanahuja Guillaume, 3 years ago

add AltitudeSensor class
failsafe altitude sensor in changeable

File size: 2.5 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: MetaUsRangeFinder.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: objet integrant une dérivée
14// d'euler, un passe bas et un generateur de consigne
15// -> adapté pour un capteur d'altitude
16//
17//
18/*********************************************************************/
19
20#include "MetaUsRangeFinder.h"
21#include "UsRangeFinder.h"
22#include <LowPassFilter.h>
23#include <ButterworthLowPass.h>
24#include <Layout.h>
25#include <DataPlot1D.h>
26#include <Tab.h>
27#include <EulerDerivative.h>
28#include <GroupBox.h>
[214]29#include <Matrix.h>
[7]30
31using std::string;
32using namespace flair::core;
33using namespace flair::gui;
34using namespace flair::filter;
35using namespace flair::sensor;
36
[15]37namespace flair {
38namespace meta {
[432]39
[7]40
[15]41MetaUsRangeFinder::MetaUsRangeFinder(UsRangeFinder *us)
[432]42 : AltitudeSensor(us, us->ObjectName()) {
[422]43 //TODO: mettre une rotation entre la sortie US et le low pass
44 //pour eviter les fausses mesures quand le drone est orienté
45 /* ex
46 Vector3Df test(0,0,altitude+0.04);
47 Printf("altitude av %f %f %f %f\n",altitude,test.x,test.y,test.z);
48 test.Rotate(currentQuaternion);
49 Printf("altitude ap %f %f %f %f\n",altitude,test.x,test.y,test.z-0.04);
50 */
[15]51 this->us = us;
52 pbas_z =
53 new ButterworthLowPass(us, us->GetLayout()->NewRow(), "Passe bas", 3);
54 vz_euler = new EulerDerivative(pbas_z, us->GetLayout()->NewRow(), "Vz");
55 pbas_vz = new ButterworthLowPass(vz_euler, us->GetLayout()->NewRow(),
56 "Passe bas v", 3);
[7]57}
58
[15]59MetaUsRangeFinder::~MetaUsRangeFinder() {}
[7]60
[429]61UsRangeFinder* MetaUsRangeFinder::GetUsRangeFinder() {
62 return us;
63}
64
[7]65void MetaUsRangeFinder::UseDefaultPlot(void) {
[15]66 us->UseDefaultPlot();
[7]67
[214]68 us->GetPlot()->AddCurve(pbas_z->GetMatrix()->Element(0), DataPlot::Blue);
[7]69
[15]70 vz_plot = new DataPlot1D(us->GetPlotTab()->LastRowLastCol(), "vz", -2, 2);
[214]71 vz_plot->AddCurve(vz_euler->GetMatrix()->Element(0));
72 vz_plot->AddCurve(pbas_vz->GetMatrix()->Element(0), DataPlot::Blue);
[7]73}
74
[15]75gui::DataPlot1D *MetaUsRangeFinder::GetZPlot() { return us->GetPlot(); }
[7]76
[15]77gui::DataPlot1D *MetaUsRangeFinder::GetVzPlot() { return vz_plot; }
[7]78
[15]79float MetaUsRangeFinder::z(void) const { return pbas_z->Output(); }
[7]80
[15]81float MetaUsRangeFinder::Vz(void) const { return pbas_vz->Output(); }
[7]82
83} // end namespace sensor
[170]84} // end namespace flair
Note: See TracBrowser for help on using the repository browser.