30 #include "generated/airframe.h"
52 #ifdef GUIDANCE_INDI_POS_GAIN
58 #ifdef GUIDANCE_INDI_SPEED_GAIN
65 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
66 float thrust_in_specific_force_gain = GUIDANCE_INDI_SPECIFIC_FORCE_GAIN;
67 static void guidance_indi_filter_thrust(
void);
69 #ifndef GUIDANCE_INDI_THRUST_DYNAMICS
70 #ifndef STABILIZATION_INDI_ACT_DYN_P
71 #error "You need to define GUIDANCE_INDI_THRUST_DYNAMICS to be able to use indi vertical control"
72 #else // assume that the same actuators are used for thrust as for roll (e.g. quadrotor)
73 #define GUIDANCE_INDI_THRUST_DYNAMICS STABILIZATION_INDI_ACT_DYN_P
75 #endif //GUIDANCE_INDI_THRUST_DYNAMICS
77 #endif //GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
79 #ifndef GUIDANCE_INDI_FILTER_CUTOFF
80 #ifdef STABILIZATION_INDI_FILT_CUTOFF
81 #define GUIDANCE_INDI_FILTER_CUTOFF STABILIZATION_INDI_FILT_CUTOFF
83 #define GUIDANCE_INDI_FILTER_CUTOFF 3.0
114 float sample_time = 1.0/PERIODIC_FREQUENCY;
115 for(
int8_t i=0; i<3; i++) {
147 #if GUIDANCE_INDI_RC_DEBUG
148 #warning "GUIDANCE_INDI_RC_DEBUG lets you control the accelerations via RC, but disables autonomous flight!"
153 sp_accel.
x = cosf(psi) * rc_x - sinf(psi) * rc_y;
154 sp_accel.
y = sinf(psi) * rc_x + cosf(psi) * rc_y;
165 struct FloatVect3 a_diff = { sp_accel.
x - filt_accel_ned[0].
o[0], sp_accel.
y -filt_accel_ned[1].
o[0], sp_accel.
z -filt_accel_ned[2].
o[0]};
168 Bound(a_diff.
x, -6.0, 6.0);
169 Bound(a_diff.
y, -6.0, 6.0);
170 Bound(a_diff.
z, -9.0, 9.0);
174 #ifndef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
175 #ifndef STABILIZATION_ATTITUDE_INDI_FULL
190 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
191 guidance_indi_filter_thrust();
197 #if GUIDANCE_INDI_RC_DEBUG
215 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
219 void guidance_indi_filter_thrust(
void)
254 float sphi = sinf(euler->
phi);
255 float cphi = cosf(euler->
phi);
256 float stheta = sinf(euler->
theta);
257 float ctheta = cosf(euler->
theta);
258 float spsi = sinf(euler->
psi);
259 float cpsi = cosf(euler->
psi);
263 RMAT_ELMT(*Gmat, 0, 0) = (cphi*spsi - sphi*cpsi*stheta)*T;
264 RMAT_ELMT(*Gmat, 1, 0) = (-sphi*spsi*stheta - cpsi*cphi)*T;
266 RMAT_ELMT(*Gmat, 0, 1) = (cphi*cpsi*ctheta)*T;
267 RMAT_ELMT(*Gmat, 1, 1) = (cphi*spsi*ctheta)*T;
269 RMAT_ELMT(*Gmat, 0, 2) = sphi*spsi + cphi*cpsi*stheta;
270 RMAT_ELMT(*Gmat, 1, 2) = cphi*spsi*stheta - cpsi*sphi;
void guidance_indi_enter(void)
Call upon entering indi guidance.
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
void float_quat_comp_inv(struct FloatQuat *a2b, struct FloatQuat *a2c, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions.
void float_quat_of_eulers(struct FloatQuat *q, struct FloatEulers *e)
Quaternion from Euler angles.
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
#define GUIDANCE_H_MAX_BANK
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
void float_quat_comp(struct FloatQuat *a2c, struct FloatQuat *a2b, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions.
General attitude stabilization interface for rotorcrafts.
struct FloatVect3 sp_accel
Simple first order low pass filter with bilinear transform.
Main include for ABI (AirBorneInterface).
Vertical guidance for rotorcrafts.
struct HorizontalGuidanceReference ref
reference calculated from setpoints
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define GUIDANCE_INDI_FILTER_CUTOFF
Butterworth2LowPass filt_accel_ned[3]
struct Int32Quat stab_att_sp_quat
with INT32_QUAT_FRAC
#define QUAT_COPY(_qo, _qi)
Butterworth2LowPass pitch_filt
Some helper functions to check RC sticks.
static void guidance_indi_calcG(struct FloatMat33 *Gmat)
vector in North East Down coordinates Units: meters
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
void guidance_indi_run(bool in_flight, float heading_sp)
Architecture independent timing functions.
float guidance_indi_pos_gain
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
#define QUAT_BFP_OF_REAL(_qi, _qf)
static void float_quat_normalize(struct FloatQuat *q)
struct RadioControl radio_control
struct HorizontalGuidance guidance_h
int32_t guidance_v_z_ref
altitude reference in meters.
struct FloatEulers guidance_euler_cmd
struct FloatVect3 euler_cmd
Inertial Measurement Unit interface.
float guidance_indi_speed_gain
void stabilization_attitude_set_setpoint_rp_quat_f(struct FloatEulers *indi_rp_cmd, bool in_flight, float heading)
#define THRUST_INCREMENT_ID
Core autopilot interface common to all firmwares.
#define MAT33_VECT3_MUL(_vout, _mat, _vin)
struct Int32Vect2 pos
with INT32_POS_FRAC
API to get/set the generic vehicle states.
Butterworth2LowPass thrust_filt
#define RMAT_ELMT(_rm, _row, _col)
void float_quat_of_axis_angle(struct FloatQuat *q, const struct FloatVect3 *uv, float angle)
Quaternion from unit vector and angle.
void float_quat_comp_norm_shortest(struct FloatQuat *a2c, struct FloatQuat *a2b, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions with normalization.
General stabilization interface for rotorcrafts.
static void guidance_indi_propagate_filters(void)
Low pass the accelerometer measurements to remove noise from vibrations.
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
#define POS_FLOAT_OF_BFP(_ai)
Second order low pass filter structure.
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
Horizontal guidance for rotorcrafts.
#define MAT33_INV(_minv, _m)
Butterworth2LowPass roll_filt
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
Rotorcraft attitude reference generation.
A guidance mode based on Incremental Nonlinear Dynamic Inversion Come to ICRA2016 to learn more! ...
INS for rotorcrafts combining vertical and horizontal filters.