diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2012-10-18 17:34:06 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2012-10-18 17:34:06 +0200 |
commit | 5ec5754f26f1059847b7f149bcbdf2b0d11a5115 (patch) | |
tree | 18dde09b5eb02aea2dddd489c3b90c8e0f0a747d /apps/multirotor_att_control/multirotor_rate_control.c | |
parent | c70c626915fc70d87088c6ae66152ed536cacc96 (diff) | |
download | px4-firmware-5ec5754f26f1059847b7f149bcbdf2b0d11a5115.tar.gz px4-firmware-5ec5754f26f1059847b7f149bcbdf2b0d11a5115.tar.bz2 px4-firmware-5ec5754f26f1059847b7f149bcbdf2b0d11a5115.zip |
brought controller back to last tuned state
Diffstat (limited to 'apps/multirotor_att_control/multirotor_rate_control.c')
-rw-r--r-- | apps/multirotor_att_control/multirotor_rate_control.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/apps/multirotor_att_control/multirotor_rate_control.c b/apps/multirotor_att_control/multirotor_rate_control.c index db3f1a0a6..7401ef0f6 100644 --- a/apps/multirotor_att_control/multirotor_rate_control.c +++ b/apps/multirotor_att_control/multirotor_rate_control.c @@ -52,6 +52,7 @@ #include <math.h> #include <systemlib/pid/pid.h> #include <systemlib/param/param.h> +#include <systemlib/err.h> #include <arch/board/up_hrt.h> PARAM_DEFINE_FLOAT(MC_YAWRATE_P, 20.0f); /* same on Flamewheel */ @@ -180,34 +181,36 @@ void multirotor_control_rates(const struct vehicle_rates_setpoint_s *rate_sp, if (motor_skip_counter % 2500 == 0) { /* update parameters from storage */ parameters_update(&h, &p); - printf("rate ctrl: p.yawrate_p: %8.4f, loop: %d Hz, input: %d Hz\n", + warnx("rate ctrl: p.yawrate_p: %8.4f, loop: %d Hz, input: %d Hz\n", (double)p.yawrate_p, (int)(1.0f/deltaT), (int)(1.0f/dT_input)); } /* calculate current control outputs */ /* control pitch (forward) output */ - float pitch_control = p.attrate_p * deltaT *((rate_sp->pitch)*p.attrate_lim-rates[1])-p.attrate_d*(pitch_control_last); + // XXX fix this line so that deltaT is also applied to the D term + float pitch_control = p.attrate_p * deltaT * (rate_sp->pitch - rates[1]) - (p.attrate_d * pitch_control_last); /* increase resilience to faulty control inputs */ if (isfinite(pitch_control)) { pitch_control_last = pitch_control; } else { pitch_control = 0.0f; - printf("rej. NaN ctrl pitch\n"); + warnx("rej. NaN ctrl pitch\n"); } /* control roll (left/right) output */ - float roll_control = p.attrate_p * deltaT * ((rate_sp->roll)*p.attrate_lim-rates[0])-p.attrate_d*(roll_control_last); + // XXX fix this line so that deltaT is also applied to the D term + float roll_control = p.attrate_p * deltaT * (rate_sp->roll - rates[0]) - (p.attrate_d * roll_control_last); /* increase resilience to faulty control inputs */ if (isfinite(roll_control)) { roll_control_last = roll_control; } else { roll_control = 0.0f; - printf("rej. NaN ctrl roll\n"); + warnx("rej. NaN ctrl roll\n"); } /* control yaw rate */ - float yaw_rate_control = p.yawrate_p * deltaT * ((rate_sp->yaw)*p.yawrate_lim-rates[2]); + float yaw_rate_control = p.yawrate_p * deltaT * ((rate_sp->yaw)-rates[2]); actuators->control[0] = roll_control; actuators->control[1] = pitch_control; |