28 #include "generated/airframe.h"
39 #ifndef USE_ATTITUDE_REF
40 #define USE_ATTITUDE_REF 1
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!!!"
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),
103 pprz_msg_send_STAB_ATTITUDE_REF_INT(trans, dev, AC_ID,
128 STABILIZATION_ATTITUDE_PHI_PGAIN,
129 STABILIZATION_ATTITUDE_THETA_PGAIN,
130 STABILIZATION_ATTITUDE_PSI_PGAIN);
133 STABILIZATION_ATTITUDE_PHI_DGAIN,
134 STABILIZATION_ATTITUDE_THETA_DGAIN,
135 STABILIZATION_ATTITUDE_PSI_DGAIN);
138 STABILIZATION_ATTITUDE_PHI_IGAIN,
139 STABILIZATION_ATTITUDE_THETA_IGAIN,
140 STABILIZATION_ATTITUDE_PSI_IGAIN);
143 STABILIZATION_ATTITUDE_PHI_DDGAIN,
144 STABILIZATION_ATTITUDE_THETA_DDGAIN,
145 STABILIZATION_ATTITUDE_PSI_DDGAIN);
150 #if PERIODIC_TELEMETRY
192 #define OFFSET_AND_ROUND(_a, _b) (((_a)+(1<<((_b)-1)))>>(_b))
193 #define OFFSET_AND_ROUND2(_a, _b) (((_a)+(1<<((_b)-1))-((_a)<0?1:0))>>(_b))
195 #define MAX_SUM_ERR 4000000
226 EULERS_DIFF(att_err, att_ref_scaled, (*ltp_to_body_euler));
245 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
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
#define INT_RATES_ZERO(_e)
#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_setpoint_eulers(struct Int32Eulers *sp, bool_t in_flight, bool_t in_carefree, bool_t coordinated_turn)
Read attitude setpoint from RC as euler angles.
#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 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
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)
void stabilization_attitude_run(bool_t in_flight)
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
int32_t p
in rad/s with INT32_RATE_FRAC
#define EULERS_ADD(_a, _b)
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)
void stabilization_attitude_read_rc(bool_t in_flight, bool_t in_carefree, bool_t coordinated_turn)
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