9 changed files with 146 additions and 1 deletions
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Rover specific AP_AdvancedFailsafe class
|
||||
*/ |
||||
|
||||
#include "Rover.h" |
||||
|
||||
#if ADVANCED_FAILSAFE == ENABLED |
||||
|
||||
// Constructor
|
||||
AP_AdvancedFailsafe_Rover::AP_AdvancedFailsafe_Rover(AP_Mission &_mission, AP_Baro &_baro, const AP_GPS &_gps, const RCMapper &_rcmap) : |
||||
AP_AdvancedFailsafe(_mission, _baro, _gps, _rcmap) |
||||
{} |
||||
|
||||
|
||||
/*
|
||||
Setup radio_out values for all channels to termination values |
||||
*/ |
||||
void AP_AdvancedFailsafe_Rover::terminate_vehicle(void) |
||||
{ |
||||
// stop motors
|
||||
SRV_Channels::set_output_pwm(SRV_Channel::k_throttle, 0); |
||||
SRV_Channels::set_output_pwm(SRV_Channel::k_steering, 0); |
||||
rover.lateral_acceleration = 0; |
||||
|
||||
// disarm as well
|
||||
rover.disarm_motors(); |
||||
|
||||
// Set to HOLD mode
|
||||
rover.set_mode(HOLD); |
||||
// and set all aux channels
|
||||
SRV_Channels::set_output_limit(SRV_Channel::k_manual, SRV_Channel::SRV_CHANNEL_LIMIT_TRIM); |
||||
SRV_Channels::set_output_limit(SRV_Channel::k_none, SRV_Channel::SRV_CHANNEL_LIMIT_TRIM); |
||||
|
||||
SRV_Channels::output_ch_all(); |
||||
} |
||||
|
||||
void AP_AdvancedFailsafe_Rover::setup_IO_failsafe(void) |
||||
{ |
||||
// setup failsafe for all aux channels
|
||||
SRV_Channels::set_failsafe_limit(SRV_Channel::k_manual, SRV_Channel::SRV_CHANNEL_LIMIT_TRIM); |
||||
SRV_Channels::set_failsafe_limit(SRV_Channel::k_none, SRV_Channel::SRV_CHANNEL_LIMIT_TRIM); |
||||
} |
||||
|
||||
/*
|
||||
Return an AFS_MODE for current control mode |
||||
*/ |
||||
AP_AdvancedFailsafe::control_mode AP_AdvancedFailsafe_Rover::afs_mode(void) |
||||
{ |
||||
switch (rover.control_mode) { |
||||
case AUTO: |
||||
case GUIDED: |
||||
case RTL: |
||||
return AP_AdvancedFailsafe::AFS_AUTO; |
||||
default: |
||||
break; |
||||
} |
||||
return AP_AdvancedFailsafe::AFS_STABILIZED; |
||||
} |
||||
|
||||
#endif // ADVANCED_FAILSAFE
|
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
This program is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/ |
||||
#pragma once |
||||
|
||||
/*
|
||||
advanced failsafe support for rover |
||||
*/ |
||||
|
||||
#if ADVANCED_FAILSAFE == ENABLED |
||||
#include <AP_AdvancedFailsafe/AP_AdvancedFailsafe.h> |
||||
|
||||
/*
|
||||
a rover specific AP_AdvancedFailsafe class |
||||
*/ |
||||
class AP_AdvancedFailsafe_Rover : public AP_AdvancedFailsafe |
||||
{ |
||||
public: |
||||
AP_AdvancedFailsafe_Rover(AP_Mission &_mission, AP_Baro &_baro, const AP_GPS &_gps, const RCMapper &_rcmap); |
||||
|
||||
// called to set all outputs to termination state
|
||||
void terminate_vehicle(void); |
||||
|
||||
protected: |
||||
// setup failsafe values for if FMU firmware stops running
|
||||
void setup_IO_failsafe(void); |
||||
|
||||
// return the AFS mapped control mode
|
||||
enum control_mode afs_mode(void); |
||||
}; |
||||
|
||||
#endif // ADVANCED_FAILSAFE
|
Loading…
Reference in new issue