|
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"
55 static const float phi_pgain[] = STABILIZATION_ATTITUDE_PHI_PGAIN;
56 static const float theta_pgain[] = STABILIZATION_ATTITUDE_THETA_PGAIN;
57 static const float psi_pgain[] = STABILIZATION_ATTITUDE_PSI_PGAIN;
59 static const float phi_dgain[] = STABILIZATION_ATTITUDE_PHI_DGAIN;
60 static const float theta_dgain[] = STABILIZATION_ATTITUDE_THETA_DGAIN;
61 static const float psi_dgain[] = STABILIZATION_ATTITUDE_PSI_DGAIN;
63 static const float phi_igain[] = STABILIZATION_ATTITUDE_PHI_IGAIN;
64 static const float theta_igain[] = STABILIZATION_ATTITUDE_THETA_IGAIN;
65 static const float psi_igain[] = STABILIZATION_ATTITUDE_PSI_IGAIN;
67 static const float phi_ddgain[] = STABILIZATION_ATTITUDE_PHI_DDGAIN;
68 static const float theta_ddgain[] = STABILIZATION_ATTITUDE_THETA_DDGAIN;
69 static const float psi_ddgain[] = STABILIZATION_ATTITUDE_PSI_DDGAIN;
71 static const float phi_dgain_d[] = STABILIZATION_ATTITUDE_PHI_DGAIN_D;
72 static const float theta_dgain_d[] = STABILIZATION_ATTITUDE_THETA_DGAIN_D;
73 static const float psi_dgain_d[] = STABILIZATION_ATTITUDE_PSI_DGAIN_D;
76 #if defined COMMAND_ROLL_SURFACE && defined COMMAND_PITCH_SURFACE && defined COMMAND_YAW_SURFACE
77 #define HAS_SURFACE_COMMANDS 1
80 #ifdef HAS_SURFACE_COMMANDS
81 static const float phi_pgain_surface[] = STABILIZATION_ATTITUDE_PHI_PGAIN_SURFACE;
82 static const float theta_pgain_surface[] = STABILIZATION_ATTITUDE_THETA_PGAIN_SURFACE;
83 static const float psi_pgain_surface[] = STABILIZATION_ATTITUDE_PSI_PGAIN_SURFACE;
85 static const float phi_dgain_surface[] = STABILIZATION_ATTITUDE_PHI_DGAIN_SURFACE;
86 static const float theta_dgain_surface[] = STABILIZATION_ATTITUDE_THETA_DGAIN_SURFACE;
87 static const float psi_dgain_surface[] = STABILIZATION_ATTITUDE_PSI_DGAIN_SURFACE;
89 static const float phi_igain_surface[] = STABILIZATION_ATTITUDE_PHI_IGAIN_SURFACE;
90 static const float theta_igain_surface[] = STABILIZATION_ATTITUDE_THETA_IGAIN_SURFACE;
91 static const float psi_igain_surface[] = STABILIZATION_ATTITUDE_PSI_IGAIN_SURFACE;
93 static const float phi_ddgain_surface[] = STABILIZATION_ATTITUDE_PHI_DDGAIN_SURFACE;
94 static const float theta_ddgain_surface[] = STABILIZATION_ATTITUDE_THETA_DDGAIN_SURFACE;
95 static const float psi_ddgain_surface[] = STABILIZATION_ATTITUDE_PSI_DDGAIN_SURFACE;
98 #define IERROR_SCALE 1024
100 #if PERIODIC_TELEMETRY
103 static void send_att(
struct transport_tx *trans,
struct link_device *
dev)
107 pprz_msg_send_STAB_ATTITUDE_FLOAT(trans,
dev, AC_ID,
108 &(body_rate->
p), &(body_rate->
q), &(body_rate->
r),
130 pprz_msg_send_STAB_ATTITUDE_REF_FLOAT(trans,
dev, AC_ID,
150 pprz_msg_send_AHRS_REF_QUAT(trans,
dev, AC_ID,
177 #ifdef HAS_SURFACE_COMMANDS
189 #if PERIODIC_TELEMETRY
248 #ifndef GAIN_PRESCALER_FF
249 #define GAIN_PRESCALER_FF 1
258 #ifdef HAS_SURFACE_COMMANDS
265 #ifndef GAIN_PRESCALER_P
266 #define GAIN_PRESCALER_P 1
268 #ifndef GAIN_PRESCALER_D
269 #define GAIN_PRESCALER_D 1
271 #ifndef GAIN_PRESCALER_I
272 #define GAIN_PRESCALER_I 1
278 fb_commands[COMMAND_ROLL] =
284 fb_commands[COMMAND_PITCH] =
290 fb_commands[COMMAND_YAW] =
296 #ifdef HAS_SURFACE_COMMANDS
297 fb_commands[COMMAND_ROLL_SURFACE] =
302 fb_commands[COMMAND_PITCH_SURFACE] =
307 fb_commands[COMMAND_YAW_SURFACE] =
320 static const float dt = (1./PERIODIC_FREQUENCY);
342 #define INTEGRATOR_BOUND 1.0
344 if (enable_integrator) {
365 #ifdef HAS_SURFACE_COMMANDS
382 #if USE_EARTH_BOUND_RC_SETPOINT
void stabilization_attitude_set_rpy_setpoint_i(struct Int32Eulers *rpy)
struct FloatVect3 surface_i
#define ANGLE_FLOAT_OF_BFP(_ai)
void stabilization_attitude_read_rc_setpoint_quat_earth_bound_f(struct FloatQuat *q_sp, bool in_flight, bool in_carefree, bool coordinated_turn)
static void float_quat_identity(struct FloatQuat *q)
initialises a quaternion to identity
#define FLOAT_RATES_ZERO(_r)
struct FloatAttitudeGains stabilization_gains[STABILIZATION_ATTITUDE_GAIN_NB]
void stabilization_attitude_init(void)
stabilization_attitude_init
static const float phi_ddgain[]
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
#define FLOAT_EULERS_ZERO(_e)
struct FloatRates last_body_rate
static const float theta_dgain[]
struct FloatQuat stab_att_sp_quat
with INT32_QUAT_FRAC
static void attitude_run_fb(float fb_commands[], struct FloatAttitudeGains *gains, struct FloatQuat *att_err, struct FloatRates *rate_err, struct FloatRates *rate_err_d, struct FloatQuat *sum_err)
Paparazzi floating point algebra.
static const float theta_pgain[]
static const float phi_dgain_d[]
void stabilization_attitude_read_rc(bool in_flight, bool in_carefree, bool coordinated_turn)
void attitude_ref_quat_float_init(struct AttRefQuatFloat *ref)
#define STABILIZATION_ATTITUDE_GAIN_IDX_DEFAULT
void stabilization_attitude_enter(void)
Paparazzi fixed point algebra.
float stabilization_attitude_get_heading_f(void)
static const float phi_pgain[]
void float_quat_inv_comp(struct FloatQuat *b2c, struct FloatQuat *a2b, struct FloatQuat *a2c)
Composition (multiplication) of two quaternions.
static const float psi_igain[]
void attitude_ref_quat_float_update(struct AttRefQuatFloat *ref, struct FloatQuat *sp_quat, float dt)
#define RATES_DIFF(_c, _a, _b)
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
static const struct usb_device_descriptor dev
static void send_att(struct transport_tx *trans, struct link_device *dev)
#define GAIN_PRESCALER_FF
struct FloatVect3 surface_dd
float stabilization_att_fb_cmd[COMMANDS_NB]
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
float stabilization_att_ff_cmd[COMMANDS_NB]
#define QUAT_BFP_OF_REAL(_qi, _qf)
#define EULERS_FLOAT_OF_BFP(_ef, _ei)
struct FloatEulers stab_att_sp_euler
with INT32_ANGLE_FRAC
#define STABILIZATION_ATTITUDE_GAIN_NB
Attitude reference models and state/output (float)
static void send_att_ref(struct transport_tx *trans, struct link_device *dev)
static const float theta_ddgain[]
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.
static void float_quat_wrap_shortest(struct FloatQuat *q)
void stabilization_attitude_run(bool enable_integrator)
void attitude_ref_quat_float_schedule(struct AttRefQuatFloat *ref, uint8_t idx)
static const float phi_igain[]
void attitude_ref_quat_float_enter(struct AttRefQuatFloat *ref, struct FloatQuat *state_quat)
static const float theta_dgain_d[]
static const float psi_pgain[]
struct FloatVect3 rates_d
void stabilization_attitude_gain_schedule(uint8_t idx)
static const float theta_igain[]
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
struct FloatQuat stabilization_att_sum_err_quat
void stabilization_attitude_set_failsafe_setpoint(void)
void stabilization_attitude_set_earth_cmd_i(struct Int32Vect2 *cmd, int32_t heading)
static const float phi_dgain[]
static void send_ahrs_ref_quat(struct transport_tx *trans, struct link_device *dev)
struct FloatVect3 surface_d
static const float psi_dgain_d[]
#define VECT3_ASSIGN(_a, _x, _y, _z)
struct FloatVect3 surface_p
static const float psi_dgain[]
#define RATES_COPY(_a, _b)
#define DefaultPeriodic
Set default periodic telemetry.
static void attitude_run_ff(float ff_commands[], struct FloatAttitudeGains *gains, struct FloatRates *ref_accel)
struct FloatRates body_rate_d
struct AttRefQuatFloat att_ref_quat_f
void float_quat_of_eulers(struct FloatQuat *q, struct FloatEulers *e)
quat of euler roation 'ZYX'
static const float psi_ddgain[]