Rover: added BRAKING_PERCENT parameter

this allows for reverse throttle to be applied for braking in corners
This commit is contained in:
Andrew Tridgell 2014-03-31 08:44:19 +11:00
parent 31082f4ce2
commit f4f04ead68
3 changed files with 28 additions and 0 deletions

View File

@ -44,6 +44,9 @@ public:
k_param_battery_volt_pin,
k_param_battery_curr_pin,
// braking
k_param_braking_percent = 30,
// 110: Telemetry control
//
@ -189,6 +192,9 @@ public:
// IO pins
AP_Int8 rssi_pin;
// braking
AP_Int8 braking_percent;
// Telemetry control
//
AP_Int16 sysid_this_mav;

View File

@ -145,6 +145,15 @@ const AP_Param::Info var_info[] PROGMEM = {
// @User: Standard
GSCALAR(speed_turn_dist, "SPEED_TURN_DIST", 2.0f),
// @Param: BRAKING_PERCENT
// @DisplayName: Percentage braking to apply
// @Description: The maximum reverse throttle braking percentage to apply when cornering
// @Units: percent
// @Range: 0 100
// @Increment: 1
// @User: Standard
GSCALAR(braking_percent, "BRAKING_PERCENT", 0),
// @Param: PIVOT_TURN_ANGLE
// @DisplayName: Pivot turn angle
// @Description: Navigation angle threshold in degrees to switch to pivot steering when SKID_STEER_OUT is 1. This allows you to setup a skid steering rover to turn on the spot in auto mode when the angle it needs to turn it greater than this angle. An angle of zero means to disable pivot turning. Note that you will probably also want to set a low value for WP_RADIUS to get neat turns.

View File

@ -124,6 +124,19 @@ static void calc_throttle(float target_speed)
} else {
channel_throttle->servo_out = constrain_int16(throttle, g.throttle_min, g.throttle_max);
}
if (!in_reverse && g.braking_percent != 0 && groundspeed_error < -g.speed_cruise/2) {
// the user has asked to use reverse throttle to brake. Apply
// it in proportion to the ground speed error, but only when
// our ground speed error is more than half our cruise speed
float brake_gain = constrain_float(-groundspeed_error / (float)g.speed_cruise, 0, 1);
int16_t braking_throttle = g.throttle_max * (g.braking_percent * 0.01f) * brake_gain;
channel_throttle->servo_out = constrain_int16(-braking_throttle, -g.throttle_max, -g.throttle_min);
// temporarily set us in reverse to allow the PWM setting to
// go negative
set_reverse(true);
}
if (use_pivot_steering()) {
channel_throttle->servo_out = 0;