|
|
@ -23,7 +23,7 @@ static void calc_throttle() |
|
|
|
|
|
|
|
|
|
|
|
groundspeed_error = g.speed_cruise - ground_speed; |
|
|
|
groundspeed_error = g.speed_cruise - ground_speed; |
|
|
|
|
|
|
|
|
|
|
|
throttle = throttle_target + g.pidSpeedThrottle.get_pid(groundspeed_error); |
|
|
|
throttle = throttle_target + (g.pidSpeedThrottle.get_pid(groundspeed_error * 100) / 100); |
|
|
|
g.channel_throttle.servo_out = constrain_int16(throttle, g.throttle_min.get(), g.throttle_max.get()); |
|
|
|
g.channel_throttle.servo_out = constrain_int16(throttle, g.throttle_min.get(), g.throttle_max.get()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -42,22 +42,13 @@ static void calc_nav_steer() |
|
|
|
|
|
|
|
|
|
|
|
// negative error = left turn |
|
|
|
// negative error = left turn |
|
|
|
// positive error = right turn |
|
|
|
// positive error = right turn |
|
|
|
|
|
|
|
nav_steer = g.pidNavSteer.get_pid(bearing_error_cd, nav_gain_scaler); |
|
|
|
nav_steer = g.pidNavSteer.get_pid(bearing_error, nav_gain_scaler); //returns desired bank angle in degrees*100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (obstacle) { // obstacle avoidance |
|
|
|
if (obstacle) { // obstacle avoidance |
|
|
|
nav_steer += 9000; // if obstacle in front turn 90° right |
|
|
|
nav_steer += 9000; // if obstacle in front turn 90° right |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Zeros out navigation Integrators if we are changing mode, have passed a waypoint, etc. |
|
|
|
|
|
|
|
// Keeps outdated data out of our calculations |
|
|
|
|
|
|
|
static void reset_I(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
g.pidNavSteer.reset_I(); |
|
|
|
|
|
|
|
g.pidSpeedThrottle.reset_I(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************** |
|
|
|
/***************************************** |
|
|
|
* Set the flight control servos based on the current calculated values |
|
|
|
* Set the flight control servos based on the current calculated values |
|
|
|
*****************************************/ |
|
|
|
*****************************************/ |
|
|
|