Paparazzi UAS
v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
|
#include "firmwares/rotorcraft/stabilization/stabilization_indi_simple.h"
#include "firmwares/rotorcraft/stabilization/stabilization_attitude.h"
#include "firmwares/rotorcraft/stabilization/stabilization_attitude_rc_setpoint.h"
#include "firmwares/rotorcraft/stabilization/stabilization_attitude_quat_transformations.h"
#include "state.h"
#include "generated/airframe.h"
#include "paparazzi.h"
#include "subsystems/radio_control.h"
#include "subsystems/datalink/telemetry.h"
Go to the source code of this file.
Macros | |
#define | STABILIZATION_INDI_FILT_CUTOFF 8.0 |
#define | STABILIZATION_INDI_FILT_CUTOFF_R STABILIZATION_INDI_FILT_CUTOFF |
#define | STABILIZATION_INDI_MAX_RATE 6.0 |
#define | STABILIZATION_INDI_MAX_R STABILIZATION_ATTITUDE_SP_MAX_R |
#define | STABILIZATION_INDI_ESTIMATION_FILT_CUTOFF 4.0 |
#define | INDI_EST_SCALE 0.001 |
Functions | |
static void | stabilization_indi_calc_cmd (int32_t indi_commands[], struct Int32Quat *att_err, bool rate_control) |
Does the INDI calculations. More... | |
static void | lms_estimation (void) |
This is a Least Mean Squares adaptive filter It estimates the actuator effectiveness online, by comparing the expected angular acceleration based on the inputs with the measured angular acceleration. More... | |
static void | indi_init_filters (void) |
static void | send_att_indi (struct transport_tx *trans, struct link_device *dev) |
static void | send_ahrs_ref_quat (struct transport_tx *trans, struct link_device *dev) |
void | stabilization_indi_init (void) |
Function that initializes important values upon engaging INDI. More... | |
void | stabilization_indi_enter (void) |
Function that resets important values upon engaging INDI. More... | |
void | stabilization_indi_set_failsafe_setpoint (void) |
Function that calculates the failsafe setpoint. More... | |
void | stabilization_indi_set_rpy_setpoint_i (struct Int32Eulers *rpy) |
Set attitude quaternion setpoint from rpy. More... | |
void | stabilization_indi_set_earth_cmd_i (struct Int32Vect2 *cmd, int32_t heading) |
Set attitude setpoint from command in earth axes. More... | |
static void | filter_pqr (Butterworth2LowPass *filter, struct FloatRates *new_values) |
Update butterworth filter for p, q and r of a FloatRates struct. More... | |
static void | finite_difference_from_filter (float *output, Butterworth2LowPass *filter) |
Caclulate finite difference form a filter array The filter already contains the previous values. More... | |
static void | finite_difference (float output[3], float new[3], float old[3]) |
Calculate derivative of an array via finite difference. More... | |
void | stabilization_indi_run (bool in_flight, bool rate_control) |
runs stabilization indi More... | |
void | stabilization_indi_read_rc (bool in_flight, bool in_carefree, bool coordinated_turn) |
This function reads rc commands. More... | |
Variables | |
struct Int32Eulers | stab_att_sp_euler |
with INT32_ANGLE_FRAC More... | |
struct Int32Quat | stab_att_sp_quat |
with INT32_QUAT_FRAC More... | |
static int32_t | stabilization_att_indi_cmd [COMMANDS_NB] |
struct IndiVariables | indi |
#define INDI_EST_SCALE 0.001 |
Definition at line 83 of file stabilization_indi_simple.c.
Referenced by lms_estimation(), and send_att_indi().
#define STABILIZATION_INDI_ESTIMATION_FILT_CUTOFF 4.0 |
Definition at line 71 of file stabilization_indi_simple.c.
Referenced by indi_init_filters(), and init_filters().
#define STABILIZATION_INDI_FILT_CUTOFF 8.0 |
Definition at line 50 of file stabilization_indi_simple.c.
Referenced by indi_init_filters(), and init_filters().
#define STABILIZATION_INDI_FILT_CUTOFF_R STABILIZATION_INDI_FILT_CUTOFF |
Definition at line 55 of file stabilization_indi_simple.c.
Referenced by indi_init_filters().
#define STABILIZATION_INDI_MAX_R STABILIZATION_ATTITUDE_SP_MAX_R |
Definition at line 67 of file stabilization_indi_simple.c.
#define STABILIZATION_INDI_MAX_RATE 6.0 |
Definition at line 59 of file stabilization_indi_simple.c.
|
inlinestatic |
Update butterworth filter for p, q and r of a FloatRates struct.
filter | The filter array to use |
new_values | The new values |
Definition at line 249 of file stabilization_indi_simple.c.
References FloatRates::p, FloatRates::q, FloatRates::r, and update_butterworth_2_low_pass().
Referenced by lms_estimation(), and stabilization_indi_calc_cmd().
|
inlinestatic |
Calculate derivative of an array via finite difference.
output[3] | The output array |
new[3] | The newest values |
old[3] | The values of the previous timestep |
Definition at line 277 of file stabilization_indi_simple.c.
Referenced by lms_estimation().
|
inlinestatic |
Caclulate finite difference form a filter array The filter already contains the previous values.
output | The output array |
filter | The filter array input |
Definition at line 263 of file stabilization_indi_simple.c.
References SecondOrderLowPass::o.
Referenced by lms_estimation(), and stabilization_indi_calc_cmd().
|
static |
Definition at line 167 of file stabilization_indi_simple.c.
References IndiVariables::est, init_butterworth_2_low_pass(), IndiEstimation::rate, IndiVariables::rate, STABILIZATION_INDI_ESTIMATION_FILT_CUTOFF, STABILIZATION_INDI_FILT_CUTOFF, STABILIZATION_INDI_FILT_CUTOFF_R, IndiEstimation::u, and IndiVariables::u.
Referenced by stabilization_indi_enter(), and stabilization_indi_init().
|
inlinestatic |
This is a Least Mean Squares adaptive filter It estimates the actuator effectiveness online, by comparing the expected angular acceleration based on the inputs with the measured angular acceleration.
Definition at line 437 of file stabilization_indi_simple.c.
References IndiVariables::adaptive, IndiVariables::est, filter_pqr(), finite_difference(), finite_difference_from_filter(), float_vect_copy(), float_vect_scale(), IndiEstimation::g1, IndiVariables::g1, IndiEstimation::g2, IndiVariables::g2, INDI_EST_SCALE, IndiEstimation::mu, FloatRates::p, FloatRates::q, FloatRates::r, IndiEstimation::rate, IndiEstimation::rate_d, IndiEstimation::rate_dd, stateGetBodyRates_f(), IndiEstimation::u, IndiVariables::u_act_dyn, IndiEstimation::u_d, and IndiEstimation::u_dd.
Referenced by stabilization_indi_calc_cmd().
|
static |
Definition at line 141 of file stabilization_indi_simple.c.
References Int32Quat::qi, Int32Quat::qx, Int32Quat::qy, Int32Quat::qz, stab_att_sp_quat, and stateGetNedToBodyQuat_i().
Referenced by stabilization_indi_init().
|
static |
Definition at line 121 of file stabilization_indi_simple.c.
References IndiVariables::angular_accel_ref, IndiVariables::est, IndiEstimation::g1, IndiEstimation::g2, INDI_EST_SCALE, FloatRates::p, FloatRates::q, FloatRates::r, IndiVariables::rate_d, and RATES_SMUL.
Referenced by stabilization_indi_init().
|
inlinestatic |
Does the INDI calculations.
indi_commands[] | Array of commands that the function will write to |
att_err | quaternion attitude error |
rate_control | rate control enabled, otherwise attitude control |
Definition at line 291 of file stabilization_indi_simple.c.
References IndiVariables::angular_accel_ref, IndiVariables::attitude_max_yaw_rate, IndiVariables::du, ReferenceSystem::err_p, ReferenceSystem::err_q, ReferenceSystem::err_r, filter_pqr(), finite_difference_from_filter(), FLOAT_RATES_ZERO, IndiVariables::g1, IndiVariables::g2, lms_estimation(), MAX_PPRZ, IndiVariables::max_rate, SecondOrderLowPass::o, FloatRates::p, FloatRates::q, QUAT1_FLOAT_OF_BFP, Int32Quat::qx, Int32Quat::qy, Int32Quat::qz, FloatRates::r, radio_control, RADIO_PITCH, RADIO_ROLL, RADIO_YAW, IndiVariables::rate, IndiVariables::rate_d, ReferenceSystem::rate_p, ReferenceSystem::rate_q, ReferenceSystem::rate_r, RATES_COPY, IndiVariables::reference_acceleration, stabilization_cmd, stateGetBodyRates_f(), IndiVariables::u, IndiVariables::u_act_dyn, IndiVariables::u_in, and RadioControl::values.
Referenced by stabilization_indi_run().
void stabilization_indi_enter | ( | void | ) |
Function that resets important values upon engaging INDI.
Don't reset inputs and filters, because it is unlikely to switch stabilization in flight, and there are multiple modes that use (the same) stabilization. Resetting the controller is not so nice when you are flying. FIXME: Ideally we should detect when coming from something that is not INDI
Definition at line 184 of file stabilization_indi_simple.c.
References IndiVariables::angular_accel_ref, ddu_estimation, du_estimation, FLOAT_RATES_ZERO, float_vect_zero(), indi_init_filters(), INDI_NUM_ACT, Int32Eulers::psi, stab_att_sp_euler, stabilization_attitude_get_heading_i(), IndiVariables::u_act_dyn, and IndiVariables::u_in.
void stabilization_indi_init | ( | void | ) |
Function that initializes important values upon engaging INDI.
Definition at line 156 of file stabilization_indi_simple.c.
References act_is_servo, actuator_state_filt_vect, actuator_state_filt_vectd, actuator_state_filt_vectdd, Bwls, calc_g1g2_pseudo_inv(), DefaultPeriodic, estimation_rate_d, estimation_rate_dd, float_vect_copy(), float_vect_zero(), g1, g1_est, g1_init, g1g2, g2, g2_est, g2_init, indi_init_filters(), INDI_NUM_ACT, INDI_OUTPUTS, init_filters(), num_thrusters, register_periodic_telemetry(), rpm_cb(), RPM_SENSOR_ID, send_ahrs_ref_quat(), send_att_indi(), send_indi_g(), thrust_cb(), and THRUST_INCREMENT_ID.
void stabilization_indi_read_rc | ( | bool | in_flight, |
bool | in_carefree, | ||
bool | coordinated_turn | ||
) |
This function reads rc commands.
in_flight | boolean that states if the UAV is in flight or not |
Definition at line 420 of file stabilization_indi_simple.c.
References QUAT_BFP_OF_REAL, stab_att_sp_quat, stabilization_attitude_read_rc_setpoint_quat_earth_bound_f(), and stabilization_attitude_read_rc_setpoint_quat_f().
void stabilization_indi_run | ( | bool | in_flight, |
bool | rate_control | ||
) |
runs stabilization indi
in_flight | not used |
rate_control | rate control enabled, otherwise attitude control |
Definition at line 391 of file stabilization_indi_simple.c.
References angular_acceleration, estimation_rate_d, estimation_rate_dd, indi_thrust_increment_set, int32_quat_inv_comp(), int32_quat_normalize(), int32_quat_wrap_shortest(), MAX_PPRZ, SecondOrderLowPass::o, FloatRates::p, FloatRates::q, FloatRates::r, stab_att_sp_quat, stabilization_att_indi_cmd, stabilization_cmd, stabilization_indi_calc_cmd(), stateGetBodyRates_f(), stateGetNedToBodyQuat_i(), and update_butterworth_2_low_pass().
void stabilization_indi_set_earth_cmd_i | ( | struct Int32Vect2 * | cmd, |
int32_t | heading | ||
) |
Set attitude setpoint from command in earth axes.
cmd | The command in earth axes (North East) |
heading | The desired heading |
Definition at line 226 of file stabilization_indi_simple.c.
References heading, INT32_TRIG_FRAC, Int32Eulers::phi, PPRZ_ITRIG_COS, PPRZ_ITRIG_SIN, Int32Eulers::psi, quat_from_earth_cmd_i(), stab_att_sp_euler, stab_att_sp_quat, stateGetNedToBodyEulers_i(), Int32Eulers::theta, Int32Vect2::x, and Int32Vect2::y.
void stabilization_indi_set_failsafe_setpoint | ( | void | ) |
Function that calculates the failsafe setpoint.
Definition at line 197 of file stabilization_indi_simple.c.
References PPRZ_ITRIG_COS, PPRZ_ITRIG_SIN, Int32Quat::qi, Int32Quat::qx, Int32Quat::qy, Int32Quat::qz, stab_att_sp_quat, and stabilization_attitude_get_heading_i().
void stabilization_indi_set_rpy_setpoint_i | ( | struct Int32Eulers * | rpy | ) |
Set attitude quaternion setpoint from rpy.
rpy | roll pitch yaw input |
Definition at line 212 of file stabilization_indi_simple.c.
References int32_quat_of_eulers(), stab_att_sp_euler, and stab_att_sp_quat.
struct IndiVariables indi |
Definition at line 85 of file stabilization_indi_simple.c.
struct Int32Eulers stab_att_sp_euler |
with INT32_ANGLE_FRAC
Definition at line 74 of file stabilization_indi_simple.c.
Referenced by stabilization_indi_enter(), stabilization_indi_set_earth_cmd_i(), and stabilization_indi_set_rpy_setpoint_i().
struct Int32Quat stab_att_sp_quat |
with INT32_QUAT_FRAC
Definition at line 75 of file stabilization_indi_simple.c.
Referenced by send_ahrs_ref_quat(), stabilization_indi_read_rc(), stabilization_indi_run(), stabilization_indi_set_earth_cmd_i(), stabilization_indi_set_failsafe_setpoint(), and stabilization_indi_set_rpy_setpoint_i().
|
static |
Definition at line 77 of file stabilization_indi_simple.c.
Referenced by stabilization_indi_run().