Changeset 432 in flair-src for trunk/lib/FlairMeta/src/MetaVrpnObject.cpp


Ignore:
Timestamp:
Jul 12, 2021, 11:19:21 AM (3 years ago)
Author:
Sanahuja Guillaume
Message:

add AltitudeSensor class
failsafe altitude sensor in changeable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairMeta/src/MetaVrpnObject.cpp

    r420 r432  
    2727#include <TabWidget.h>
    2828#include <Matrix.h>
     29#include <AltitudeSensor.h>
    2930
    3031using std::string;
     
    3334using namespace flair::sensor;
    3435using namespace flair::filter;
     36
     37namespace flair {
     38namespace sensor {
     39class MetaVrpnObjectAltitudeSensor : public AltitudeSensor {
     40  public:
     41    MetaVrpnObjectAltitudeSensor(meta::MetaVrpnObject* parent,std::string name): AltitudeSensor(parent,name) {
     42      this->parent=parent;
     43    }
     44    ~MetaVrpnObjectAltitudeSensor() {
     45    }
     46
     47    //z and dz must be in uav's frame
     48    float z(void) const {
     49      Vector3Df uav_pos;
     50      parent->GetPosition(uav_pos);
     51      return -uav_pos.z;
     52    }
     53    float Vz(void) const {
     54      Vector3Df uav_vel;
     55      parent->GetSpeed(uav_vel);
     56      return -uav_vel.z;
     57    }
     58
     59  private:
     60     meta::MetaVrpnObject* parent;
     61     
     62};
     63}// end namespace sensor
     64}// end namespace flair
    3565
    3666namespace flair {
     
    80110  xy_plot = new DataPlot2D(plot_tab->NewRow(), "xy", "y", -5, 5, "x", -5, 5);
    81111  xy_plot->AddCurve(Output()->Element(5, 0), Output()->Element(4, 0));
     112 
     113  altitudeSensor=new MetaVrpnObjectAltitudeSensor(this,name);
     114}
     115
     116sensor::AltitudeSensor *MetaVrpnObject::GetAltitudeSensor(void) const {
     117  return altitudeSensor;
    82118}
    83119
     
    102138}
    103139
    104 } // end namespace sensor
     140} // end namespace meta
    105141} // end namespace flair
Note: See TracChangeset for help on using the changeset viewer.