Changeset 432 in flair-src for trunk/lib/FlairMeta/src
- Timestamp:
- Jul 12, 2021, 11:19:21 AM (3 years ago)
- Location:
- trunk/lib/FlairMeta/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairMeta/src/MetaUsRangeFinder.cpp
r429 r432 37 37 namespace flair { 38 38 namespace meta { 39 39 40 40 41 MetaUsRangeFinder::MetaUsRangeFinder(UsRangeFinder *us) 41 : Object(us, us->ObjectName()) {42 : AltitudeSensor(us, us->ObjectName()) { 42 43 //TODO: mettre une rotation entre la sortie US et le low pass 43 44 //pour eviter les fausses mesures quand le drone est orienté -
trunk/lib/FlairMeta/src/MetaUsRangeFinder.h
r429 r432 14 14 #define METAUSRANGEFINDER_H 15 15 16 #include < Object.h>16 #include <AltitudeSensor.h> 17 17 18 18 namespace flair { 19 namespace filter {20 class ButterworthLowPass;21 class EulerDerivative;22 }23 namespace sensor {24 class UsRangeFinder;25 }26 namespace gui {27 class DataPlot1D;28 }19 namespace filter { 20 class ButterworthLowPass; 21 class EulerDerivative; 22 } 23 namespace sensor { 24 class UsRangeFinder; 25 } 26 namespace gui { 27 class DataPlot1D; 28 } 29 29 } 30 30 … … 38 38 * Cette classe est adaptée pour un capteur d'altitude. 39 39 */ 40 class MetaUsRangeFinder : public core::Object{40 class MetaUsRangeFinder : public sensor::AltitudeSensor { 41 41 public: 42 42 MetaUsRangeFinder(sensor::UsRangeFinder *us); … … 51 51 private: 52 52 sensor::UsRangeFinder *us; 53 filter::ButterworthLowPass *pbas_z, 53 filter::ButterworthLowPass *pbas_z,*pbas_vz; 54 54 filter::EulerDerivative *vz_euler; 55 55 gui::DataPlot1D *vz_plot; -
trunk/lib/FlairMeta/src/MetaVrpnObject.cpp
r420 r432 27 27 #include <TabWidget.h> 28 28 #include <Matrix.h> 29 #include <AltitudeSensor.h> 29 30 30 31 using std::string; … … 33 34 using namespace flair::sensor; 34 35 using namespace flair::filter; 36 37 namespace flair { 38 namespace sensor { 39 class 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 35 65 36 66 namespace flair { … … 80 110 xy_plot = new DataPlot2D(plot_tab->NewRow(), "xy", "y", -5, 5, "x", -5, 5); 81 111 xy_plot->AddCurve(Output()->Element(5, 0), Output()->Element(4, 0)); 112 113 altitudeSensor=new MetaVrpnObjectAltitudeSensor(this,name); 114 } 115 116 sensor::AltitudeSensor *MetaVrpnObject::GetAltitudeSensor(void) const { 117 return altitudeSensor; 82 118 } 83 119 … … 102 138 } 103 139 104 } // end namespace sensor140 } // end namespace meta 105 141 } // end namespace flair -
trunk/lib/FlairMeta/src/MetaVrpnObject.h
r420 r432 29 29 class LowPassFilter; 30 30 } 31 namespace sensor { 32 class AltitudeSensor; 33 } 31 34 } 32 35 … … 51 54 void GetSpeed(core::Vector3Df &speed) const; 52 55 filter::EulerDerivative* GetEulerDerivative(void) const; 56 //get the associated AltitudeSensor 57 //MetaVrpnObject do not derivate from AltitudeSensor because frames are differents 58 //and this could be confusing 59 //MetaVrpnObject is in vrpn frame (earth) 60 //AltitudeSensor is in uav frame 61 sensor::AltitudeSensor *GetAltitudeSensor(void) const; 53 62 54 63 private: … … 59 68 gui::DataPlot1D *vx_opti_plot, *vy_opti_plot, *vz_opti_plot; 60 69 gui::Tab *plot_tab; 70 sensor::AltitudeSensor *altitudeSensor; 61 71 }; 62 72 } // end namespace meta -
trunk/lib/FlairMeta/src/UavStateMachine.cpp
r422 r432 53 53 54 54 UavStateMachine::UavStateMachine(TargetController *controller): 55 56 57 58 55 Thread(getFrameworkManager(),"UavStateMachine",50), 56 uav(GetUav()),controller(controller),failSafeMode(true),flagConnectionLost(false),flagBatteryLow(false),flagCriticalSensorLost(false),flagZTrajectoryFinished(false),safeToFly(true){ 57 altitudeState=AltitudeState_t::Stopped; 58 uav->UseDefaultPlot(); 59 59 60 60 Tab *uavTab = new Tab(getFrameworkManager()->GetTabWidget(), "uav", 0); … … 112 112 uav->GetMetaUsRangeFinder()->GetVzPlot()->AddCurve( 113 113 altitudeTrajectory->GetMatrix()->Element(1), DataPlot::Green); 114 115 failSafeAltitudeSensor=uav->GetMetaUsRangeFinder(); 114 116 } 115 117 … … 125 127 126 128 const TargetController *UavStateMachine::GetTargetController(void) const { 127 129 return controller; 128 130 } 129 131 130 132 MetaDualShock3 *UavStateMachine::GetJoystick(void) const { 131 133 return joy; 132 134 } 133 135 … … 138 140 const Vector3Df &UavStateMachine::GetCurrentAngularSpeed(void) const { 139 141 return currentAngularSpeed; 142 } 143 144 void UavStateMachine::SetFailSafeAltitudeSensor(AltitudeSensor *altitudeSensor) { 145 Warn("Replacing the FailSafeAltitudeSensor with %s\n",altitudeSensor->ObjectName().c_str()); 146 failSafeAltitudeSensor=altitudeSensor; 140 147 } 141 148 … … 147 154 void UavStateMachine::FailSafeAltitudeValues(float &altitude, 148 155 float &verticalSpeed) const { 149 altitude = uav->GetMetaUsRangeFinder()->z();150 verticalSpeed = uav->GetMetaUsRangeFinder()->Vz();156 altitude = failSafeAltitudeSensor->z(); 157 verticalSpeed = failSafeAltitudeSensor->Vz(); 151 158 159 //a mettre dans le metausrangefinder? 160 //on ne sait pas si failSafeAltitudeSensor est vrpn (dans ce cas pas besoin de rotation) 161 //ou un us range finder 152 162 //+0.04 decalage en z de l'us en simulation 153 163 //faire un reglage -
trunk/lib/FlairMeta/src/UavStateMachine.h
r313 r432 26 26 27 27 namespace flair { 28 namespace core { 29 class FrameworkManager; 30 class AhrsData; 31 class io_data; 32 } 33 namespace gui { 34 class PushButton; 35 class GridLayout; 36 class Tab; 37 class DoubleSpinBox; 38 } 39 namespace filter { 40 class ControlLaw; 41 class NestedSat; 42 class Pid; 43 class PidThrust; 44 class TrajectoryGenerator1D; 45 } 46 namespace sensor { 47 class TargetController; 48 } 49 namespace meta { 50 class MetaDualShock3; 51 class Uav; 52 } 28 namespace core { 29 class FrameworkManager; 30 class AhrsData; 31 class io_data; 32 } 33 namespace gui { 34 class PushButton; 35 class GridLayout; 36 class Tab; 37 class DoubleSpinBox; 38 } 39 namespace filter { 40 class ControlLaw; 41 class NestedSat; 42 class Pid; 43 class PidThrust; 44 class TrajectoryGenerator1D; 45 } 46 namespace sensor { 47 class TargetController; 48 class AltitudeSensor; 49 } 50 namespace meta { 51 class MetaDualShock3; 52 class Uav; 53 } 53 54 } 54 55 … … 102 103 }; 103 104 104 105 105 UavStateMachine(sensor::TargetController* controller); 106 ~UavStateMachine(); 106 107 107 108 const core::Quaternion &GetCurrentQuaternion(void) const; … … 109 110 const core::Vector3Df &GetCurrentAngularSpeed(void) const; 110 111 111 112 113 114 115 116 117 118 119 112 void Land(void); 113 void EmergencyLand(void); 114 void TakeOff(void); 115 void EmergencyStop(void); 116 //! Used to signal an event 117 /*! 118 \param event the event which occured 119 */ 120 virtual void SignalEvent(Event_t event); 120 121 121 122 virtual const core::AhrsData *GetOrientation(void) const; … … 126 127 bool ExitFailSafeMode(void); 127 128 void FailSafeAltitudeValues(float &z, float &dz) const; // in uav coordinate! 129 130 /*! 131 * \brief Set the FailSafe AltitudeSensor 132 * 133 * by default, the failsafe AltitudeSensor is the MetaUsRangeFinder 134 * you can change it (by a vrpn one) using this method in the case us range finder is not working well 135 * use it carefully, trusting only vrpn can be risquee 136 * 137 * \param altitudeSensor altitudeSensor to use when is failsafe 138 */ 139 void SetFailSafeAltitudeSensor(sensor::AltitudeSensor *altitudeSensor); 128 140 129 141 gui::GridLayout *GetButtonsLayout(void) const; … … 306 318 filter::PidThrust *uZ; 307 319 filter::TrajectoryGenerator1D *altitudeTrajectory; 320 sensor::AltitudeSensor *failSafeAltitudeSensor; 308 321 }; 309 }; 310 }; 322 }; // end namespace meta 323 }; // end namespace flair 311 324 #endif // UAVSTATEMACHINE_H
Note:
See TracChangeset
for help on using the changeset viewer.