26#include "generated/airframe.h"
38#ifndef STABILIZATION_ATTITUDE_PHI_FFDGAIN
39#define STABILIZATION_ATTITUDE_PHI_FFDGAIN 0
41#ifndef STABILIZATION_ATTITUDE_THETA_FFDGAIN
42#define STABILIZATION_ATTITUDE_THETA_FFDGAIN 0
44#ifndef STABILIZATION_ATTITUDE_PSI_FFDGAIN
45#define STABILIZATION_ATTITUDE_PSI_FFDGAIN 0
57#if (STABILIZATION_ATTITUDE_PHI_PGAIN < 0) || \
58 (STABILIZATION_ATTITUDE_THETA_PGAIN < 0) || \
59 (STABILIZATION_ATTITUDE_PSI_PGAIN < 0) || \
60 (STABILIZATION_ATTITUDE_PHI_DGAIN < 0) || \
61 (STABILIZATION_ATTITUDE_THETA_DGAIN < 0) || \
62 (STABILIZATION_ATTITUDE_PSI_DGAIN < 0) || \
63 (STABILIZATION_ATTITUDE_PHI_IGAIN < 0) || \
64 (STABILIZATION_ATTITUDE_THETA_IGAIN < 0) || \
65 (STABILIZATION_ATTITUDE_PSI_IGAIN < 0)
66#error "ALL control gains have to be positive!!!"
79#define IERROR_SCALE 128
80#define GAIN_PRESCALER_FF 48
81#define GAIN_PRESCALER_P 12
82#define GAIN_PRESCALER_D 3
83#define GAIN_PRESCALER_I 3
93 &(body_rate->
p), &(body_rate->
q), &(body_rate->
r),
152#if PERIODIC_TELEMETRY
167#define OFFSET_AND_ROUND(_a, _b) (((_a)+(1<<((_b)-1)))>>(_b))
168#define OFFSET_AND_ROUND2(_a, _b) (((_a)+(1<<((_b)-1))-((_a)<0?1:0))>>(_b))
235#define INTEGRATOR_BOUND 100000
#define RATES_DIFF(_c, _a, _b)
int32_t p
in rad/s with INT32_RATE_FRAC
int32_t r
in rad/s with INT32_RATE_FRAC
int32_t phi
in rad with INT32_ANGLE_FRAC
int32_t q
in rad/s with INT32_RATE_FRAC
int32_t psi
in rad with INT32_ANGLE_FRAC
int32_t theta
in rad with INT32_ANGLE_FRAC
static void int32_quat_normalize(struct Int32Quat *q)
normalize a quaternion inplace
#define QUAT1_FLOAT_OF_BFP(_qi)
static void int32_quat_identity(struct Int32Quat *q)
initialises a quaternion to identity
#define RATE_FLOAT_OF_BFP(_ai)
static void int32_quat_wrap_shortest(struct Int32Quat *q)
#define INT32_EULERS_LSHIFT(_o, _i, _r)
void int32_quat_inv_comp(struct Int32Quat *b2c, struct Int32Quat *a2b, struct Int32Quat *a2c)
Composition (multiplication) of two quaternions.
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
float gains[MAX_SAMPLES_LEARNING]
Paparazzi floating point algebra.
Paparazzi fixed point algebra.
struct Stabilization stabilization
struct Int32Quat stab_sp_to_quat_i(struct StabilizationSetpoint *sp)
struct Int32Eulers stab_sp_to_eulers_i(struct StabilizationSetpoint *sp)
int32_t th_sp_to_thrust_i(struct ThrustSetpoint *th, int32_t thrust, uint8_t axis)
int32_t cmd[COMMANDS_NB]
output command vector, range from [-MAX_PPRZ:MAX_PPRZ] (store for messages)
static void send_ahrs_ref_quat(struct transport_tx *trans, struct link_device *dev)
void stabilization_attitude_enter(void)
Attitude control enter function.
void stabilization_attitude_quat_int_init(void)
int32_t stabilization_att_ff_cmd[COMMANDS_NB]
void stabilization_attitude_run(bool enable_integrator, struct StabilizationSetpoint *sp, struct ThrustSetpoint *thrust, int32_t *cmd)
Attitude control run function.
static void send_att_ref(struct transport_tx *trans, struct link_device *dev)
#define STABILIZATION_ATTITUDE_PSI_FFDGAIN
#define OFFSET_AND_ROUND(_a, _b)
static struct Int32Eulers stab_att_sp_euler
static void attitude_run_fb(int32_t fb_commands[], struct Int32AttitudeGains *gains, struct Int32Quat *att_err, struct Int32Rates *rate_err, struct Int32Quat *sum_err)
struct Int32AttitudeGains stabilization_gains
static void attitude_run_ff(int32_t ff_commands[], struct Int32AttitudeGains *gains, struct Int32Rates *ref_accel)
int32_t stabilization_att_fb_cmd[COMMANDS_NB]
#define GAIN_PRESCALER_FF
#define STABILIZATION_ATTITUDE_THETA_FFDGAIN
#define STABILIZATION_ATTITUDE_PHI_FFDGAIN
explicitly define to zero to disable feed-forward rate term by default
struct AttRefQuatInt att_ref_quat_i
static struct Int32Quat stab_att_sp_quat
static void send_att(struct transport_tx *trans, struct link_device *dev)
struct Int32Quat stabilization_att_sum_err_quat
void attitude_ref_quat_int_update(struct AttRefQuatInt *ref, struct Int32Quat *sp_quat, float dt)
Propagate reference.
void attitude_ref_quat_int_enter(struct AttRefQuatInt *ref, struct Int32Quat *state_quat)
void attitude_ref_quat_int_init(struct AttRefQuatInt *ref)
struct Int32Rates rate
with REF_RATE_FRAC
struct Int32Eulers euler
with INT32_ANGLE_FRAC
struct Int32Rates accel
with REF_ACCEL_FRAC
Attitude reference models and state/output (quat int)
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
Thrust setpoint // TODO to a setpoint header Structure to store the desired thrust vector with differ...
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
int int32_t
Typedef defining 32 bit int type.