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/UavStateMachine.cpp

    r422 r432  
    5353
    5454UavStateMachine::UavStateMachine(TargetController *controller):
    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();
     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();
    5959
    6060  Tab *uavTab = new Tab(getFrameworkManager()->GetTabWidget(), "uav", 0);
     
    112112  uav->GetMetaUsRangeFinder()->GetVzPlot()->AddCurve(
    113113      altitudeTrajectory->GetMatrix()->Element(1), DataPlot::Green);
     114     
     115  failSafeAltitudeSensor=uav->GetMetaUsRangeFinder();
    114116}
    115117
     
    125127
    126128const TargetController *UavStateMachine::GetTargetController(void) const {
    127     return controller;
     129  return controller;
    128130}
    129131
    130132MetaDualShock3 *UavStateMachine::GetJoystick(void) const {
    131     return joy;
     133  return joy;
    132134}
    133135
     
    138140const Vector3Df &UavStateMachine::GetCurrentAngularSpeed(void) const {
    139141  return currentAngularSpeed;
     142}
     143
     144void UavStateMachine::SetFailSafeAltitudeSensor(AltitudeSensor *altitudeSensor) {
     145  Warn("Replacing the FailSafeAltitudeSensor with %s\n",altitudeSensor->ObjectName().c_str());
     146  failSafeAltitudeSensor=altitudeSensor;
    140147}
    141148
     
    147154void UavStateMachine::FailSafeAltitudeValues(float &altitude,
    148155                                             float &verticalSpeed) const {
    149   altitude = uav->GetMetaUsRangeFinder()->z();
    150   verticalSpeed = uav->GetMetaUsRangeFinder()->Vz();
     156  altitude = failSafeAltitudeSensor->z();
     157  verticalSpeed = failSafeAltitudeSensor->Vz();
    151158 
     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
    152162  //+0.04 decalage en z de l'us en simulation
    153163  //faire un reglage
Note: See TracChangeset for help on using the changeset viewer.