aboutsummaryrefslogtreecommitdiff
path: root/apps/multirotor_att_control/multirotor_rate_control.c
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2012-10-17 18:26:56 +0200
committerLorenz Meier <lm@inf.ethz.ch>2012-10-17 18:26:56 +0200
commit2d631fb0059cecdc429c5847e8dbede82348d129 (patch)
treeab1bb88f6d35af5cd943ea6ea740674418068712 /apps/multirotor_att_control/multirotor_rate_control.c
parente4645c0a411b62ebe58c14639f5259e6a444178d (diff)
downloadpx4-firmware-2d631fb0059cecdc429c5847e8dbede82348d129.tar.gz
px4-firmware-2d631fb0059cecdc429c5847e8dbede82348d129.tar.bz2
px4-firmware-2d631fb0059cecdc429c5847e8dbede82348d129.zip
Various fixes to attitude control, flyable, needs parameter tuning
Diffstat (limited to 'apps/multirotor_att_control/multirotor_rate_control.c')
-rw-r--r--apps/multirotor_att_control/multirotor_rate_control.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/apps/multirotor_att_control/multirotor_rate_control.c b/apps/multirotor_att_control/multirotor_rate_control.c
index c132665d2..db3f1a0a6 100644
--- a/apps/multirotor_att_control/multirotor_rate_control.c
+++ b/apps/multirotor_att_control/multirotor_rate_control.c
@@ -153,6 +153,13 @@ void multirotor_control_rates(const struct vehicle_rates_setpoint_s *rate_sp,
static float pitch_control_last = 0;
static uint64_t last_run = 0;
const float deltaT = (hrt_absolute_time() - last_run) / 1000000.0f;
+ static uint64_t last_input = 0;
+
+ float dT_input = (hrt_absolute_time() - last_input) / 1000000.0f;
+ if (last_input != rate_sp->timestamp) {
+ last_input = rate_sp->timestamp;
+ }
+
last_run = hrt_absolute_time();
static int motor_skip_counter = 0;
@@ -173,7 +180,8 @@ 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("p.yawrate_p: %8.4f\n", (double)p.yawrate_p);
+ printf("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 */
@@ -185,6 +193,7 @@ void multirotor_control_rates(const struct vehicle_rates_setpoint_s *rate_sp,
pitch_control_last = pitch_control;
} else {
pitch_control = 0.0f;
+ printf("rej. NaN ctrl pitch\n");
}
/* control roll (left/right) output */
@@ -194,10 +203,11 @@ void multirotor_control_rates(const struct vehicle_rates_setpoint_s *rate_sp,
roll_control_last = roll_control;
} else {
roll_control = 0.0f;
+ printf("rej. NaN ctrl roll\n");
}
/* control yaw rate */
- float yaw_rate_control = p.yawrate_p * deltaT * ((rate_sp->yaw)*p.attrate_lim-rates[2]);
+ float yaw_rate_control = p.yawrate_p * deltaT * ((rate_sp->yaw)*p.yawrate_lim-rates[2]);
actuators->control[0] = roll_control;
actuators->control[1] = pitch_control;