|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
26 #include "generated/airframe.h"
39 #ifndef STABILIZATION_ATTITUDE_PHI_FFDGAIN
40 #define STABILIZATION_ATTITUDE_PHI_FFDGAIN 0
42 #ifndef STABILIZATION_ATTITUDE_THETA_FFDGAIN
43 #define STABILIZATION_ATTITUDE_THETA_FFDGAIN 0
45 #ifndef STABILIZATION_ATTITUDE_PSI_FFDGAIN
46 #define STABILIZATION_ATTITUDE_PSI_FFDGAIN 0
50 {STABILIZATION_ATTITUDE_PHI_PGAIN, STABILIZATION_ATTITUDE_THETA_PGAIN, STABILIZATION_ATTITUDE_PSI_PGAIN },
51 {STABILIZATION_ATTITUDE_PHI_DGAIN, STABILIZATION_ATTITUDE_THETA_DGAIN, STABILIZATION_ATTITUDE_PSI_DGAIN },
52 {STABILIZATION_ATTITUDE_PHI_DDGAIN, STABILIZATION_ATTITUDE_THETA_DDGAIN, STABILIZATION_ATTITUDE_PSI_DDGAIN },
53 {STABILIZATION_ATTITUDE_PHI_IGAIN, STABILIZATION_ATTITUDE_THETA_IGAIN, STABILIZATION_ATTITUDE_PSI_IGAIN },
58 #if (STABILIZATION_ATTITUDE_PHI_PGAIN < 0) || \
59 (STABILIZATION_ATTITUDE_THETA_PGAIN < 0) || \
60 (STABILIZATION_ATTITUDE_PSI_PGAIN < 0) || \
61 (STABILIZATION_ATTITUDE_PHI_DGAIN < 0) || \
62 (STABILIZATION_ATTITUDE_THETA_DGAIN < 0) || \
63 (STABILIZATION_ATTITUDE_PSI_DGAIN < 0) || \
64 (STABILIZATION_ATTITUDE_PHI_IGAIN < 0) || \
65 (STABILIZATION_ATTITUDE_THETA_IGAIN < 0) || \
66 (STABILIZATION_ATTITUDE_PSI_IGAIN < 0)
67 #error "ALL control gains have to be positive!!!"
80 #define IERROR_SCALE 128
81 #define GAIN_PRESCALER_FF 48
82 #define GAIN_PRESCALER_P 12
83 #define GAIN_PRESCALER_D 3
84 #define GAIN_PRESCALER_I 3
86 #if PERIODIC_TELEMETRY
89 static void send_att(
struct transport_tx *trans,
struct link_device *
dev)
93 pprz_msg_send_STAB_ATTITUDE_INT(trans,
dev, AC_ID,
94 &(body_rate->
p), &(body_rate->
q), &(body_rate->
r),
118 pprz_msg_send_STAB_ATTITUDE_REF_INT(trans,
dev, AC_ID,
136 pprz_msg_send_AHRS_REF_QUAT(trans,
dev, AC_ID,
155 #if PERIODIC_TELEMETRY
211 #define OFFSET_AND_ROUND(_a, _b) (((_a)+(1<<((_b)-1)))>>(_b))
212 #define OFFSET_AND_ROUND2(_a, _b) (((_a)+(1<<((_b)-1))-((_a)<0?1:0))>>(_b))
227 fb_commands[COMMAND_ROLL] =
232 fb_commands[COMMAND_PITCH] =
237 fb_commands[COMMAND_YAW] =
252 static const float dt = (1./PERIODIC_FREQUENCY);
275 RATES_DIFF(rate_err, rate_ref_scaled, (*body_rate));
277 #define INTEGRATOR_BOUND 100000
279 if (enable_integrator) {
311 #if USE_EARTH_BOUND_RC_SETPOINT
void int32_quat_of_eulers(struct Int32Quat *q, struct Int32Eulers *e)
Quaternion from Euler angles.
#define GAIN_PRESCALER_FF
int32_t theta
in rad with INT32_ANGLE_FRAC
int32_t stabilization_att_ff_cmd[COMMANDS_NB]
void stabilization_attitude_enter(void)
struct Int32Eulers euler
with INT32_ANGLE_FRAC
struct Int32Eulers stab_att_sp_euler
with INT32_ANGLE_FRAC
void stabilization_attitude_read_rc_setpoint_quat_earth_bound_f(struct FloatQuat *q_sp, bool in_flight, bool in_carefree, bool coordinated_turn)
#define INT32_EULERS_LSHIFT(_o, _i, _r)
struct Int32AttitudeGains stabilization_gains
void stabilization_attitude_init(void)
stabilization_attitude_init
#define STABILIZATION_ATTITUDE_PHI_FFDGAIN
explicitly define to zero to disable feed-forward rate term by default
int32_t q
in rad/s with INT32_RATE_FRAC
void attitude_ref_quat_int_enter(struct AttRefQuatInt *ref, struct Int32Quat *state_quat)
static void attitude_run_fb(int32_t fb_commands[], struct Int32AttitudeGains *gains, struct Int32Quat *att_err, struct Int32Rates *rate_err, struct Int32Quat *sum_err)
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
#define PPRZ_ITRIG_COS(_c, _a)
static void send_att(struct transport_tx *trans, struct link_device *dev)
static void int32_quat_normalize(struct Int32Quat *q)
normalize a quaternion inplace
Paparazzi floating point algebra.
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
void stabilization_attitude_set_failsafe_setpoint(void)
void int32_quat_inv_comp(struct Int32Quat *b2c, struct Int32Quat *a2b, struct Int32Quat *a2c)
Composition (multiplication) of two quaternions.
int32_t stabilization_attitude_get_heading_i(void)
Paparazzi fixed point algebra.
static void int32_quat_wrap_shortest(struct Int32Quat *q)
void attitude_ref_quat_int_init(struct AttRefQuatInt *ref)
int32_t p
in rad/s with INT32_RATE_FRAC
struct Int32Rates rate
with REF_RATE_FRAC
static void send_att_ref(struct transport_tx *trans, struct link_device *dev)
int32_t psi
in rad with INT32_ANGLE_FRAC
int32_t phi
in rad with INT32_ANGLE_FRAC
void stabilization_attitude_run(bool enable_integrator)
#define RATES_DIFF(_c, _a, _b)
static void attitude_run_ff(int32_t ff_commands[], struct Int32AttitudeGains *gains, struct Int32Rates *ref_accel)
static const struct usb_device_descriptor dev
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
#define OFFSET_AND_ROUND(_a, _b)
void stabilization_attitude_set_rpy_setpoint_i(struct Int32Eulers *rpy)
#define QUAT_BFP_OF_REAL(_qi, _qf)
struct Int32Quat stabilization_att_sum_err_quat
#define STABILIZATION_ATTITUDE_PSI_FFDGAIN
#define QUAT1_FLOAT_OF_BFP(_qi)
static void send_ahrs_ref_quat(struct transport_tx *trans, struct link_device *dev)
void stabilization_attitude_read_rc_setpoint_quat_f(struct FloatQuat *q_sp, bool in_flight, bool in_carefree, bool coordinated_turn)
Read attitude setpoint from RC as quaternion Interprets the stick positions as axes.
void stabilization_attitude_set_earth_cmd_i(struct Int32Vect2 *cmd, int32_t heading)
void stabilization_attitude_read_rc(bool in_flight, bool in_carefree, bool coordinated_turn)
Attitude reference models and state/output (quat int)
struct Int32Rates accel
with REF_ACCEL_FRAC
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
int32_t stabilization_att_fb_cmd[COMMANDS_NB]
#define STABILIZATION_ATTITUDE_THETA_FFDGAIN
struct Int32Quat stab_att_sp_quat
with INT32_QUAT_FRAC
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
static void int32_quat_identity(struct Int32Quat *q)
initialises a quaternion to identity
#define RATE_FLOAT_OF_BFP(_ai)
struct AttRefQuatInt att_ref_quat_i
int32_t r
in rad/s with INT32_RATE_FRAC
#define DefaultPeriodic
Set default periodic telemetry.
void attitude_ref_quat_int_update(struct AttRefQuatInt *ref, struct Int32Quat *sp_quat, float dt)
Propagate reference.
#define PPRZ_ITRIG_SIN(_s, _a)