diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-11-28 23:00:43 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-11-28 23:00:43 +0100 |
commit | 00b79764d795edf2914e4c5dcb6e5eaa00376aee (patch) | |
tree | b8b48d1ad9f797baa0c22f1f454cbac3bbe90b35 /apps/fixedwing_pos_control | |
parent | 9fa628c6682543e930e8c9d5b8e5c8681081dada (diff) | |
download | px4-firmware-00b79764d795edf2914e4c5dcb6e5eaa00376aee.tar.gz px4-firmware-00b79764d795edf2914e4c5dcb6e5eaa00376aee.tar.bz2 px4-firmware-00b79764d795edf2914e4c5dcb6e5eaa00376aee.zip |
minor code cleanup, not changing functionality
Diffstat (limited to 'apps/fixedwing_pos_control')
-rw-r--r-- | apps/fixedwing_pos_control/fixedwing_pos_control_main.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/apps/fixedwing_pos_control/fixedwing_pos_control_main.c b/apps/fixedwing_pos_control/fixedwing_pos_control_main.c index 3cff75a1a..fbd6138de 100644 --- a/apps/fixedwing_pos_control/fixedwing_pos_control_main.c +++ b/apps/fixedwing_pos_control/fixedwing_pos_control_main.c @@ -297,19 +297,12 @@ int fixedwing_pos_control_thread_main(int argc, char *argv[]) if (global_sp_updated) { orb_copy(ORB_ID(vehicle_global_position_setpoint), global_setpoint_sub, &global_setpoint); - // printf("xtrack_err.distance %.4f ", (double)xtrack_err.distance); - - float delta_psi_c = pid_calculate(&offtrack_controller, 0, xtrack_err.distance, 0.0f, 0.0f); //p.xtrack_p * xtrack_err.distance - - // printf("delta_psi_c %.4f ", (double)delta_psi_c); - start_pos = global_pos; //for now using the current position as the startpoint (= approx. last waypoint because the setpoint switch occurs at the waypoint) global_sp_updated_set_once = true; psi_track = get_bearing_to_next_waypoint((double)global_pos.lat / (double)1e7d, (double)global_pos.lon / (double)1e7d, (double)global_setpoint.lat / (double)1e7d, (double)global_setpoint.lon / (double)1e7d); - if (verbose) - printf("psi_track: %0.4f\n", (double)psi_track); + printf("next wp direction: %0.4f\n", (double)psi_track); } /* Simple Horizontal Control */ @@ -331,6 +324,9 @@ int fixedwing_pos_control_thread_main(int argc, char *argv[]) float psi_c = psi_track + delta_psi_c; float psi_e = psi_c - att.yaw; + + /* wrap difference back onto -pi..pi range */ + psi_e = _wrap_pi(psi_e); if (verbose) { printf("xtrack_err.distance %.4f ", (double)xtrack_err.distance); @@ -340,9 +336,6 @@ int fixedwing_pos_control_thread_main(int argc, char *argv[]) printf("psi_e %.4f ", (double)psi_e); } - /* shift error to prevent wrapping issues */ - psi_e = _wrap_pi(psi_e); - /* calculate roll setpoint, do this artificially around zero */ float delta_psi_rate_c = pid_calculate(&heading_controller, psi_e, 0.0f, 0.0f, 0.0f); float psi_rate_track = 0; //=V_gr/r_track , this will be needed for implementation of arc following |