Rover: acro and steering steer even with target speed of zero

This commit is contained in:
Randy Mackay 2018-02-19 12:29:49 +11:00
parent 4b41d0833a
commit 30fcda1d0a
3 changed files with 14 additions and 18 deletions

View File

@ -174,7 +174,15 @@ void Mode::calc_throttle(float target_speed, bool nudge_allowed)
}
// call throttle controller and convert output to -100 to +100 range
float throttle_out = 100.0f * attitude_control.get_throttle_out_speed(target_speed, g2.motors.limit.throttle_lower, g2.motors.limit.throttle_upper, g.speed_cruise, g.throttle_cruise * 0.01f);
float throttle_out;
// call speed or stop controller
if (is_zero(target_speed)) {
bool stopped;
throttle_out = 100.0f * attitude_control.get_throttle_out_stop(g2.motors.limit.throttle_lower, g2.motors.limit.throttle_upper, g.speed_cruise, g.throttle_cruise * 0.01f, stopped);
} else {
throttle_out = 100.0f * attitude_control.get_throttle_out_speed(target_speed, g2.motors.limit.throttle_lower, g2.motors.limit.throttle_upper, g.speed_cruise, g.throttle_cruise * 0.01f);
}
// send to motor
g2.motors.set_throttle(throttle_out);

View File

@ -22,15 +22,6 @@ void ModeAcro::update()
// convert pilot steering input to desired turn rate in radians/sec
const float target_turn_rate = (desired_steering / 4500.0f) * radians(g2.acro_turn_rate);
// determine if pilot is requesting pivot turn
const bool is_pivot_turning = g2.motors.have_skid_steering() && is_zero(target_speed) && (!is_zero(desired_steering));
// stop vehicle if target speed is zero and not pivot turning
if (is_zero(target_speed) && !is_pivot_turning) {
stop_vehicle();
return;
}
// set reverse flag backing up
const bool reversed = is_negative(target_speed);
rover.set_reverse(reversed);

View File

@ -47,12 +47,9 @@ void ModeSteering::update()
// mark us as in_reverse when using a negative throttle
rover.set_reverse(reversed);
// run speed to throttle output controller
if (is_zero(target_speed) && !is_pivot_turning) {
stop_vehicle();
} else {
// run lateral acceleration to steering controller
calc_steering_from_lateral_acceleration(desired_lat_accel, reversed);
// run speed to throttle controller
calc_throttle(target_speed, false);
}
}