26 #include "generated/airframe.h"
39 {STABILIZATION_ATTITUDE_PHI_PGAIN, STABILIZATION_ATTITUDE_THETA_PGAIN, STABILIZATION_ATTITUDE_PSI_PGAIN },
40 {STABILIZATION_ATTITUDE_PHI_DGAIN, STABILIZATION_ATTITUDE_THETA_DGAIN, STABILIZATION_ATTITUDE_PSI_DGAIN },
41 {STABILIZATION_ATTITUDE_PHI_DDGAIN, STABILIZATION_ATTITUDE_THETA_DDGAIN, STABILIZATION_ATTITUDE_PSI_DDGAIN },
42 {STABILIZATION_ATTITUDE_PHI_IGAIN, STABILIZATION_ATTITUDE_THETA_IGAIN, STABILIZATION_ATTITUDE_PSI_IGAIN }
46 #if (STABILIZATION_ATTITUDE_PHI_PGAIN < 0) || \
47 (STABILIZATION_ATTITUDE_THETA_PGAIN < 0) || \
48 (STABILIZATION_ATTITUDE_PSI_PGAIN < 0) || \
49 (STABILIZATION_ATTITUDE_PHI_DGAIN < 0) || \
50 (STABILIZATION_ATTITUDE_THETA_DGAIN < 0) || \
51 (STABILIZATION_ATTITUDE_PSI_DGAIN < 0) || \
52 (STABILIZATION_ATTITUDE_PHI_IGAIN < 0) || \
53 (STABILIZATION_ATTITUDE_THETA_IGAIN < 0) || \
54 (STABILIZATION_ATTITUDE_PSI_IGAIN < 0)
55 #error "ALL control gains have to be positive!!!"
68 #define IERROR_SCALE 128
69 #define GAIN_PRESCALER_FF 48
70 #define GAIN_PRESCALER_P 12
71 #define GAIN_PRESCALER_D 3
72 #define GAIN_PRESCALER_I 3
74 #if PERIODIC_TELEMETRY
81 pprz_msg_send_STAB_ATTITUDE_INT(trans, dev, AC_ID,
82 &(body_rate->
p), &(body_rate->
q), &(body_rate->
r),
106 pprz_msg_send_STAB_ATTITUDE_REF_INT(trans, dev, AC_ID,
124 pprz_msg_send_AHRS_REF_QUAT(trans, dev, AC_ID,
143 #if PERIODIC_TELEMETRY
197 #define OFFSET_AND_ROUND(_a, _b) (((_a)+(1<<((_b)-1)))>>(_b))
198 #define OFFSET_AND_ROUND2(_a, _b) (((_a)+(1<<((_b)-1))-((_a)<0?1:0))>>(_b))
213 fb_commands[COMMAND_ROLL] =
218 fb_commands[COMMAND_PITCH] =
223 fb_commands[COMMAND_YAW] =
261 RATES_DIFF(rate_err, rate_ref_scaled, (*body_rate));
263 #define INTEGRATOR_BOUND 100000
265 if (enable_integrator) {
297 #if USE_EARTH_BOUND_RC_SETPOINT
int32_t psi
in rad with INT32_ANGLE_FRAC
void stabilization_attitude_read_rc(bool_t in_flight, bool_t in_carefree, bool_t coordinated_turn)
struct Int32Quat stab_att_sp_quat
with INT32_QUAT_FRAC
void attitude_ref_quat_int_init(struct AttRefQuatInt *ref)
int32_t stabilization_att_fb_cmd[COMMANDS_NB]
struct Int32Rates rate
with REF_RATE_FRAC
static void int32_quat_normalize(struct Int32Quat *q)
normalize a quaternion inplace
Generic transmission transport header.
Periodic telemetry system header (includes downlink utility and generated code).
General attitude stabilization interface for rotorcrafts.
int32_t theta
in rad with INT32_ANGLE_FRAC
void int32_quat_of_eulers(struct Int32Quat *q, struct Int32Eulers *e)
Quaternion from Euler angles.
void stabilization_attitude_set_failsafe_setpoint(void)
int32_t stabilization_attitude_get_heading_i(void)
Read an attitude setpoint from the RC.
void stabilization_attitude_init(void)
#define OFFSET_AND_ROUND(_a, _b)
void attitude_ref_quat_int_enter(struct AttRefQuatInt *ref, int32_t psi)
#define RATES_DIFF(_c, _a, _b)
void stabilization_attitude_run(bool_t enable_integrator)
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
#define INT32_EULERS_LSHIFT(_o, _i, _r)
int32_t r
in rad/s with INT32_RATE_FRAC
#define PPRZ_ITRIG_SIN(_s, _a)
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
Paparazzi floating point algebra.
#define INT32_QUAT_INV_COMP(_b2c, _a2b, _a2c)
static void attitude_run_fb(int32_t fb_commands[], struct Int32AttitudeGains *gains, struct Int32Quat *att_err, struct Int32Rates *rate_err, struct Int32Quat *sum_err)
#define QUAT_BFP_OF_REAL(_qi, _qf)
struct Int32AttitudeGains stabilization_gains
void attitude_ref_quat_int_update(struct AttRefQuatInt *ref, struct Int32Quat *sp_quat, float dt)
Propagate reference.
#define DefaultPeriodic
Set default periodic telemetry.
static void int32_quat_identity(struct Int32Quat *q)
initialises a quaternion to identity
#define RATE_FLOAT_OF_BFP(_ai)
struct Int32Eulers euler
with INT32_ANGLE_FRAC
#define QUAT1_FLOAT_OF_BFP(_qi)
static const struct usb_device_descriptor dev
int32_t stabilization_att_ff_cmd[COMMANDS_NB]
#define GAIN_PRESCALER_FF
int32_t phi
in rad with INT32_ANGLE_FRAC
API to get/set the generic vehicle states.
Attitude reference models and state/output (quat int)
static void attitude_run_ff(int32_t ff_commands[], struct Int32AttitudeGains *gains, struct Int32Rates *ref_accel)
void stabilization_attitude_read_rc_setpoint_quat_f(struct FloatQuat *q_sp, bool_t in_flight, bool_t in_carefree, bool_t coordinated_turn)
Read attitude setpoint from RC as quaternion Interprets the stick positions as axes.
struct AttRefQuatInt att_ref_quat_i
static void int32_quat_wrap_shortest(struct Int32Quat *q)
struct Int32Rates accel
with REF_ACCEL_FRAC
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
void stabilization_attitude_enter(void)
int32_t p
in rad/s with INT32_RATE_FRAC
#define PERIODIC_FREQUENCY
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
void stabilization_attitude_read_rc_setpoint_quat_earth_bound_f(struct FloatQuat *q_sp, bool_t in_flight, bool_t in_carefree, bool_t coordinated_turn)
void stabilization_attitude_set_rpy_setpoint_i(struct Int32Eulers *rpy)
struct Int32Eulers stab_att_sp_euler
with INT32_ANGLE_FRAC
int32_t q
in rad/s with INT32_RATE_FRAC
struct Int32Quat stabilization_att_sum_err_quat
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
void stabilization_attitude_set_earth_cmd_i(struct Int32Vect2 *cmd, int32_t heading)
#define PPRZ_ITRIG_COS(_c, _a)
Paparazzi fixed point algebra.