29 #include "generated/airframe.h"
40 #define MAX_SUM_ERR 40000
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!!!"
64 #define OFFSET_AND_ROUND(_a, _b) (((_a)+(1<<((_b)-1)))>>(_b))
65 #define OFFSET_AND_ROUND2(_a, _b) (((_a)+(1<<((_b)-1))-((_a)<0?1:0))>>(_b))
74 #ifndef STABILIZATION_RATE_DEADBAND_P
75 #define STABILIZATION_RATE_DEADBAND_P 0
77 #ifndef STABILIZATION_RATE_DEADBAND_Q
78 #define STABILIZATION_RATE_DEADBAND_Q 0
80 #ifndef STABILIZATION_RATE_DEADBAND_R
81 #define STABILIZATION_RATE_DEADBAND_R 200
84 #define ROLL_RATE_DEADBAND_EXCEEDED() \
85 (radio_control.values[RADIO_ROLL] > STABILIZATION_RATE_DEADBAND_P || \
86 radio_control.values[RADIO_ROLL] < -STABILIZATION_RATE_DEADBAND_P)
88 #define PITCH_RATE_DEADBAND_EXCEEDED() \
89 (radio_control.values[RADIO_PITCH] > STABILIZATION_RATE_DEADBAND_Q || \
90 radio_control.values[RADIO_PITCH] < -STABILIZATION_RATE_DEADBAND_Q)
92 #define YAW_RATE_DEADBAND_EXCEEDED() \
93 (radio_control.values[RADIO_YAW] > STABILIZATION_RATE_DEADBAND_R || \
94 radio_control.values[RADIO_YAW] < -STABILIZATION_RATE_DEADBAND_R)
96 #if PERIODIC_TELEMETRY
99 static void send_rate(
struct transport_tx *trans,
struct link_device *
dev)
101 pprz_msg_send_RATE_LOOP(trans, dev, AC_ID,
121 STABILIZATION_RATE_GAIN_P,
122 STABILIZATION_RATE_GAIN_Q,
123 STABILIZATION_RATE_GAIN_R);
131 #if PERIODIC_TELEMETRY
197 RATES_SDIV(sum_err_increment, _error, PERIODIC_FREQUENCY);
#define RATES_SDIV(_ro, _ri, _s)
#define STABILIZATION_RATE_IGAIN_R
struct FloatRates stabilization_rate_sum_err
#define RATES_ADD(_a, _b)
Periodic telemetry system header (includes downlink utility and generated code).
void stabilization_rate_enter(void)
#define RATES_ASSIGN(_ra, _p, _q, _r)
#define FLOAT_RATES_ZERO(_r)
#define YAW_RATE_DEADBAND_EXCEEDED()
#define RATES_DIFF(_c, _a, _b)
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define THROTTLE_STICK_DOWN()
Rate stabilization for rotorcrafts.
struct FloatRates stabilization_rate_sp
#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)
struct FloatRates stabilization_rate_igain
#define DefaultPeriodic
Set default periodic telemetry.
struct RadioControl radio_control
Inertial Measurement Unit interface.
#define STABILIZATION_RATE_IGAIN_Q
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
#define PITCH_RATE_DEADBAND_EXCEEDED()
Some helper functions to check RC sticks.
static const struct usb_device_descriptor dev
static void send_rate(struct transport_tx *trans, struct link_device *dev)
API to get/set the generic vehicle states.
struct FloatRates stabilization_rate_fb_cmd
General stabilization interface for rotorcrafts.
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
void stabilization_rate_run(bool in_flight)
struct FloatRates stabilization_rate_gain
void stabilization_rate_init(void)
#define ROLL_RATE_DEADBAND_EXCEEDED()
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.