28 #include "generated/airframe.h"
39 #ifndef USE_ATTITUDE_REF
40 #define USE_ATTITUDE_REF 1
44 #ifndef STABILIZATION_ATTITUDE_PHI_FFDGAIN
45 #define STABILIZATION_ATTITUDE_PHI_FFDGAIN 0
47 #ifndef STABILIZATION_ATTITUDE_THETA_FFDGAIN
48 #define STABILIZATION_ATTITUDE_THETA_FFDGAIN 0
50 #ifndef STABILIZATION_ATTITUDE_PSI_FFDGAIN
51 #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!!!"
85 #if PERIODIC_TELEMETRY
88 static void send_att(
struct transport_tx *trans,
struct link_device *
dev)
92 pprz_msg_send_STAB_ATTITUDE_INT(trans, dev, AC_ID,
93 &(body_rate->
p), &(body_rate->
q), &(body_rate->
r),
114 pprz_msg_send_STAB_ATTITUDE_REF_INT(trans, dev, AC_ID,
139 STABILIZATION_ATTITUDE_PHI_PGAIN,
140 STABILIZATION_ATTITUDE_THETA_PGAIN,
141 STABILIZATION_ATTITUDE_PSI_PGAIN);
144 STABILIZATION_ATTITUDE_PHI_DGAIN,
145 STABILIZATION_ATTITUDE_THETA_DGAIN,
146 STABILIZATION_ATTITUDE_PSI_DGAIN);
149 STABILIZATION_ATTITUDE_PHI_IGAIN,
150 STABILIZATION_ATTITUDE_THETA_IGAIN,
151 STABILIZATION_ATTITUDE_PSI_IGAIN);
154 STABILIZATION_ATTITUDE_PHI_DDGAIN,
155 STABILIZATION_ATTITUDE_THETA_DDGAIN,
156 STABILIZATION_ATTITUDE_PSI_DDGAIN);
165 #if PERIODIC_TELEMETRY
207 #define OFFSET_AND_ROUND(_a, _b) (((_a)+(1<<((_b)-1)))>>(_b))
208 #define OFFSET_AND_ROUND2(_a, _b) (((_a)+(1<<((_b)-1))-((_a)<0?1:0))>>(_b))
210 #define MAX_SUM_ERR 4000000
256 EULERS_DIFF(att_err, att_ref_scaled, (*ltp_to_body_euler));
270 RATES_DIFF(rate_err, rate_ref_scaled, (*body_rate));
int32_t psi
in rad with INT32_ANGLE_FRAC
int32_t stabilization_att_fb_cmd[COMMANDS_NB]
void stabilization_attitude_enter(void)
struct AttRefEulerInt att_ref_euler_i
Periodic telemetry system header (includes downlink utility and generated code).
General attitude stabilization interface for rotorcrafts.
#define STABILIZATION_ATTITUDE_PSI_FFDGAIN
static void send_att_ref(struct transport_tx *trans, struct link_device *dev)
int32_t theta
in rad with INT32_ANGLE_FRAC
#define INT_RATES_ZERO(_e)
void stabilization_attitude_run(bool in_flight)
#define OFFSET_AND_ROUND(_a, _b)
#define VECT3_ASSIGN(_a, _x, _y, _z)
Read an attitude setpoint from the RC.
struct Int32Rates rate
with REF_RATE_FRAC
struct Int32AttitudeGains stabilization_gains
void stabilization_attitude_read_rc(bool in_flight, bool in_carefree, bool coordinated_turn)
#define RATES_DIFF(_c, _a, _b)
#define EULERS_BOUND_CUBE(_v, _min, _max)
Attitude reference models and state/output (euler int)
void stabilization_attitude_set_failsafe_setpoint(void)
#define INT32_EULERS_LSHIFT(_o, _i, _r)
int32_t r
in rad/s with INT32_RATE_FRAC
#define PPRZ_ITRIG_SIN(_s, _a)
static void reset_psi_ref_from_body(void)
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
void stabilization_attitude_init(void)
#define STABILIZATION_ATTITUDE_THETA_FFDGAIN
#define INT32_ANGLE_NORMALIZE(_a)
#define OFFSET_AND_ROUND2(_a, _b)
struct Int32Eulers stabilization_att_sum_err
#define DefaultPeriodic
Set default periodic telemetry.
void attitude_ref_euler_int_init(struct AttRefEulerInt *ref)
void attitude_ref_euler_int_update(struct AttRefEulerInt *ref, struct Int32Eulers *sp_euler)
Propagate reference model.
int32_t stabilization_att_ff_cmd[COMMANDS_NB]
static const struct usb_device_descriptor dev
#define STABILIZATION_ATTITUDE_PHI_FFDGAIN
explicitly define to zero to disable feed-forward rate term by default
void stabilization_attitude_set_rpy_setpoint_i(struct Int32Eulers *rpy)
struct Int32Rates accel
with REF_ACCEL_FRAC
int32_t phi
in rad with INT32_ANGLE_FRAC
#define INT_EULERS_ZERO(_e)
API to get/set the generic vehicle states.
struct Int32Eulers euler
with REF_ANGLE_FRAC
#define EULERS_DIFF(_c, _a, _b)
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
int32_t p
in rad/s with INT32_RATE_FRAC
void stabilization_attitude_read_rc_setpoint_eulers(struct Int32Eulers *sp, bool in_flight, bool in_carefree, bool coordinated_turn)
Read attitude setpoint from RC as euler angles.
#define EULERS_ADD(_a, _b)
static void send_att(struct transport_tx *trans, struct link_device *dev)
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
int32_t q
in rad/s with INT32_RATE_FRAC
void stabilization_attitude_set_earth_cmd_i(struct Int32Vect2 *cmd, int32_t heading)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
#define PPRZ_ITRIG_COS(_c, _a)
Paparazzi fixed point algebra.
struct Int32Eulers stab_att_sp_euler
with INT32_ANGLE_FRAC