|
|
|
@ -162,8 +162,10 @@ static void calc_location_error(struct Location *next_loc)
@@ -162,8 +162,10 @@ static void calc_location_error(struct Location *next_loc)
|
|
|
|
|
#define NAV_RATE_ERR_MAX 250 |
|
|
|
|
static void calc_loiter(int x_error, int y_error) |
|
|
|
|
{ |
|
|
|
|
#if RETRO_LOITER_MODE == ENABLED |
|
|
|
|
x_error = constrain(x_error, -NAV_ERR_MAX, NAV_ERR_MAX); |
|
|
|
|
y_error = constrain(y_error, -NAV_ERR_MAX, NAV_ERR_MAX); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
int32_t p,i,d; // used to capture pid values for logging |
|
|
|
|
int32_t output; |
|
|
|
@ -179,7 +181,10 @@ static void calc_loiter(int x_error, int y_error)
@@ -179,7 +181,10 @@ static void calc_loiter(int x_error, int y_error)
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
x_rate_error = constrain(x_target_speed - x_actual_speed, -NAV_RATE_ERR_MAX, NAV_RATE_ERR_MAX); // calc the speed error |
|
|
|
|
x_rate_error = x_target_speed - x_actual_speed; // calc the speed error |
|
|
|
|
#if RETRO_LOITER_MODE == ENABLED |
|
|
|
|
x_rate_error = constrain(x_rate_error, -NAV_RATE_ERR_MAX, NAV_RATE_ERR_MAX); |
|
|
|
|
#endif |
|
|
|
|
p = g.pid_loiter_rate_lon.get_p(x_rate_error); |
|
|
|
|
i = g.pid_loiter_rate_lon.get_i(x_rate_error, dTnav); |
|
|
|
|
d = g.pid_loiter_rate_lon.get_d(x_rate_error, dTnav); |
|
|
|
@ -206,7 +211,10 @@ static void calc_loiter(int x_error, int y_error)
@@ -206,7 +211,10 @@ static void calc_loiter(int x_error, int y_error)
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
y_rate_error = constrain(y_target_speed - y_actual_speed, -NAV_RATE_ERR_MAX, NAV_RATE_ERR_MAX); |
|
|
|
|
y_rate_error = y_target_speed - y_actual_speed; |
|
|
|
|
#if RETRO_LOITER_MODE == ENABLED |
|
|
|
|
y_rate_error = constrain(y_rate_error, -NAV_RATE_ERR_MAX, NAV_RATE_ERR_MAX); |
|
|
|
|
#endif |
|
|
|
|
p = g.pid_loiter_rate_lat.get_p(y_rate_error); |
|
|
|
|
i = g.pid_loiter_rate_lat.get_i(y_rate_error, dTnav); |
|
|
|
|
d = g.pid_loiter_rate_lat.get_d(y_rate_error, dTnav); |
|
|
|
|