34 #include "generated/airframe.h"
55 #ifdef GUIDANCE_INDI_POS_GAIN
61 #ifdef GUIDANCE_INDI_SPEED_GAIN
67 #ifndef GUIDANCE_INDI_ACCEL_SP_ID
68 #define GUIDANCE_INDI_ACCEL_SP_ID ABI_BROADCAST
78 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
80 static void guidance_indi_filter_thrust(
void);
82 #ifndef GUIDANCE_INDI_THRUST_DYNAMICS
83 #ifndef STABILIZATION_INDI_ACT_DYN_P
84 #error "You need to define GUIDANCE_INDI_THRUST_DYNAMICS to be able to use indi vertical control"
86 #define GUIDANCE_INDI_THRUST_DYNAMICS STABILIZATION_INDI_ACT_DYN_P
92 #ifndef GUIDANCE_INDI_FILTER_CUTOFF
93 #ifdef STABILIZATION_INDI_FILT_CUTOFF
94 #define GUIDANCE_INDI_FILTER_CUTOFF STABILIZATION_INDI_FILT_CUTOFF
96 #define GUIDANCE_INDI_FILTER_CUTOFF 3.0
123 #if PERIODIC_TELEMETRY
127 pprz_msg_send_GUIDANCE_INDI_HYBRID(trans,
dev, AC_ID,
150 #if PERIODIC_TELEMETRY
165 float sample_time = 1.0 / PERIODIC_FREQUENCY;
166 for (
int8_t i = 0; i < 3; i++) {
224 #if GUIDANCE_INDI_RC_DEBUG
225 #warning "GUIDANCE_INDI_RC_DEBUG lets you control the accelerations via RC, but disables autonomous flight!"
230 sp_accel.
x = cosf(psi) * rc_x - sinf(psi) * rc_y;
231 sp_accel.
y = sinf(psi) * rc_x + cosf(psi) * rc_y;
246 Bound(a_diff.
x, -6.0, 6.0);
247 Bound(a_diff.
y, -6.0, 6.0);
248 Bound(a_diff.
z, -9.0, 9.0);
252 #ifndef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
253 #ifndef STABILIZATION_ATTITUDE_INDI_FULL
267 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
268 guidance_indi_filter_thrust();
274 #if GUIDANCE_INDI_RC_DEBUG
294 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
298 void guidance_indi_filter_thrust(
void)
334 float sphi = sinf(euler_yxz->
phi);
335 float cphi = cosf(euler_yxz->
phi);
336 float stheta = sinf(euler_yxz->
theta);
337 float ctheta = cosf(euler_yxz->
theta);
364 float sphi = sinf(euler->
phi);
365 float cphi = cosf(euler->
phi);
366 float stheta = sinf(euler->
theta);
367 float ctheta = cosf(euler->
theta);
368 float spsi = sinf(euler->
psi);
369 float cpsi = cosf(euler->
psi);
373 RMAT_ELMT(*Gmat, 0, 0) = (cphi * spsi - sphi * cpsi * stheta) *
T;
374 RMAT_ELMT(*Gmat, 1, 0) = (-sphi * spsi * stheta - cpsi * cphi) *
T;
376 RMAT_ELMT(*Gmat, 0, 1) = (cphi * cpsi * ctheta) *
T;
377 RMAT_ELMT(*Gmat, 1, 1) = (cphi * spsi * ctheta) *
T;
379 RMAT_ELMT(*Gmat, 0, 2) = sphi * spsi + cphi * cpsi * stheta;
380 RMAT_ELMT(*Gmat, 1, 2) = cphi * spsi * stheta - cpsi * sphi;
395 }
else if (flag == 1) {
Main include for ABI (AirBorneInterface).
Event structure to store callbacks in a linked list.
#define THRUST_INCREMENT_ID
Core autopilot interface common to all firmwares.
void float_eulers_of_quat_yxz(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'YXZ' This function calculates from a quaternion the Euler angles with the order YXZ,...
void float_quat_of_eulers_yxz(struct FloatQuat *q, struct FloatEulers *e)
quat from euler rotation 'YXZ' This function calculates a quaternion from Euler angles with the order...
#define MAT33_VECT3_MUL(_vout, _mat, _vin)
#define MAT33_INV(_minv, _m)
#define QUAT_BFP_OF_REAL(_qi, _qf)
#define RMAT_ELMT(_rm, _row, _col)
#define POS_FLOAT_OF_BFP(_ai)
#define SPEED_FLOAT_OF_BFP(_ai)
#define ACCEL_FLOAT_OF_BFP(_ai)
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
#define GUIDANCE_INDI_ACCEL_SP_ID
Butterworth2LowPass roll_filt
float guidance_indi_max_bank
bool indi_accel_sp_set_3d
float guidance_indi_pos_gain
struct FloatVect3 sp_accel
struct FloatEulers guidance_euler_cmd
static void guidance_indi_calcG(struct FloatMat33 *Gmat)
struct FloatVect3 speed_sp
static void guidance_indi_calcG_yxz(struct FloatMat33 *Gmat, struct FloatEulers *euler_yxz)
void guidance_indi_enter(void)
Call upon entering indi guidance.
static void accel_sp_cb(uint8_t sender_id, uint8_t flag, struct FloatVect3 *accel_sp)
ABI callback that obtains the acceleration setpoint from telemetry flag: 0 -> 2D, 1 -> 3D.
Butterworth2LowPass pitch_filt
static void guidance_indi_propagate_filters(struct FloatEulers *eulers)
Low pass the accelerometer measurements to remove noise from vibrations.
void guidance_indi_init(void)
Init function.
float time_of_accel_sp_3d
#define GUIDANCE_INDI_FILTER_CUTOFF
bool indi_accel_sp_set_2d
struct FloatVect3 indi_accel_sp
struct FloatVect3 control_increment
Butterworth2LowPass filt_accel_ned[3]
float guidance_indi_speed_gain
float time_of_accel_sp_2d
Butterworth2LowPass thrust_filt
void guidance_indi_run(float *heading_sp)
static void send_indi_guidance(struct transport_tx *trans, struct link_device *dev)
A guidance mode based on Incremental Nonlinear Dynamic Inversion.
float guidance_indi_specific_force_gain
#define GUIDANCE_INDI_POS_GAIN
#define GUIDANCE_INDI_SPEED_GAIN
Inertial Measurement Unit interface.
INS for rotorcrafts combining vertical and horizontal filters.
Simple first order low pass filter with bilinear transform.
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
Second order low pass filter structure.
vector in North East Down coordinates Units: meters
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define RADIO_ROLL
Redefining RADIO_* Do not use with radio.h (ppm rc)
Some helper functions to check RC sticks.
struct HorizontalGuidance guidance_h
#define GUIDANCE_H_MAX_BANK
Horizontal guidance for rotorcrafts.
struct Int32Vect2 accel
with INT32_ACCEL_FRAC
struct Int32Vect2 speed
with INT32_SPEED_FRAC
struct Int32Vect2 pos
with INT32_POS_FRAC
struct HorizontalGuidanceReference ref
reference calculated from setpoints
int32_t guidance_v_z_ref
altitude reference in meters.
int32_t guidance_v_zd_ref
vertical speed reference in meter/s.
int32_t guidance_v_zdd_ref
vertical acceleration reference in meter/s^2.
Vertical guidance for rotorcrafts.
General attitude stabilization interface for rotorcrafts.
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
General stabilization interface for rotorcrafts.
struct Int32Quat stab_att_sp_quat
with INT32_QUAT_FRAC
Rotorcraft attitude reference generation.
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
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.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.