29 #include "generated/airframe.h"
40 #define MAX_SUM_ERR 4000000
42 #ifndef STABILIZATION_RATE_IGAIN_P
43 #define STABILIZATION_RATE_IGAIN_P 0
46 #ifndef STABILIZATION_RATE_IGAIN_Q
47 #define STABILIZATION_RATE_IGAIN_Q 0
50 #ifndef STABILIZATION_RATE_IGAIN_R
51 #define STABILIZATION_RATE_IGAIN_R 0
54 #if (STABILIZATION_RATE_GAIN_P < 0) || \
55 (STABILIZATION_RATE_GAIN_Q < 0) || \
56 (STABILIZATION_RATE_GAIN_R < 0) || \
57 (STABILIZATION_RATE_IGAIN_P < 0) || \
58 (STABILIZATION_RATE_IGAIN_Q < 0) || \
59 (STABILIZATION_RATE_IGAIN_R < 0)
60 #error "ALL control gains have to be positive!!!"
63 #define OFFSET_AND_ROUND(_a, _b) (((_a)+(1<<((_b)-1)))>>(_b))
64 #define OFFSET_AND_ROUND2(_a, _b) (((_a)+(1<<((_b)-1))-((_a)<0?1:0))>>(_b))
73 #ifndef STABILIZATION_RATE_DEADBAND_P
74 #define STABILIZATION_RATE_DEADBAND_P 0
76 #ifndef STABILIZATION_RATE_DEADBAND_Q
77 #define STABILIZATION_RATE_DEADBAND_Q 0
79 #ifndef STABILIZATION_RATE_DEADBAND_R
80 #define STABILIZATION_RATE_DEADBAND_R 200
83 #define ROLL_RATE_DEADBAND_EXCEEDED() \
84 (radio_control.values[RADIO_ROLL] > STABILIZATION_RATE_DEADBAND_P || \
85 radio_control.values[RADIO_ROLL] < -STABILIZATION_RATE_DEADBAND_P)
87 #define PITCH_RATE_DEADBAND_EXCEEDED() \
88 (radio_control.values[RADIO_PITCH] > STABILIZATION_RATE_DEADBAND_Q || \
89 radio_control.values[RADIO_PITCH] < -STABILIZATION_RATE_DEADBAND_Q)
91 #define YAW_RATE_DEADBAND_EXCEEDED() \
92 (radio_control.values[RADIO_YAW] > STABILIZATION_RATE_DEADBAND_R || \
93 radio_control.values[RADIO_YAW] < -STABILIZATION_RATE_DEADBAND_R)
95 #if PERIODIC_TELEMETRY
100 pprz_msg_send_RATE_LOOP(trans, dev, AC_ID,
120 STABILIZATION_RATE_GAIN_P,
121 STABILIZATION_RATE_GAIN_Q,
122 STABILIZATION_RATE_GAIN_R);
130 #if PERIODIC_TELEMETRY
#define STABILIZATION_RATE_IGAIN_R
void stabilization_rate_run(bool_t in_flight)
Generic transmission transport header.
#define RATES_ADD(_a, _b)
Periodic telemetry system header (includes downlink utility and generated code).
struct Int32Rates stabilization_rate_sum_err
void stabilization_rate_enter(void)
#define INT_RATES_ZERO(_e)
struct Int32Rates stabilization_rate_gain
#define RATES_ASSIGN(_ra, _p, _q, _r)
#define OFFSET_AND_ROUND2(_a, _b)
#define YAW_RATE_DEADBAND_EXCEEDED()
struct Int32Rates stabilization_rate_igain
#define RATES_DIFF(_c, _a, _b)
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define THROTTLE_STICK_DOWN()
Rate stabilization for rotorcrafts.
int32_t r
in rad/s with INT32_RATE_FRAC
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
#define RATES_BOUND_CUBE(_v, _min, _max)
#define STABILIZATION_RATE_IGAIN_P
void stabilization_rate_read_rc(void)
void stabilization_rate_read_rc_switched_sticks(void)
#define DefaultPeriodic
Set default periodic telemetry.
struct RadioControl radio_control
Inertial Measurement Unit interface.
#define STABILIZATION_RATE_IGAIN_Q
#define PITCH_RATE_DEADBAND_EXCEEDED()
Some helper functions to check RC sticks.
static const struct usb_device_descriptor dev
API to get/set the generic vehicle states.
General stabilization interface for rotorcrafts.
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
int32_t p
in rad/s with INT32_RATE_FRAC
struct Int32Rates stabilization_rate_fb_cmd
void stabilization_rate_init(void)
#define ROLL_RATE_DEADBAND_EXCEEDED()
struct Int32Rates stabilization_rate_sp
int32_t q
in rad/s with INT32_RATE_FRAC
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
#define RATE_BFP_OF_REAL(_af)