multirotor_att_control: style fixes, cleanup

This commit is contained in:
Anton Babushkin 2013-11-02 23:35:53 +04:00
parent ad133f601b
commit 67c33b2810
1 changed files with 5 additions and 31 deletions

View File

@ -59,31 +59,23 @@
#include <systemlib/err.h> #include <systemlib/err.h>
#include <drivers/drv_hrt.h> #include <drivers/drv_hrt.h>
PARAM_DEFINE_FLOAT(MC_YAWRATE_P, 0.3f); /* same on Flamewheel */ PARAM_DEFINE_FLOAT(MC_YAWRATE_P, 0.3f);
PARAM_DEFINE_FLOAT(MC_YAWRATE_D, 0.005f); PARAM_DEFINE_FLOAT(MC_YAWRATE_D, 0.005f);
PARAM_DEFINE_FLOAT(MC_YAWRATE_I, 0.2f); PARAM_DEFINE_FLOAT(MC_YAWRATE_I, 0.2f);
//PARAM_DEFINE_FLOAT(MC_YAWRATE_AWU, 0.0f);
//PARAM_DEFINE_FLOAT(MC_YAWRATE_LIM, 1.0f);
PARAM_DEFINE_FLOAT(MC_ATTRATE_P, 0.09f); /* 0.15 F405 Flamewheel */ PARAM_DEFINE_FLOAT(MC_ATTRATE_P, 0.09f);
PARAM_DEFINE_FLOAT(MC_ATTRATE_D, 0.002f); PARAM_DEFINE_FLOAT(MC_ATTRATE_D, 0.002f);
PARAM_DEFINE_FLOAT(MC_ATTRATE_I, 0.0f); PARAM_DEFINE_FLOAT(MC_ATTRATE_I, 0.0f);
//PARAM_DEFINE_FLOAT(MC_ATTRATE_AWU, 0.05f);
//PARAM_DEFINE_FLOAT(MC_ATTRATE_LIM, 1.0f); /**< roughly < 500 deg/s limit */
struct mc_rate_control_params { struct mc_rate_control_params {
float yawrate_p; float yawrate_p;
float yawrate_d; float yawrate_d;
float yawrate_i; float yawrate_i;
//float yawrate_awu;
//float yawrate_lim;
float attrate_p; float attrate_p;
float attrate_d; float attrate_d;
float attrate_i; float attrate_i;
//float attrate_awu;
//float attrate_lim;
float rate_lim; float rate_lim;
}; };
@ -93,14 +85,10 @@ struct mc_rate_control_param_handles {
param_t yawrate_p; param_t yawrate_p;
param_t yawrate_i; param_t yawrate_i;
param_t yawrate_d; param_t yawrate_d;
//param_t yawrate_awu;
//param_t yawrate_lim;
param_t attrate_p; param_t attrate_p;
param_t attrate_i; param_t attrate_i;
param_t attrate_d; param_t attrate_d;
//param_t attrate_awu;
//param_t attrate_lim;
}; };
/** /**
@ -122,14 +110,10 @@ static int parameters_init(struct mc_rate_control_param_handles *h)
h->yawrate_p = param_find("MC_YAWRATE_P"); h->yawrate_p = param_find("MC_YAWRATE_P");
h->yawrate_i = param_find("MC_YAWRATE_I"); h->yawrate_i = param_find("MC_YAWRATE_I");
h->yawrate_d = param_find("MC_YAWRATE_D"); h->yawrate_d = param_find("MC_YAWRATE_D");
//h->yawrate_awu = param_find("MC_YAWRATE_AWU");
//h->yawrate_lim = param_find("MC_YAWRATE_LIM");
h->attrate_p = param_find("MC_ATTRATE_P"); h->attrate_p = param_find("MC_ATTRATE_P");
h->attrate_i = param_find("MC_ATTRATE_I"); h->attrate_i = param_find("MC_ATTRATE_I");
h->attrate_d = param_find("MC_ATTRATE_D"); h->attrate_d = param_find("MC_ATTRATE_D");
//h->attrate_awu = param_find("MC_ATTRATE_AWU");
//h->attrate_lim = param_find("MC_ATTRATE_LIM");
return OK; return OK;
} }
@ -139,14 +123,10 @@ static int parameters_update(const struct mc_rate_control_param_handles *h, stru
param_get(h->yawrate_p, &(p->yawrate_p)); param_get(h->yawrate_p, &(p->yawrate_p));
param_get(h->yawrate_i, &(p->yawrate_i)); param_get(h->yawrate_i, &(p->yawrate_i));
param_get(h->yawrate_d, &(p->yawrate_d)); param_get(h->yawrate_d, &(p->yawrate_d));
//param_get(h->yawrate_awu, &(p->yawrate_awu));
//param_get(h->yawrate_lim, &(p->yawrate_lim));
param_get(h->attrate_p, &(p->attrate_p)); param_get(h->attrate_p, &(p->attrate_p));
param_get(h->attrate_i, &(p->attrate_i)); param_get(h->attrate_i, &(p->attrate_i));
param_get(h->attrate_d, &(p->attrate_d)); param_get(h->attrate_d, &(p->attrate_d));
//param_get(h->attrate_awu, &(p->attrate_awu));
//param_get(h->attrate_lim, &(p->attrate_lim));
return OK; return OK;
} }
@ -202,15 +182,9 @@ void multirotor_control_rates(const struct vehicle_rates_setpoint_s *rate_sp,
pid_reset_integral(&yaw_rate_controller); pid_reset_integral(&yaw_rate_controller);
} }
/* control pitch (forward) output */ /* run pitch, roll and yaw controllers */
float pitch_control = pid_calculate(&pitch_rate_controller, rate_sp->pitch , float pitch_control = pid_calculate(&pitch_rate_controller, rate_sp->pitch, rates[1], 0.0f, deltaT);
rates[1], 0.0f, deltaT); float roll_control = pid_calculate(&roll_rate_controller, rate_sp->roll, rates[0], 0.0f, deltaT);
/* control roll (left/right) output */
float roll_control = pid_calculate(&roll_rate_controller, rate_sp->roll ,
rates[0], 0.0f, deltaT);
/* control yaw output */
float yaw_control = pid_calculate(&yaw_rate_controller, rate_sp->yaw, rates[2], 0.0f, deltaT); float yaw_control = pid_calculate(&yaw_rate_controller, rate_sp->yaw, rates[2], 0.0f, deltaT);
actuators->control[0] = roll_control; actuators->control[0] = roll_control;