|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
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
77 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
78 float thrust_in_specific_force_gain = GUIDANCE_INDI_SPECIFIC_FORCE_GAIN;
79 static void guidance_indi_filter_thrust(
void);
81 #ifndef GUIDANCE_INDI_THRUST_DYNAMICS
82 #ifndef STABILIZATION_INDI_ACT_DYN_P
83 #error "You need to define GUIDANCE_INDI_THRUST_DYNAMICS to be able to use indi vertical control"
84 #else // assume that the same actuators are used for thrust as for roll (e.g. quadrotor)
85 #define GUIDANCE_INDI_THRUST_DYNAMICS STABILIZATION_INDI_ACT_DYN_P
87 #endif //GUIDANCE_INDI_THRUST_DYNAMICS
89 #endif //GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
91 #ifndef GUIDANCE_INDI_FILTER_CUTOFF
92 #ifdef STABILIZATION_INDI_FILT_CUTOFF
93 #define GUIDANCE_INDI_FILTER_CUTOFF STABILIZATION_INDI_FILT_CUTOFF
95 #define GUIDANCE_INDI_FILTER_CUTOFF 3.0
140 float sample_time = 1.0 / PERIODIC_FREQUENCY;
141 for (
int8_t i = 0; i < 3; i++) {
198 #if GUIDANCE_INDI_RC_DEBUG
199 #warning "GUIDANCE_INDI_RC_DEBUG lets you control the accelerations via RC, but disables autonomous flight!"
204 sp_accel.
x = cosf(psi) * rc_x - sinf(psi) * rc_y;
205 sp_accel.
y = sinf(psi) * rc_x + cosf(psi) * rc_y;
220 Bound(a_diff.
x, -6.0, 6.0);
221 Bound(a_diff.
y, -6.0, 6.0);
222 Bound(a_diff.
z, -9.0, 9.0);
226 #ifndef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
227 #ifndef STABILIZATION_ATTITUDE_INDI_FULL
241 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
242 guidance_indi_filter_thrust();
248 #if GUIDANCE_INDI_RC_DEBUG
268 #ifdef GUIDANCE_INDI_SPECIFIC_FORCE_GAIN
272 void guidance_indi_filter_thrust(
void)
308 float sphi = sinf(euler_yxz->
phi);
309 float cphi = cosf(euler_yxz->
phi);
310 float stheta = sinf(euler_yxz->
theta);
311 float ctheta = cosf(euler_yxz->
theta);
338 float sphi = sinf(euler->
phi);
339 float cphi = cosf(euler->
phi);
340 float stheta = sinf(euler->
theta);
341 float ctheta = cosf(euler->
theta);
342 float spsi = sinf(euler->
psi);
343 float cpsi = cosf(euler->
psi);
347 RMAT_ELMT(*Gmat, 0, 0) = (cphi * spsi - sphi * cpsi * stheta) *
T;
348 RMAT_ELMT(*Gmat, 1, 0) = (-sphi * spsi * stheta - cpsi * cphi) *
T;
350 RMAT_ELMT(*Gmat, 0, 1) = (cphi * cpsi * ctheta) *
T;
351 RMAT_ELMT(*Gmat, 1, 1) = (cphi * spsi * ctheta) *
T;
353 RMAT_ELMT(*Gmat, 0, 2) = sphi * spsi + cphi * cpsi * stheta;
354 RMAT_ELMT(*Gmat, 1, 2) = cphi * spsi * stheta - cpsi * sphi;
369 }
else if (flag == 1) {
static void guidance_indi_calcG(struct FloatMat33 *Gmat)
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
vector in North East Down coordinates Units: meters
struct HorizontalGuidanceReference ref
reference calculated from setpoints
static struct NedCoor_f * stateGetPositionNed_f(void)
Get position in local NED coordinates (float).
struct FloatEulers guidance_euler_cmd
#define THRUST_INCREMENT_ID
#define GUIDANCE_H_MAX_BANK
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
static float get_sys_time_float(void)
Get the time in seconds since startup.
float guidance_indi_speed_gain
float guidance_indi_max_bank
Butterworth2LowPass thrust_filt
struct FloatVect3 indi_accel_sp
Event structure to store callbacks in a linked list.
Butterworth2LowPass pitch_filt
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
float time_of_accel_sp_3d
Second order low pass filter structure.
#define POS_FLOAT_OF_BFP(_ai)
static struct NedCoor_i * stateGetPositionNed_i(void)
Get position in local NED coordinates (int).
static void guidance_indi_propagate_filters(struct FloatEulers *eulers)
Low pass the accelerometer measurements to remove noise from vibrations.
Butterworth2LowPass roll_filt
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
bool indi_accel_sp_set_3d
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
void guidance_indi_enter(void)
Call upon entering indi guidance.
bool indi_accel_sp_set_2d
Architecture independent timing functions.
#define RMAT_ELMT(_rm, _row, _col)
Butterworth2LowPass filt_accel_ned[3]
#define QUAT_BFP_OF_REAL(_qi, _qf)
struct FloatVect3 control_increment
#define GUIDANCE_INDI_ACCEL_SP_ID
struct FloatVect3 sp_accel
#define GUIDANCE_INDI_SPEED_GAIN
#define MAT33_INV(_minv, _m)
void guidance_indi_init(void)
Init function.
#define MAT33_VECT3_MUL(_vout, _mat, _vin)
static void guidance_indi_calcG_yxz(struct FloatMat33 *Gmat, struct FloatEulers *euler_yxz)
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.
#define GUIDANCE_INDI_FILTER_CUTOFF
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
struct Int32Vect2 pos
with INT32_POS_FRAC
struct HorizontalGuidance guidance_h
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
struct Int32Quat stab_att_sp_quat
with INT32_QUAT_FRAC
float time_of_accel_sp_2d
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...
void guidance_indi_run(float *heading_sp)
struct RadioControl radio_control
float guidance_indi_pos_gain
#define GUIDANCE_INDI_POS_GAIN
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Simple first order low pass filter with bilinear transform.
int32_t guidance_v_z_ref
altitude reference in meters.