82 #include "generated/airframe.h"
85 #ifdef STABILIZATION_ANDI_ROTWING_V3A
86 #include "modules/rot_wing_drone/wing_rotation_controller_v3a.h"
98 #ifndef ONELOOP_ANDI_NUM_THRUSTERS
104 #ifdef ONELOOP_ANDI_FILT_CUTOFF
110 #ifdef ONELOOP_ANDI_FILT_CUTOFF_ACC
116 #ifdef ONELOOP_ANDI_FILT_CUTOFF_VEL
122 #ifdef ONELOOP_ANDI_FILT_CUTOFF_POS
128 #ifdef ONELOOP_ANDI_FILT_CUTOFF_P
129 #define ONELOOP_ANDI_FILTER_ROLL_RATE TRUE
131 #define ONELOOP_ANDI_FILT_CUTOFF_P 20.0
134 #ifdef ONELOOP_ANDI_FILT_CUTOFF_Q
135 #define ONELOOP_ANDI_FILTER_PITCH_RATE TRUE
137 #define ONELOOP_ANDI_FILT_CUTOFF_Q 20.0
140 #ifdef ONELOOP_ANDI_FILT_CUTOFF_R
141 #define ONELOOP_ANDI_FILTER_YAW_RATE TRUE
143 #define ONELOOP_ANDI_FILT_CUTOFF_R 20.0
146 #ifdef ONELOOP_ANDI_ACT_IS_SERVO
152 #ifdef ONELOOP_ANDI_ACT_DYN
155 #error "You must specify the actuator dynamics"
159 #ifdef ONELOOP_ANDI_ACT_MAX
165 #ifdef ONELOOP_ANDI_ACT_MIN
171 #ifdef ONELOOP_ANDI_ACT_MAX_NORM
177 #ifdef ONELOOP_ANDI_ACT_MIN_NORM
183 #ifdef ONELOOP_ANDI_WV
191 #ifdef ONELOOP_ANDI_WU
197 #ifdef ONELOOP_ANDI_U_PREF
203 #ifndef ONELOOP_ANDI_DEBUG_MODE
204 #error "Debug Mode not defined"
205 #define ONELOOP_ANDI_DEBUG_MODE FALSE;
208 #ifndef ONELOOP_ANDI_AC_HAS_PUSHER
209 #error "Did not specify if ac has a pusher"
210 #define ONELOOP_ANDI_AC_HAS_PUSHER FALSE;
213 #if !ONELOOP_ANDI_AC_HAS_PUSHER
214 #define ONELOOP_ANDI_PUSHER_IDX 0
217 #ifndef ONELOOP_ANDI_PUSHER_IDX
218 #error "Did not specify pusher index"
219 #define ONELOOP_ANDI_PUSHER_IDX 4
222 #if ANDI_NUM_ACT_TOT != WLS_N_U
223 #error Matrix-WLS_N_U is not equal to the number of actuators: define WLS_N_U == ANDI_NUM_ACT_TOT in airframe file
224 #define WLS_N_U == ANDI_NUM_ACT_TOT
226 #if ANDI_OUTPUTS != WLS_N_V
227 #error Matrix-WLS_N_V is not equal to the number of controlled axis: define WLS_N_V == ANDI_OUTPUTS in airframe file
228 #define WLS_N_V == ANDI_OUTPUTS
233 #ifdef ONELOOP_MAX_ACC
239 #ifdef ONELOOP_MAX_JERK
245 #ifdef ONELOOP_MAX_AIRSPEED
253 #ifndef GUIDANCE_INDI_SPEED_GAIN
254 #define GUIDANCE_INDI_SPEED_GAIN 1.8
255 #define GUIDANCE_INDI_SPEED_GAINZ 1.8
258 #ifndef GUIDANCE_INDI_POS_GAIN
259 #define GUIDANCE_INDI_POS_GAIN 0.5
260 #define GUIDANCE_INDI_POS_GAINZ 0.5
263 #ifndef GUIDANCE_INDI_LIFTD_ASQ
264 #define GUIDANCE_INDI_LIFTD_ASQ 0.20
271 #ifndef GUIDANCE_INDI_LIFTD_P50
272 #define GUIDANCE_INDI_LIFTD_P80 (GUIDANCE_INDI_LIFTD_ASQ*12*12)
273 #define GUIDANCE_INDI_LIFTD_P50 (GUIDANCE_INDI_LIFTD_P80/2)
283 .heading_bank_gain = 5.0,
301 void err_nd(
float err[],
float a[],
float b[],
float k[],
int n);
302 void integrate_nd(
float dt,
float a[],
float a_dot[],
int n);
304 void rm_2nd(
float dt,
float* x_ref,
float* x_d_ref,
float* x_2d_ref,
float x_des,
float k1_rm,
float k2_rm);
305 void rm_3rd(
float dt,
float* x_ref,
float* x_d_ref,
float* x_2d_ref,
float* x_3d_ref,
float x_des,
float k1_rm,
float k2_rm,
float k3_rm);
306 void rm_3rd_head(
float dt,
float* x_ref,
float* x_d_ref,
float* x_2d_ref,
float* x_3d_ref,
float x_des,
float k1_rm,
float k2_rm,
float k3_rm);
307 void rm_3rd_attitude(
float dt,
float x_ref[3],
float x_d_ref[3],
float x_2d_ref[3],
float x_3d_ref[3],
float x_des[3],
bool ow_psi,
float psi_overwrite[4],
float k1_rm[3],
float k2_rm[3],
float k3_rm[3]);
308 void rm_3rd_pos(
float dt,
float x_ref[],
float x_d_ref[],
float x_2d_ref[],
float x_3d_ref[],
float x_des[],
float k1_rm[],
float k2_rm[],
float k3_rm[],
float x_d_bound,
float x_2d_bound,
float x_3d_bound,
int n);
309 void rm_2nd_pos(
float dt,
float x_d_ref[],
float x_2d_ref[],
float x_3d_ref[],
float x_d_des[],
float k2_rm[],
float k3_rm[],
float x_2d_bound,
float x_3d_bound,
int n);
310 void rm_1st_pos(
float dt,
float x_2d_ref[],
float x_3d_ref[],
float x_2d_des[],
float k3_rm[],
float x_3d_bound,
int n);
311 void ec_3rd_att(
float y_4d[3],
float x_ref[3],
float x_d_ref[3],
float x_2d_ref[3],
float x_3d_ref[3],
float x[3],
float x_d[3],
float x_2d[3],
float k1_e[3],
float k2_e[3],
float k3_e[3]);
315 #if PERIODIC_TELEMETRY
321 pprz_msg_send_EFF_MAT_G(trans,
dev, AC_ID,
333 pprz_msg_send_STAB_ATTITUDE(trans,
dev, AC_ID,
358 pprz_msg_send_GUIDANCE(trans,
dev, AC_ID,
389 static float dt_1l = 1./PERIODIC_FREQUENCY;
390 static float g = 9.81;
408 static float psi_vec[4] = {0.0, 0.0, 0.0, 0.0};
445 float g1_1l[
ANDI_OUTPUTS][
ANDI_NUM_ACT_TOT] = {ONELOOP_ANDI_G1_ZERO, ONELOOP_ANDI_G1_ZERO, ONELOOP_ANDI_G1_THRUST, ONELOOP_ANDI_G1_ROLL, ONELOOP_ANDI_G1_PITCH, ONELOOP_ANDI_G1_YAW};
462 if (input < FLT_EPSILON) {
474 return (p1 * p2 * p3);
481 return (p1 * p2 + p1 * p3 + p2 * p3);
488 return (p1 + p2 + p3);
506 return (omega_n * omega_n * p1);
513 return (omega_n * omega_n + 2 * zeta * omega_n * p1);
520 return (2 * zeta * omega_n + p1);
525 static float k_rm_1_3_f(
float omega_n,
float zeta,
float p1) {
529 return (omega_n * omega_n * p1) / (omega_n * omega_n + omega_n * p1 * zeta * 2.0);
532 static float k_rm_2_3_f(
float omega_n,
float zeta,
float p1) {
536 return (omega_n * omega_n + omega_n * p1 * zeta * 2.0) / (p1 + omega_n * zeta * 2.0);
539 static float k_rm_3_3_f(
float omega_n,
float zeta,
float p1) {
543 return p1 + omega_n * zeta * 2.0;
549 return omega_n / (2.0 * zeta);
555 return 2.0 * zeta * omega_n;
561 float sphi = sinf(e[0]);
562 float cphi = cosf(e[0]);
563 float stheta = sinf(e[1]);
564 float ctheta = cosf(e[1]);
565 r[0] = edot[0] - stheta * edot[2];
566 r[1] = cphi * edot[1] + sphi * ctheta * edot[2];
567 r[2] = -sphi * edot[1] + cphi * ctheta * edot[2];
573 float sphi = sinf(e[0]);
574 float cphi = cosf(e[0]);
575 float stheta = sinf(e[1]);
576 float ctheta = cosf(e[1]);
577 if (fabs(ctheta) < FLT_EPSILON){
578 ctheta = FLT_EPSILON;
580 edot[0] = r[0] + sphi*stheta/ctheta*r[1] + cphi*stheta/ctheta*r[2];
581 edot[1] = cphi*r[1] - sphi*r[2];
582 edot[2] = sphi/ctheta*r[1] + cphi/ctheta*r[2];
586 void err_nd(
float err[],
float a[],
float b[],
float k[],
int n)
589 for (i = 0; i < n; i++) {
590 err[i] = k[i] * (a[i] -
b[i]);
598 for (i = 0; i < n; i++) {
599 a[i] = a[i] + dt * a_dot[i];
607 if((norm-bound) > FLT_EPSILON) {
608 float scale = bound/norm;
610 for(i = 0; i < n; i++) {
630 void rm_3rd_attitude(
float dt,
float x_ref[3],
float x_d_ref[3],
float x_2d_ref[3],
float x_3d_ref[3],
float x_des[3],
bool ow_psi,
float psi_overwrite[4],
float k1_rm[3],
float k2_rm[3],
float k3_rm[3]){
635 float x_d_eul_ref[3];
636 err_nd(e_x, x_des, x_ref, k1_rm, 3);
637 float temp_diff = x_des[2] - x_ref[2];
638 NormRadAngle(temp_diff);
639 e_x[2] = k1_rm[2] * temp_diff;
641 err_nd(e_x_d, e_x_rates, x_d_ref, k2_rm, 3);
642 err_nd(e_x_2d, e_x_d, x_2d_ref, k3_rm, 3);
644 if(ow_psi){x_3d_ref[2] = psi_overwrite[3];}
646 if(ow_psi){x_2d_ref[2] = psi_overwrite[2];}
648 if(ow_psi){x_d_ref[2] = psi_overwrite[1];}
651 if(ow_psi){x_ref[2] = psi_overwrite[0];}
652 NormRadAngle(x_ref[2]);
667 void rm_3rd(
float dt,
float* x_ref,
float* x_d_ref,
float* x_2d_ref,
float* x_3d_ref,
float x_des,
float k1_rm,
float k2_rm,
float k3_rm){
668 float e_x = k1_rm * (x_des- *x_ref);
669 float e_x_d = k2_rm * (e_x- *x_d_ref);
670 float e_x_2d = k3_rm * (e_x_d- *x_2d_ref);
672 *x_2d_ref = (*x_2d_ref + dt * (*x_3d_ref));
673 *x_d_ref = (*x_d_ref + dt * (*x_2d_ref));
674 *x_ref = (*x_ref + dt * (*x_d_ref ));
689 void rm_3rd_head(
float dt,
float* x_ref,
float* x_d_ref,
float* x_2d_ref,
float* x_3d_ref,
float x_des,
float k1_rm,
float k2_rm,
float k3_rm){
690 float temp_diff = x_des - *x_ref;
691 NormRadAngle(temp_diff);
692 float e_x = k1_rm * temp_diff;
693 float e_x_d = k2_rm * (e_x- *x_d_ref);
694 float e_x_2d = k3_rm * (e_x_d- *x_2d_ref);
696 *x_2d_ref = (*x_2d_ref + dt * (*x_3d_ref));
697 *x_d_ref = (*x_d_ref + dt * (*x_2d_ref));
698 *x_ref = (*x_ref + dt * (*x_d_ref ));
717 void rm_3rd_pos(
float dt,
float x_ref[],
float x_d_ref[],
float x_2d_ref[],
float x_3d_ref[],
float x_des[],
float k1_rm[],
float k2_rm[],
float k3_rm[],
float x_d_bound,
float x_2d_bound,
float x_3d_bound,
int n){
721 err_nd(e_x, x_des, x_ref, k1_rm, n);
723 err_nd(e_x_d, e_x, x_d_ref, k2_rm, n);
725 err_nd(e_x_2d, e_x_d, x_2d_ref, k3_rm, n);
746 void rm_2nd_pos(
float dt,
float x_d_ref[],
float x_2d_ref[],
float x_3d_ref[],
float x_d_des[],
float k2_rm[],
float k3_rm[],
float x_2d_bound,
float x_3d_bound,
int n){
749 err_nd(e_x_d, x_d_des, x_d_ref, k2_rm, n);
751 err_nd(e_x_2d, e_x_d, x_2d_ref, k3_rm, n);
768 void rm_1st_pos(
float dt,
float x_2d_ref[],
float x_3d_ref[],
float x_2d_des[],
float k3_rm[],
float x_3d_bound,
int n){
770 err_nd(e_x_2d, x_2d_des, x_2d_ref, k3_rm, n);
789 void rm_2nd(
float dt,
float* x_ref,
float* x_d_ref,
float* x_2d_ref,
float x_des,
float k1_rm,
float k2_rm){
790 float e_x = k1_rm * (x_des- *x_ref);
791 float e_x_d = k2_rm * (e_x- *x_d_ref);
793 *x_d_ref = (*x_d_ref + dt * (*x_2d_ref));
794 *x_ref = (*x_ref + dt * (*x_d_ref ));
812 static float ec_3rd(
float x_ref,
float x_d_ref,
float x_2d_ref,
float x_3d_ref,
float x,
float x_d,
float x_2d,
float k1_e,
float k2_e,
float k3_e){
813 float y_4d = k1_e*(x_ref-x)+k2_e*(x_d_ref-x_d)+k3_e*(x_2d_ref-x_2d)+x_3d_ref;
832 void ec_3rd_att(
float y_4d[3],
float x_ref[3],
float x_d_ref[3],
float x_2d_ref[3],
float x_3d_ref[3],
float x[3],
float x_d[3],
float x_2d[3],
float k1_e[3],
float k2_e[3],
float k3_e[3]){
836 err_nd(y_4d_1, x_ref, x, k1_e, 3);
837 float temp_diff = x_ref[2] - x[2];
838 NormRadAngle(temp_diff);
839 float e_x = temp_diff;
840 y_4d_1[2] = k1_e[2] * e_x;
841 err_nd(y_4d_2, x_d_ref, x_d, k2_e, 3);
842 err_nd(y_4d_3, x_2d_ref, x_2d, k3_e, 3);
861 static float ec_2rd(
float x_ref,
float x_d_ref,
float x_2d_ref,
float x,
float x_d,
float k1_e,
float k2_e){
862 float y_3d = k1_e*(x_ref-x)+k2_e*(x_d_ref-x_d)+x_2d_ref;
874 static float w_approx(
float p1,
float p2,
float p3,
float rm_k){
879 float tao = (p1*p2+p1*p3+p2*p3)/(p1*p2*p3)/(rm_k);
995 float sample_time = 1.0 / PERIODIC_FREQUENCY;
999 for (i = 0; i < 3; i++) {
1026 float rate_vect[3] = {body_rates->
p, body_rates->
q, body_rates->
r};
1038 for (i = 0; i < 3; i++) {
1085 #if PERIODIC_TELEMETRY
1136 float thrust_cmd_1l = 0.0;
1164 BoundAbs(des_r,3.0);
1176 if (rm_order_h == 3){
1177 rm_3rd_pos(
dt_1l,
oneloop_andi.
gui_ref.
pos,
oneloop_andi.
gui_ref.
vel,
oneloop_andi.
gui_ref.
acc,
oneloop_andi.
gui_ref.
jer,
nav_target,
k_pos_rm.
k1,
k_pos_rm.
k2,
k_pos_rm.
k3,
max_v_nav,
max_a_nav,
max_j_nav, 2);
1178 }
else if (rm_order_h == 2){
1181 }
else if (rm_order_h == 1){
1192 float single_value_nav_target[1] = {
nav_target[2]};
1193 float single_value_k1_rm[1] = {
k_pos_rm.
k1[2]};
1194 float single_value_k2_rm[1] = {
k_pos_rm.
k2[2]};
1195 float single_value_k3_rm[1] = {
k_pos_rm.
k3[2]};
1197 if (rm_order_v == 3){
1198 rm_3rd_pos(
dt_1l, single_value_ref, single_value_d_ref, single_value_2d_ref, single_value_3d_ref, single_value_nav_target, single_value_k1_rm, single_value_k2_rm, single_value_k3_rm,
max_v_nav,
max_a_nav,
max_j_nav, 1);
1203 }
else if (rm_order_v == 2){
1204 rm_2nd_pos(
dt_1l, single_value_d_ref, single_value_2d_ref, single_value_3d_ref, single_value_nav_target, single_value_k2_rm, single_value_k3_rm,
max_a_nav,
max_j_nav, 1);
1209 }
else if (rm_order_v == 1){
1210 rm_1st_pos(
dt_1l, single_value_2d_ref, single_value_3d_ref, single_value_nav_target, single_value_k3_rm,
max_j_nav, 1);
1218 bool ow_psi =
false;
1219 rm_3rd_attitude(
dt_1l,
oneloop_andi.
sta_ref.
att,
oneloop_andi.
sta_ref.
att_d,
oneloop_andi.
sta_ref.
att_2d,
oneloop_andi.
sta_ref.
att_3d, att_des, ow_psi,
psi_vec,
k_att_rm.
k1,
k_att_rm.
k2,
k_att_rm.
k3);
1242 bool in_flight_oneloop =
false;
1245 in_flight_oneloop =
true;
1248 in_flight_oneloop =
false;
1295 ec_3rd_att(y_4d_att,
oneloop_andi.
sta_ref.
att,
oneloop_andi.
sta_ref.
att_d,
oneloop_andi.
sta_ref.
att_2d,
oneloop_andi.
sta_ref.
att_3d,
oneloop_andi.
sta_state.
att,
oneloop_andi.
sta_state.
att_d,
oneloop_andi.
sta_state.
att_2d,
k_att_e.
k1,
k_att_e.
k2,
k_att_e.
k3);
1299 nu[3] = y_4d_att[0];
1300 nu[4] = y_4d_att[1];
1301 nu[5] = y_4d_att[2];
1317 number_iter =
wls_alloc(
andi_du_n,
nu,
du_min_1l,
du_max_1l,
bwls_1l, 0, 0,
Wv_wls,
Wu,
du_pref_1l,
gamma_wls, 10,
ANDI_NUM_ACT_TOT,
ANDI_OUTPUTS);
1323 if (in_flight_oneloop) {
1362 float prev_actuator_state_1l;
1396 g1g2_1l[0][i] = (cpsi * stheta + ctheta * sphi * spsi) *
g1_1l[2][i] * scaler;
1397 g1g2_1l[1][i] = (spsi * stheta - cpsi * ctheta * sphi) *
g1_1l[2][i] * scaler;
1398 g1g2_1l[2][i] = (cphi * ctheta ) *
g1_1l[2][i] * scaler;
1403 g1g2_1l[0][i] = (cpsi * ctheta - sphi * spsi * stheta) *
g1_1l[2][i] * scaler;
1404 g1g2_1l[1][i] = (ctheta * spsi + cpsi * sphi * stheta) *
g1_1l[2][i] * scaler;
1405 g1g2_1l[2][i] = (- cphi * stheta ) *
g1_1l[2][i] * scaler;
1414 g1g2_1l[0][i] = ( cphi * ctheta * spsi *
T - cphi * spsi * stheta *
P) * scaler;
1415 g1g2_1l[1][i] = (-cphi * ctheta * cpsi *
T + cphi * cpsi * stheta *
P) * scaler;
1416 g1g2_1l[2][i] = (-sphi * ctheta *
T + sphi * stheta *
P) * scaler;
1423 g1g2_1l[0][i] = ((ctheta*cpsi - sphi*stheta*spsi) *
T - (cpsi * stheta + ctheta * sphi * spsi) *
P) * scaler;
1424 g1g2_1l[1][i] = ((ctheta*spsi + sphi*stheta*cpsi) *
T - (spsi * stheta - cpsi * ctheta * sphi) *
P) * scaler;
1425 g1g2_1l[2][i] = (-stheta * cphi *
T - cphi * ctheta *
P) * scaler;
1447 ratio_u_un[i] = ratio_numerator/ratio_denominator;
1466 model_pred[0] = (cpsi * stheta + ctheta * sphi * spsi) *
T + (cpsi * ctheta + sphi * spsi * stheta) *
P;
1467 model_pred[1] = (spsi * stheta - cpsi * ctheta * sphi) *
T + (ctheta * spsi + cpsi * sphi * stheta) *
P;
Main include for ABI (AirBorneInterface).
struct pprz_autopilot autopilot
Global autopilot structure.
bool autopilot_get_motors_on(void)
get motors status
uint8_t mode
current autopilot mode
static const float scale[]
static void float_vect_sum(float *o, const float *a, const float *b, const int n)
o = a + b
static void float_vect_zero(float *a, const int n)
a = 0
static void float_vect_copy(float *a, const float *b, const int n)
a = b
void float_eulers_of_quat_zxy(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZXY' This rotation order is useful if you need 90 deg pitch
static float float_vect_norm(const float *a, const int n)
||a||
#define POS_FLOAT_OF_BFP(_ai)
#define SPEED_FLOAT_OF_BFP(_ai)
#define POS_BFP_OF_REAL(_af)
#define SPEED_BFP_OF_REAL(_af)
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (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 FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
Simple first order low pass filter with bilinear transform.
static float update_first_order_low_pass(struct FirstOrderLowPass *filter, float value)
Update first order low pass filter state with a new value.
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, float tau, float sample_time, float value)
Init a second order Butterworth filter.
static void init_first_order_low_pass(struct FirstOrderLowPass *filter, float tau, float sample_time, float value)
Init first order low pass filter.
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, float value)
Update second order Butterworth low pass filter state with a new value.
First order low pass filter structure.
Second order low pass filter structure.
Hardware independent API for actuators (servos, motor controllers).
Specific navigation functions for hybrid aircraft.
static float k_e_3_3_f_v2(float omega_n, float zeta, float p1)
static float k_e_1_3_f(float p1, float p2, float p3)
Error Controller Gain Design.
static float w_approx(float p1, float p2, float p3, float rm_k)
Third Order to First Order Dynamics Approximation.
void init_poles(void)
Initialize Position of Poles.
static struct FirstOrderLowPass filt_accel_ned[3]
struct PolePlacement p_pos_e
bool force_forward
forward flight for hybrid nav
static float du_pref_1l[ANDI_NUM_ACT_TOT]
static float k_e_3_3_f(float p1, float p2, float p3)
float act_dynamics[ANDI_NUM_ACT_TOT]
float ratio_u_un[ANDI_NUM_ACT_TOT]
void init_filter(void)
Initialize the filters.
struct PolePlacement p_head_rm
#define GUIDANCE_INDI_SPEED_GAINZ
static float k_e_2_3_f_v2(float omega_n, float zeta, float p1)
void ec_3rd_att(float y_4d[3], float x_ref[3], float x_d_ref[3], float x_2d_ref[3], float x_3d_ref[3], float x[3], float x_d[3], float x_2d[3], float k1_e[3], float k2_e[3], float k3_e[3])
Error Controller Definition for 3rd order system specific to attitude.
void rm_3rd_attitude(float dt, float x_ref[3], float x_d_ref[3], float x_2d_ref[3], float x_3d_ref[3], float x_des[3], bool ow_psi, float psi_overwrite[4], float k1_rm[3], float k2_rm[3], float k3_rm[3])
Reference Model Definition for 3rd order system with attitude conversion functions.
float act_max_norm[ANDI_NUM_ACT_TOT]
struct Gains3rdOrder k_att_rm
struct guidance_indi_hybrid_params gih_params
void float_euler_dot_of_rates_vec(float r[3], float e[3], float edot[3])
Attitude Euler to Rates Conversion Function.
float oneloop_andi_filt_cutoff_v
struct FloatEulers eulers_zxy_des
static float du_min_1l[ANDI_NUM_ACT_TOT]
static float du_max_1l[ANDI_NUM_ACT_TOT]
struct Int32Eulers stab_att_sp_euler_1l
struct PolePlacement p_att_rm
static float ec_3rd(float x_ref, float x_d_ref, float x_2d_ref, float x_3d_ref, float x, float x_d, float x_2d, float k1_e, float k2_e, float k3_e)
Error Controller Definition for 3rd order system.
static float Wv_wls[ANDI_OUTPUTS]
static float k_rm_3_3_f(float omega_n, float zeta, float p1)
float g1g2_1l[ANDI_OUTPUTS][ANDI_NUM_ACT_TOT]
static struct FirstOrderLowPass rates_filt_fo[3]
struct Gains3rdOrder k_att_e
static float model_pred[ANDI_OUTPUTS]
void rm_1st_pos(float dt, float x_2d_ref[], float x_3d_ref[], float x_2d_des[], float k3_rm[], float x_3d_bound, int n)
Reference Model Definition for 3rd order system specific to positioning with bounds.
void oneloop_andi_propagate_filters(void)
Propagate the filters.
#define ONELOOP_ANDI_PUSHER_IDX
struct Gains3rdOrder k_pos_e
bool actuator_is_servo[ANDI_NUM_ACT_TOT]
float num_thrusters_oneloop
struct Gains2ndOrder k_head_rm
static float act_dynamics_d[ANDI_NUM_ACT_TOT]
float act_min_norm[ANDI_NUM_ACT_TOT]
#define ONELOOP_ANDI_DEBUG_MODE
float oneloop_andi_filt_cutoff_a
static Butterworth2LowPass model_pred_filt[ANDI_OUTPUTS]
float g1_1l[ANDI_OUTPUTS][ANDI_NUM_ACT_TOT]
#define GUIDANCE_INDI_LIFTD_ASQ
void oneloop_from_nav(bool in_flight)
Function that maps navigation inputs to the oneloop controller for the generated autopilot.
#define GUIDANCE_INDI_POS_GAIN
struct PolePlacement p_alt_rm
void oneloop_andi_RM(bool half_loop, struct FloatVect3 PSA_des, int rm_order_h, int rm_order_v)
Function to generate the reference signals for the oneloop controller.
struct Gains2ndOrder k_head_e
static float positive_non_zero(float input)
Function to make sure that inputs are positive non zero vaues.
void rm_3rd(float dt, float *x_ref, float *x_d_ref, float *x_2d_ref, float *x_3d_ref, float x_des, float k1_rm, float k2_rm, float k3_rm)
Reference Model Definition for 3rd order system.
float andi_u[ANDI_NUM_ACT_TOT]
void calc_normalization(void)
Calculate Normalization of actuators and discrete actuator dynamics
#define ONELOOP_ANDI_FILT_CUTOFF_R
void oneloop_andi_run(bool in_flight, bool half_loop, struct FloatVect3 PSA_des, int rm_order_h, int rm_order_v)
Main function that runs the controller and performs control allocation.
struct PolePlacement p_att_e
struct PolePlacement p_alt_e
void rm_2nd_pos(float dt, float x_d_ref[], float x_2d_ref[], float x_3d_ref[], float x_d_des[], float k2_rm[], float k3_rm[], float x_2d_bound, float x_3d_bound, int n)
Reference Model Definition for 3rd order system specific to positioning with bounds.
static float andi_du_n[ANDI_NUM_ACT_TOT]
void get_act_state_oneloop(void)
Function to reconstruct actuator state using first order dynamics.
static float k_e_1_2_f(float p1, float p2)
#define GUIDANCE_INDI_LIFTD_P50
static float ec_2rd(float x_ref, float x_d_ref, float x_2d_ref, float x, float x_d, float k1_e, float k2_e)
Error Controller Definition for 2rd order system.
struct PolePlacement p_head_e
#define ONELOOP_ANDI_FILT_CUTOFF_Q
float g2_1l[ANDI_NUM_ACT_TOT]
float andi_du[ANDI_NUM_ACT_TOT]
struct Int32Quat stab_att_sp_quat_1l
static float nav_target[3]
void err_nd(float err[], float a[], float b[], float k[], int n)
Calculate Scaled Error between two 3D arrays.
static float k_e_1_3_f_v2(float omega_n, UNUSED float zeta, float p1)
void calc_model(void)
Function that calculates the model prediction for the complementary filter.
struct OneloopGeneral oneloop_andi
float ratio_vn_v[ANDI_NUM_ACT_TOT]
struct Gains3rdOrder k_pos_rm
static float use_increment
static struct FirstOrderLowPass model_pred_a_filt[3]
static float Wv[ANDI_OUTPUTS]
#define ONELOOP_ANDI_AC_HAS_PUSHER
void init_controller(void)
Initialize Controller Gains FIXME: Calculate the gains dynamically for transition.
static float k_e_2_3_f(float p1, float p2, float p3)
static void send_guidance_oneloop_andi(struct transport_tx *trans, struct link_device *dev)
float act_max[ANDI_NUM_ACT_TOT]
void rm_3rd_head(float dt, float *x_ref, float *x_d_ref, float *x_2d_ref, float *x_3d_ref, float x_des, float k1_rm, float k2_rm, float k3_rm)
Reference Model Definition for 3rd order system specific to the heading angle.
void rm_3rd_pos(float dt, float x_ref[], float x_d_ref[], float x_2d_ref[], float x_3d_ref[], float x_des[], float k1_rm[], float k2_rm[], float k3_rm[], float x_d_bound, float x_2d_bound, float x_3d_bound, int n)
Reference Model Definition for 3rd order system specific to positioning with bounds.
void oneloop_andi_enter(bool half_loop_sp)
Function that resets important values upon engaging Oneloop ANDI.
struct FloatEulers eulers_zxy
void oneloop_andi_init(void)
Init function of Oneloop ANDI controller
static float Wu[ANDI_NUM_ACT_TOT]
void float_rates_of_euler_dot_vec(float r[3], float e[3], float edot[3])
Attitude Rates to Euler Conversion Function.
float oneloop_andi_filt_cutoff_p
static float k_rm_1_3_f(float omega_n, float zeta, float p1)
Reference Model Gain Design.
static Butterworth2LowPass att_dot_meas_lowpass_filters[3]
static float k_e_2_2_f(float p1, float p2)
#define ONELOOP_ANDI_FILT_CUTOFF_P
struct PolePlacement p_pos_rm
#define GUIDANCE_INDI_POS_GAINZ
void sum_g1g2_1l(void)
Function that sums g1 and g2 to obtain the g1_g2 matrix.
void vect_bound_nd(float vect[], float bound, int n)
Scale a 3D array to within a 3D bound.
static float k_rm_2_2_f(float omega_n, float zeta)
void integrate_nd(float dt, float a[], float a_dot[], int n)
Integrate in time 3D array.
static void send_oneloop_andi(struct transport_tx *trans, struct link_device *dev)
float act_min[ANDI_NUM_ACT_TOT]
float actuator_state_1l[ANDI_NUM_ACT]
void rm_2nd(float dt, float *x_ref, float *x_d_ref, float *x_2d_ref, float x_des, float k1_rm, float k2_rm)
Reference Model Definition for 2nd order system.
static void send_eff_mat_g_oneloop_andi(struct transport_tx *trans, struct link_device *dev)
float * bwls_1l[ANDI_OUTPUTS]
static float k_rm_1_2_f(float omega_n, float zeta)
#define GUIDANCE_INDI_LIFTD_P80
static float k_rm_2_3_f(float omega_n, float zeta, float p1)
#define GUIDANCE_INDI_SPEED_GAIN
static float u_pref[ANDI_NUM_ACT_TOT]
float oneloop_andi_filt_cutoff
struct OneloopGuidanceState gui_state
struct OneloopStabilizationState sta_state
struct OneloopGuidanceRef gui_ref
struct OneloopStabilizationRef sta_ref
Paparazzi floating point algebra.
vector in North East Down coordinates Units: meters
Generic interface for radio control modules.
static pprz_t radio_control_get(uint8_t idx)
Get a radio control channel value.
#define RADIO_ROLL
Redefining RADIO_* Do not use with radio.h (ppm rc)
#define AP_MODE_ATTITUDE_DIRECT
struct RotorcraftNavigation nav
Rotorcraft navigation functions.
struct EnuCoor_f speed
speed setpoint (in m/s)
float climb
climb setpoint (in m/s)
#define NAV_SETPOINT_MODE_SPEED
#define NAV_VERTICAL_MODE_CLIMB
float nav_altitude
current altitude setpoint (in meters): might differ from fp_altitude depending on altitude shift from...
#define NAV_VERTICAL_MODE_ALT
struct EnuCoor_f carrot
carrot position (also used for GCS display)
#define NAV_SETPOINT_MODE_POS
Nav setpoint modes these modes correspond to submodes defined by navigation routines to tell which se...
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
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.
short int16_t
Typedef defining 16 bit short type.
signed char int8_t
Typedef defining 8 bit char type.
int wls_alloc(float *u, float *v, float *umin, float *umax, float **B, float *u_guess, float *W_init, float *Wv, float *Wu, float *up, float gamma_sq, int imax, int n_u, int n_v)
active set algorithm for control allocation