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))
73 #if PERIODIC_TELEMETRY
76 static void send_rate(
struct transport_tx *trans,
struct link_device *
dev)
78 pprz_msg_send_RATE_LOOP(trans,
dev, AC_ID,
98 STABILIZATION_RATE_GAIN_P,
99 STABILIZATION_RATE_GAIN_Q,
100 STABILIZATION_RATE_GAIN_R);
108 #if PERIODIC_TELEMETRY
129 RATES_SDIV(sum_err_increment, _error, PERIODIC_FREQUENCY);
152 BoundAbs(cmd[COMMAND_ROLL],
MAX_PPRZ);
153 BoundAbs(cmd[COMMAND_PITCH],
MAX_PPRZ);
154 BoundAbs(cmd[COMMAND_YAW],
MAX_PPRZ);
155 BoundAbs(cmd[COMMAND_THRUST],
MAX_PPRZ);
#define FLOAT_RATES_ZERO(_r)
#define RATES_ASSIGN(_ra, _p, _q, _r)
#define RATES_ADD(_a, _b)
#define RATES_DIFF(_c, _a, _b)
#define RATES_BOUND_CUBE(_v, _min, _max)
#define RATES_SDIV(_ro, _ri, _s)
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
Inertial Measurement Unit interface.
Generic interface for radio control modules.
Some helper functions to check RC sticks.
#define THROTTLE_STICK_DOWN_FROM_RC(_rc)
struct Stabilization stabilization
struct FloatRates stab_sp_to_rates_f(struct StabilizationSetpoint *sp)
struct StabilizationSetpoint stab_sp_from_rates_f(struct FloatRates *rates)
int32_t th_sp_to_thrust_i(struct ThrustSetpoint *th, int32_t thrust, uint8_t axis)
General stabilization interface for rotorcrafts.
int32_t cmd[COMMANDS_NB]
output command vector, range from [-MAX_PPRZ:MAX_PPRZ] (store for messages)
#define STABILIZATION_RATE_IGAIN_P
static struct FloatRates stabilization_rate_fb_cmd
void stabilization_rate_enter(void)
struct StabilizationSetpoint stabilization_rate_read_rc(struct RadioControl *rc)
#define STABILIZATION_RATE_IGAIN_R
#define STABILIZATION_RATE_IGAIN_Q
void stabilization_rate_run(bool in_flight, struct StabilizationSetpoint *rate_sp, struct ThrustSetpoint *thrust, int32_t *cmd)
struct FloatRates stabilization_rate_igain
struct FloatRates stabilization_rate_gain
static void send_rate(struct transport_tx *trans, struct link_device *dev)
static struct FloatRates stabilization_rate_sp
static struct FloatRates stabilization_rate_sum_err
void stabilization_rate_init(void)
Rate stabilization for rotorcrafts.
#define YAW_RATE_DEADBAND_EXCEEDED(_rc)
#define ROLL_RATE_DEADBAND_EXCEEDED(_rc)
#define PITCH_RATE_DEADBAND_EXCEEDED(_rc)
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
Thrust setpoint // TODO to a setpoint header Structure to store the desired thrust vector with differ...
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
int int32_t
Typedef defining 32 bit int type.