Rover: move RC failsafe check up

Both steering and acro modes can benefit from this check
This commit is contained in:
Peter Barker 2017-11-29 18:12:13 +11:00 committed by Randy Mackay
parent 47f8ed7fab
commit 68800a52f5
2 changed files with 13 additions and 11 deletions

View File

@ -26,6 +26,13 @@ bool Mode::enter()
void Mode::get_pilot_desired_steering_and_throttle(float &steering_out, float &throttle_out)
{
// no RC input means no throttle and centered steering
if (rover.failsafe.bits & FAILSAFE_EVENT_THROTTLE) {
steering_out = 0;
throttle_out = 0;
return;
}
// apply RC skid steer mixing
switch ((enum pilot_steer_type_t)rover.g.pilot_steer_type.get())
{

View File

@ -3,17 +3,12 @@
void ModeManual::update()
{
// check for radio failsafe
if (rover.failsafe.bits & FAILSAFE_EVENT_THROTTLE) {
g2.motors.set_throttle(0.0f);
g2.motors.set_steering(0.0f);
} else {
float desired_steering, desired_throttle;
get_pilot_desired_steering_and_throttle(desired_steering, desired_throttle);
// copy RC scaled inputs to outputs
g2.motors.set_throttle(desired_throttle);
g2.motors.set_steering(desired_steering);
}
float desired_steering, desired_throttle;
get_pilot_desired_steering_and_throttle(desired_steering, desired_throttle);
// copy RC scaled inputs to outputs
g2.motors.set_throttle(desired_throttle);
g2.motors.set_steering(desired_steering);
// mark us as in_reverse when using a negative throttle to stop AHRS getting off
rover.set_reverse(is_negative(g2.motors.get_throttle()));