83#include "generated/airframe.h"
92#ifndef ONELOOP_NB_SIMPLE_QUAD
110#ifndef ONELOOP_NB_DEBUG_MODE
111#define ONELOOP_NB_DEBUG_MODE FALSE
115static float dt_1l = 1. / PERIODIC_FREQUENCY;
116static float g = 9.81;
118#define IDX_aD RW_aD - 2
119#define IDX_ap RW_ap - 2
120#define IDX_aq RW_aq - 2
121#define IDX_ar RW_ar - 2
127#ifdef ONELOOP_NB_FILT_CUTOFF
133#ifdef ONELOOP_NB_FILT_CUTOFF_ACC
139#ifdef ONELOOP_NB_FILT_CUTOFF_VEL
145#ifdef ONELOOP_NB_FILT_CUTOFF_P
146#define ONELOOP_NB_FILTER_ROLL_RATE TRUE
152#ifdef ONELOOP_NB_FILT_CUTOFF_Q
153#define ONELOOP_NB_FILTER_PITCH_RATE TRUE
159#ifdef ONELOOP_NB_FILT_CUTOFF_R
160#define ONELOOP_NB_FILTER_YAW_RATE TRUE
166PRINT_CONFIG_MSG(
"============================================================")
174PRINT_CONFIG_MSG(
"============================================================")
175PRINT_CONFIG_MSG(
"============================================================")
181PRINT_CONFIG_MSG(
"============================================================")
197#ifndef ONELOOP_NB_NUM_THRUSTERS
203#ifdef ONELOOP_NB_ACT_IS_SERVO
209#ifdef ONELOOP_NB_ACT_DYN
213#error "You must specify the actuator dynamics"
218#ifdef ONELOOP_NB_ACT_MAX
224#ifdef ONELOOP_NB_ACT_MIN
230#ifdef ONELOOP_NB_ACT_MAX_NORM
236#ifdef ONELOOP_NB_ACT_MIN_NORM
242#ifdef ONELOOP_NB_NU_NORM_MAX
248#ifdef ONELOOP_NB_U_PREF
254PRINT_CONFIG_MSG(
"============================================================")
259PRINT_CONFIG_MSG(
"============================================================")
261#ifdef ONELOOP_NB_MAX_BANK
262float max_bank = ONELOOP_NB_MAX_BANK;
267#ifdef ONELOOP_NB_MAX_PHI
268float max_phi = ONELOOP_NB_MAX_PHI;
273#ifdef ONELOOP_NB_MAX_THETA
279#ifndef ONELOOP_THETA_PREF_MAX
285PRINT_CONFIG_MSG(
"============================================================")
289PRINT_CONFIG_MSG(
"============================================================")
291#if ANDI_NUM_ACT_TOT != WLS_N_U_MAX
292#error Matrix-WLS_N_U_MAX is not equal to the number of actuators: define WLS_N_U_MAX == ANDI_NUM_ACT_TOT in airframe file
293#define WLS_N_U_MAX == ANDI_NUM_ACT_TOT
295#if ANDI_OUTPUTS != WLS_N_V_MAX
296#error Matrix-WLS_N_V_MAX is not equal to the number of controlled axis: define WLS_N_V_MAX == ANDI_OUTPUTS in airframe file
297#define WLS_N_V_MAX == ANDI_OUTPUTS
309#ifndef ONELOOP_NB_MAX_FAULT_MOT
310#define ONELOOP_NB_MAX_FAULT_MOT 3000.0
313 "ONELOOP_NB_MAX_FAULT_MOT must be in [0, 9600] pprz");
321float max_r = RadOfDeg(MAX_R);
324#ifdef ONELOOP_NB_YAW_DISTURBANCE_LIMIT
330#if ONELOOP_NB_HEADING_MANUAL
336#if ONELOOP_NB_YAW_STICK_IN_AUTO
344#ifdef ONELOOP_NB_MAX_ANGULAR_JERK
345 .att_3d[0] = ONELOOP_NB_MAX_ANGULAR_JERK,
346 .att_3d[1] = ONELOOP_NB_MAX_ANGULAR_JERK,
348 .att_3d[0] = RadOfDeg(100000.0),
349 .att_3d[1] = RadOfDeg(100000.0),
352#ifdef ONELOOP_NB_MAX_ANGULAR_JERK_YAW
353 .att_3d[2] = ONELOOP_NB_MAX_ANGULAR_JERK_YAW,
355 .att_3d[2] = RadOfDeg(100000.0),
358#ifdef ONELOOP_NB_MAX_ANGULAR_ACCEL
359 .att_2d[0] = ONELOOP_NB_MAX_ANGULAR_ACCEL,
360 .att_2d[1] = ONELOOP_NB_MAX_ANGULAR_ACCEL,
362 .att_2d[0] = RadOfDeg(700.0),
363 .att_2d[1] = RadOfDeg(480.0),
366#ifdef ONELOOP_NB_MAX_ANGULAR_ACCEL_YAW
367 .att_2d[2] = ONELOOP_NB_MAX_ANGULAR_ACCEL_YAW,
369 .att_2d[2] = RadOfDeg(480.0),
372#ifdef ONELOOP_NB_MAX_ANGULAR_VEL
373 .att_d[0] = ONELOOP_NB_MAX_ANGULAR_VEL,
374 .att_d[1] = ONELOOP_NB_MAX_ANGULAR_VEL,
376 .att_d[0] = RadOfDeg(10000.0),
377 .att_d[1] = RadOfDeg(10000.0),
380#ifdef ONELOOP_NB_MAX_ANGULAR_VEL_YAW
381 .att_d[2] = ONELOOP_NB_MAX_ANGULAR_VEL_YAW,
383 .att_d[2] = RadOfDeg(10000.0),
394#ifndef ONELOOP_NB_AIRSPEED_SWITCH_THRESHOLD
395#define ONELOOP_NB_AIRSPEED_SWITCH_THRESHOLD 10.0
398#ifndef FWD_SIDESLIP_GAIN
404#ifdef NAV_HYBRID_MAX_DECELERATION
410#ifdef ONELOOP_NB_MAX_LINEAR_JERK
411float max_j_lin = ONELOOP_NB_MAX_LINEAR_JERK;
416#ifdef NAV_HYBRID_MAX_AIRSPEED
422#ifdef NAV_HYBRID_MAX_SPEED_V
428#define USE_ND_VELOCITIES
440#ifndef ONELOOP_NB_WU_QUAD_MOTORS_FWD
498#ifndef ONELOOP_NB_FAULT_AILERONS
499#define ONELOOP_NB_FAULT_AILERONS TRUE
521#ifdef ONELOOP_NB_DELTA_FAULT
530#ifndef ONELOOP_NB_SPIN_PROT_MAX_RATE
531#define ONELOOP_NB_SPIN_PROT_MAX_RATE 34.0
533#ifndef ONELOOP_NB_SPIN_PROT_START_RATE
534#define ONELOOP_NB_SPIN_PROT_START_RATE 28.0
536#ifndef ONELOOP_NB_SPIN_PROT_MAX_CMD
537#define ONELOOP_NB_SPIN_PROT_MAX_CMD 4800.0
547#ifndef ONELOOP_NB_SPIN_TRIM_ON
548#define ONELOOP_NB_SPIN_TRIM_ON TRUE
550#ifndef ONELOOP_NB_SPIN_TRIM_RATE
551#define ONELOOP_NB_SPIN_TRIM_RATE 1000.0
553#ifndef ONELOOP_NB_SPIN_TRIM_BLEED_RATE
554#define ONELOOP_NB_SPIN_TRIM_BLEED_RATE 1000.0
556#ifndef ONELOOP_NB_SPIN_TRIM_RELEASE_RATE
557#define ONELOOP_NB_SPIN_TRIM_RELEASE_RATE 24.0
564#ifndef ONELOOP_NB_SPIN_PROT_MIN_GAP
565#define ONELOOP_NB_SPIN_PROT_MIN_GAP 1.0
570 "ONELOOP_NB_SPIN_PROT_MIN_GAP must be in [0.1, 10] rad/s");
572 "ONELOOP_NB_SPIN_PROT_MAX_RATE must be <= 60 rad/s");
574 "ONELOOP_NB_SPIN_PROT_START_RATE must be at least SPIN_PROT_MIN_GAP below SPIN_PROT_MAX_RATE");
577 "ONELOOP_NB_SPIN_TRIM_RELEASE_RATE must be >= 0 and at least SPIN_PROT_MIN_GAP below SPIN_PROT_START_RATE");
579 "ONELOOP_NB_SPIN_PROT_MAX_CMD must be in [0, MAX_PPRZ]");
581 "ONELOOP_NB_SPIN_TRIM_RATE must be in [0, 1000] pprz/s");
583 "ONELOOP_NB_SPIN_TRIM_BLEED_RATE must be in [0, 1000] pprz/s");
585#ifndef ONELOOP_NB_SPIN_MAN_RAMP_RATE
586#define ONELOOP_NB_SPIN_MAN_RAMP_RATE 2.0
588#ifndef ONELOOP_NB_SPIN_MAN_BLEND_TIME
589#define ONELOOP_NB_SPIN_MAN_BLEND_TIME 1.0
591#ifndef ONELOOP_NB_SPIN_MAN_TRIM_RATE
592#define ONELOOP_NB_SPIN_MAN_TRIM_RATE 300.0
594#ifndef ONELOOP_NB_SPIN_MAN_DONE_RATE
595#define ONELOOP_NB_SPIN_MAN_DONE_RATE 0.5
597#define SPIN_MAN_PAIR_PITCH 0
598#define SPIN_MAN_PAIR_ROLL 1
599#ifndef ONELOOP_NB_SPIN_MAN_PAIR
600#define ONELOOP_NB_SPIN_MAN_PAIR SPIN_MAN_PAIR_PITCH
602#ifndef ONELOOP_NB_SPIN_MAN_PITCH_DIR
603#define ONELOOP_NB_SPIN_MAN_PITCH_DIR 1.0
606 "ONELOOP_NB_SPIN_MAN_PAIR must be 0 (pitch) or 1 (roll)");
608 "ONELOOP_NB_SPIN_MAN_PITCH_DIR must be 1 or -1");
610 "ONELOOP_NB_SPIN_MAN_RAMP_RATE must be in [0.1, 10] rad/s^2");
612 "ONELOOP_NB_SPIN_MAN_BLEND_TIME must be in [0.1, 5] s");
614 "ONELOOP_NB_SPIN_MAN_TRIM_RATE must be in [0, 1000] pprz/s");
616 "ONELOOP_NB_SPIN_MAN_DONE_RATE must be in [0.1, 5] rad/s");
618#ifndef ONELOOP_NB_EC_K3
619#define ONELOOP_NB_EC_K3 22.0
625#ifndef ONELOOP_NB_PID_A_MAX
626#define ONELOOP_NB_PID_A_MAX 0.6
628#ifndef ONELOOP_NB_PID_V_MAX_MANUAL
629#define ONELOOP_NB_PID_V_MAX_MANUAL 3.0
631#ifndef ONELOOP_NB_PID_V_MAX_NAV
632#define ONELOOP_NB_PID_V_MAX_NAV 3.0
636 "ONELOOP_NB_PID_V_MAX_MANUAL must be in [0.1, 10] m/s");
638 "ONELOOP_NB_PID_V_MAX_NAV must be in [0.1, 10] m/s");
669#ifdef ONELOOP_NB_SLOW_POLE
723void err_nd(
float err[],
float a[],
float b[],
float k[],
int n);
724void err_sum_nd(
float err[],
float a[],
float b[],
float k[],
float c[],
int n);
726void integrate_nd(
float dt,
float a[],
float a_dot[],
int n);
731void 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], struct
OneloopStabilizationRef bounds);
732void 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);
733void 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);
734void 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);
736void ec_3rd_att(
float y_4d[3],
float x_des[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], struct
OneloopStabilizationRef bounds,
float fb[3]);
737void ec_3rd_pos(
float y_4d[],
float x_des[],
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[],
float x_d_bound,
float x_2d_bound,
float fb[],
int n);
740void chirp_pos(
float time_elapsed,
float f0,
float f1,
float t_chirp,
float A,
int8_t n,
float psi,
float p_ref[],
float v_ref[],
float a_ref[],
float j_ref[],
float p_ref_0[]);
741void chirp_call(
bool*
chirp_on,
bool*
chirp_first_call,
float*
t_0_chirp,
float* time_elapsed,
float f0,
float f1,
float t_chirp,
float A,
int8_t n,
float psi,
float p_ref[],
float v_ref[],
float a_ref[],
float j_ref[],
float p_ref_0[]);
751float cos_2n(
float psi,
float xi,
int n);
753float xi_fun(
float r,
float w,
float aN_des,
float aE_des);
754float pusher_cmd_fun(
float aN_des,
float aE_des,
float r,
float psi,
float w,
int n);
758#if PERIODIC_TELEMETRY
772 pprz_msg_send_EFF_MAT_STAB(trans,
dev, AC_ID,
778 pprz_msg_send_EFF_MAT_STAB(trans,
dev, AC_ID,
790 pprz_msg_send_EFF_MAT_STAB_THRUST(trans,
dev, AC_ID,
795 pprz_msg_send_EFF_MAT_STAB_THRUST(trans,
dev, AC_ID,
803 pprz_msg_send_EFF_MAT_GUID(trans,
dev, AC_ID,
811 pprz_msg_send_STAB_ATTITUDE(trans,
dev, AC_ID,
812 3, temp_eulers_zxy_des,
834 pprz_msg_send_NB_CTRL(trans,
dev, AC_ID,
848 pprz_msg_send_GUIDANCE(trans,
dev, AC_ID,
872#ifdef PPRZ_MSG_ID_PUSH_NB
873static void send_PUSH_NB(
struct transport_tx *trans,
struct link_device *
dev)
876 pprz_msg_send_PUSH_NB(trans,
dev, AC_ID,
894static void debug_vect(
struct transport_tx *trans,
struct link_device *
dev,
char *name,
float *data,
int datasize)
896 pprz_msg_send_DEBUG_VECT(trans,
dev, AC_ID,
903 float temp_debug_vect[20];
906 temp_debug_vect[2] =
oneloop_nB.sta_state.att_d[2];
907 temp_debug_vect[3] =
LP.r.meas;
908 temp_debug_vect[4] =
SQ_r;
913 temp_debug_vect[9] =
andi_u[COMMAND_MOTOR_FRONT];
914 temp_debug_vect[10] =
andi_u[COMMAND_MOTOR_RIGHT];
915 temp_debug_vect[11] =
andi_u[COMMAND_MOTOR_BACK];
916 temp_debug_vect[12] =
andi_u[COMMAND_MOTOR_LEFT];
1018 if (!in_flight || !nb_ctrl)
1024 float abs_r = fabsf(r);
1111 if (input < FLT_EPSILON)
1118void err_nd(
float err[],
float a[],
float b[],
float k[],
int n)
1121 for (i = 0; i < n; i++)
1123 err[i] = k[i] * (a[i] -
b[i]);
1127void err_sum_nd(
float err[],
float a[],
float b[],
float k[],
float c[],
int n)
1130 for (i = 0; i < n; i++)
1132 err[i] = k[i] * (a[i] -
b[i]);
1139 err[0] = (a[0] -
b[0]);
1140 err[1] = (a[1] -
b[1]);
1141 err[2] = (a[2] -
b[2]);
1142 NormRadAngle(err[2]);
1148 for (i = 0; i < n; i++)
1150 a[i] = a[i] + dt * a_dot[i];
1158 if ((norm - bound) > FLT_EPSILON)
1160 float scale = bound / norm;
1162 for (i = 0; i < n; i++)
1176 return (omega_n * omega_n * p1) / (omega_n * omega_n + omega_n * p1 * zeta * 2.0);
1183 return (omega_n * omega_n + omega_n * p1 * zeta * 2.0) / (p1 + omega_n * zeta * 2.0);
1190 return p1 + omega_n * zeta * 2.0;
1229static inline bool vec3_saturated(
const float u_unsat[3],
const float u_sat[3],
float eps)
1231 return (fabsf(u_sat[0] - u_unsat[0]) > eps) ||
1232 (fabsf(u_sat[1] - u_unsat[1]) > eps) ||
1233 (fabsf(u_sat[2] - u_unsat[2]) > eps);
1238 const float u_unsat[3],
1239 const float u_sat[3],
1240 const float I_prev[3],
1241 const float I_cand[3],
1244 const float eps = 1e-6f;
1248 I_next[0] = I_cand[0];
1249 I_next[1] = I_cand[1];
1250 I_next[2] = I_cand[2];
1254 const float ds0 = u_unsat[0] - u_sat[0];
1255 const float ds1 = u_unsat[1] - u_sat[1];
1256 const float ds2 = u_unsat[2] - u_sat[2];
1259 const float dot_err_ds = err[0] * ds0 + err[1] * ds1 + err[2] * ds2;
1261 if (dot_err_ds < 0.0f)
1263 I_next[0] = I_cand[0];
1264 I_next[1] = I_cand[1];
1265 I_next[2] = I_cand[2];
1269 I_next[0] = I_prev[0];
1270 I_next[1] = I_prev[1];
1271 I_next[2] = I_prev[2];
1276 const float x_dot[3],
1278 float a_sp[3],
float a_max,
float v_max)
1280 static float prev_vel[3] = {0.f, 0.f, 0.f};
1281 static float integral[3] = {0.f, 0.f, 0.f};
1285 const float I_MAX = 0.4f;
1297 for (
int i = 0; i < 3; i++)
1302 I_cand[i] = integral[i] + err[i] *
dt_1l;
1303 BoundAbs(I_cand[i], I_MAX);
1306 const float vel_dot_nd = (x_dot[i] - prev_vel[i]) /
dt_1l;
1308 prev_vel[i] = x_dot[i];
1310 const float vel_dot_filt =
KPID_filt[i].o[0];
1313 a_unsat[i] =
k_P * err[i] +
k_I * I_cand[i] -
k_D * vel_dot_filt;
1314 a_sat[i] = a_unsat[i];
1321 ARW_ClampVec3(err, a_unsat, a_sat, integral, I_cand, I_next);
1324 integral[0] = I_next[0];
1325 integral[1] = I_next[1];
1326 integral[2] = I_next[2];
1335 const float x_dot[3],
1337 float a_sp[3],
float a_max,
float v_max)
1339 static float prev_vel[3] = {0.f, 0.f, 0.f};
1340 static float integral[3] = {0.f, 0.f, 0.f};
1344 const float I_MAX = 0.4f;
1356 for (
int i = 0; i < 3; i++)
1358 v_d[i] = (x_des[i] - x[i]) *
k_K;
1362 for (
int i = 0; i < 3; i++)
1367 I_cand[i] = integral[i] + err[i] *
dt_1l;
1368 BoundAbs(I_cand[i], I_MAX);
1371 const float vel_dot_nd = (x_dot[i] - prev_vel[i]) /
dt_1l;
1373 prev_vel[i] = x_dot[i];
1375 const float vel_dot_filt =
KPID_filt[i].o[0];
1378 a_unsat[i] =
k_P * err[i] +
k_I * I_cand[i] -
k_D * vel_dot_filt;
1379 a_sat[i] = a_unsat[i];
1386 ARW_ClampVec3(err, a_unsat, a_sat, integral, I_cand, I_next);
1389 integral[0] = I_next[0];
1390 integral[1] = I_next[1];
1391 integral[2] = I_next[2];
1408 float spsi = sinf(psi);
1409 float cpsi = cosf(psi);
1410 float aX = cpsi * a[0] + spsi * a[1];
1411 float aY = -spsi * a[0] + cpsi * a[1];
1412 theta_des = asinf(-aX);
1413 float ctheta_des = cosf(theta_des);
1414 if (fabs(ctheta_des) < FLT_EPSILON)
1416 ctheta_des = FLT_EPSILON;
1418 phi_des = asinf(aY / ctheta_des);
1441 float sphi = sinf(e[0]);
1442 float cphi = cosf(e[0]);
1443 float stheta = sinf(e[1]);
1444 float ctheta = cosf(e[1]);
1445 r[0] = ctheta * edot[0] - stheta * cphi * edot[2];
1446 r[1] = edot[1] + sphi * edot[2];
1447 r[2] = stheta * edot[0] + ctheta * cphi * edot[2];
1469 float sphi = sinf(e[0]);
1470 float cphi = cosf(e[0]);
1471 float stheta = sinf(e[1]);
1472 float ctheta = cosf(e[1]);
1473 float spsi = sinf(e[2]);
1474 float cpsi = cosf(e[2]);
1476 if (fabs(ctheta) < FLT_EPSILON)
1478 ctheta = FLT_EPSILON;
1480 edot[0] = r[0] + spsi * stheta / ctheta * r[1] + cpsi * stheta / ctheta * r[2];
1481 edot[1] = cphi * r[1] - sphi * r[2];
1482 edot[2] = sphi * r[1] + cphi * r[2];
1490 float v[2] = {vect->
x, vect->
y};
1491 float sign_v0 = (
v[0] > 0.f) ? 1.f : (
v[0] < 0.f) ? -1.f
1493 float sign_v1 = (
v[1] > 0.f) ? 1.f : (
v[1] < 0.f) ? -1.f
1499 if ((norm - bound) > FLT_EPSILON)
1501 v[0] =
Min(
v[0], bound);
1502 float acc_b_y_2 = bound * bound -
v[0] *
v[0];
1504 v[1] = sqrtf(acc_b_y_2);
1506 vect->
x = sign_v0 *
v[0];
1507 vect->
y = sign_v1 *
v[1];
1521 norm = fmaxf(norm, 1.0);
1522 float v_bound_a = sqrtf(fabs(2.0 * a_bound * norm *
xdot_lim_sf));
1523 return fminf(v_bound, v_bound_a);
1539 float v_bound_a = sqrtf(fabs(2.0 * a_bound * norm *
xdot_lim_sf));
1540 return fminf(v_bound, v_bound_a);
1559void 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],
struct OneloopStabilizationRef bounds)
1564 float x_d_fw_rates[3];
1567 float bounds_att_d[3];
1568 float x_d_eul_ref[3];
1571 x_d_fw[0] = e_x[0] * k1_rm[0];
1572 x_d_fw[1] = e_x[1] * k1_rm[1];
1573 x_d_fw[2] = e_x[2] * k1_rm[2];
1578 BoundAbs(x_d_fw_rates[0], bounds_att_d[0]);
1579 BoundAbs(x_d_fw_rates[1], bounds_att_d[1]);
1580 BoundAbs(x_d_fw_rates[2], bounds_att_d[2]);
1582 err_nd(x_2d_fw, x_d_fw_rates, x_d_ref, k2_rm, 3);
1583 BoundAbs(x_2d_fw[0], bounds.
att_2d[0]);
1584 BoundAbs(x_2d_fw[1], bounds.
att_2d[1]);
1585 BoundAbs(x_2d_fw[2], bounds.
att_2d[2]);
1587 err_nd(x_3d_fw, x_2d_fw, x_2d_ref, k3_rm, 3);
1588 BoundAbs(x_3d_fw[0], bounds.
att_3d[0]);
1589 BoundAbs(x_3d_fw[1], bounds.
att_3d[1]);
1590 BoundAbs(x_3d_fw[2], bounds.
att_3d[2]);
1595 x_3d_ref[2] = psi_overwrite[3];
1601 x_2d_ref[2] = psi_overwrite[2];
1607 x_d_ref[2] = psi_overwrite[1];
1614 x_ref[2] = psi_overwrite[0];
1616 NormRadAngle(x_ref[2]);
1635void 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)
1640 err_nd(e_x, x_des, x_ref, k1_rm, n);
1643 err_nd(e_x_d, e_x, x_d_ref, k2_rm, n);
1645 err_nd(e_x_2d, e_x_d, x_2d_ref, k3_rm, n);
1666void 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)
1670 err_nd(e_x_d, x_d_des, x_d_ref, k2_rm, n);
1672 err_nd(e_x_2d, e_x_d, x_2d_ref, k3_rm, n);
1689void 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)
1692 err_nd(e_x_2d, x_2d_des, x_2d_ref, k3_rm, n);
1714void ec_3rd_pos(
float y_4d[],
float x_des[],
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[],
float x_d_bound,
float x_2d_bound,
float fb[],
int n)
1721 err_sum_nd(e_x_d, x_ref, x, k1_e, x_d_ref, n);
1723 err_sum_nd(e_x_2d, e_x_d, x_d, k2_e, x_2d_ref, n);
1728 err_sum_nd(y_4d, e_x_2d, dist, k3_e, x_3d_ref, n);
1746void ec_3rd_att(
float y_4d[3],
float x_des[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],
struct OneloopStabilizationRef bounds,
float fb[3])
1751 float x_d_fw_rates[3];
1752 float x_d_fw_rates_rm[3];
1754 float bounds_att_d[3];
1757 x_d_fw[0] = e_x[0] * k1_e[0];
1758 x_d_fw[1] = e_x[1] * k1_e[1];
1759 x_d_fw[2] = e_x[2] * k1_e[2];
1766 BoundAbs(x_d_fw_rates_rm[0], bounds_att_d[0]);
1767 BoundAbs(x_d_fw_rates_rm[1], bounds_att_d[1]);
1768 BoundAbs(x_d_fw_rates_rm[2], bounds_att_d[2]);
1770 x_2d_fw[0] = (x_d_fw_rates_rm[0] - x_d[0]) * k2_e[0] + x_2d_ref[0];
1771 x_2d_fw[1] = (x_d_fw_rates_rm[1] - x_d[1]) * k2_e[1] + x_2d_ref[1];
1772 x_2d_fw[2] = (x_d_fw_rates_rm[2] - x_d[2]) * k2_e[2] + x_2d_ref[2];
1779 fb_k3[0] = fb[0] / k3_e[0];
1780 fb_k3[1] = fb[1] / k3_e[1];
1781 fb_k3[2] = fb[2] / k3_e[2];
1786 err_sum_nd(y_4d, x_2d_fw, dist, k3_e, x_3d_ref, 3);
1875 float max_wind = 20.0;
1914 Bound(
ec_k3, 1.0, 100.0);
2073 LP->tau = 1 / (2 * M_PI *
LP->freq);
2076#elif defined(USE_BW2)
2078#elif defined(USE_YAW_LP4)
2084 LP->meas_prev = 0.0;
2090 if (
LP->freq !=
LP->freq_set || reinit)
2092 LP->freq =
LP->freq_set;
2093 LP->tau = 1 / (2 * M_PI *
LP->freq);
2100 if (
LP->freq !=
LP->freq_set || reinit)
2102 LP->freq =
LP->freq_set;
2103 LP->tau = 1 / (2 * M_PI *
LP->freq);
2146 bool reinit_other = ((
LP.p_dot.freq !=
LP.p_dot.freq_set) || reinit);
2163 for (
int i = 0; i < 3; i++)
2182 float tau_r = 1.0 / (5.0);
2187 for (
int i = 0; i < 3; i++)
2200 for (
int i = 0; i < 3; i++)
2215#ifdef USE_ND_VELOCITIES
2216 static bool vel_inited =
false;
2220 veloc_prev = *veloc;
2223 LP.ax.meas = (veloc->
x - veloc_prev.
x) * PERIODIC_FREQUENCY;
2224 LP.ay.meas = (veloc->
y - veloc_prev.
y) * PERIODIC_FREQUENCY;
2225 LP.az.meas = (veloc->
z - veloc_prev.
z) * PERIODIC_FREQUENCY;
2226 veloc_prev = *veloc;
2229 LP.ax.meas = accel->
x;
2230 LP.ay.meas = accel->
y;
2231 LP.az.meas = accel->
z;
2233 LP.p.meas_prev =
LP.p.meas;
2234 LP.q.meas_prev =
LP.q.meas;
2235 LP.r.meas_prev =
LP.r.meas;
2236 LP.p.meas = body_rates->
p;
2237 LP.q.meas = body_rates->
q;
2238 LP.r.meas = body_rates->
r;
2239 LP.p_dot.meas_prev =
LP.p_dot.meas;
2240 LP.q_dot.meas_prev =
LP.q_dot.meas;
2241 LP.r_dot.meas_prev =
LP.r_dot.meas;
2242 LP.p_dot.meas = (
LP.p.meas -
LP.p.meas_prev) * PERIODIC_FREQUENCY;
2243 LP.q_dot.meas = (
LP.q.meas -
LP.q.meas_prev) * PERIODIC_FREQUENCY;
2244 LP.r_dot.meas = (
LP.r.meas -
LP.r.meas_prev) * PERIODIC_FREQUENCY;
2245 LP.p_ddot.meas = (
LP.p_dot.meas -
LP.p_dot.meas_prev) * PERIODIC_FREQUENCY;
2246 LP.q_ddot.meas = (
LP.q_dot.meas -
LP.q_dot.meas_prev) * PERIODIC_FREQUENCY;
2247 LP.r_ddot.meas = (
LP.r_dot.meas -
LP.r_dot.meas_prev) * PERIODIC_FREQUENCY;
2265 Bound(airspeed_meas, 0.0, 30.0);
2328#if PERIODIC_TELEMETRY
2335#ifdef PPRZ_MSG_ID_PUSH_NB
2379 float radio_thrust_cmd = 0.0;
2380 float radio_roll_cmd = 0.0;
2381 float radio_pitch_cmd = 0.0;
2420#ifdef ROTWING_EFF_SCHED_MP_dFdu
2448 x_dot_des_NE.
x = x_dot_des[0] * cos_psi - x_dot_des[1] * sin_psi;
2449 x_dot_des_NE.
y = x_dot_des[0] * sin_psi + x_dot_des[1] * cos_psi;
2450 x_dot_des[0] = x_dot_des_NE.
x;
2451 x_dot_des[1] = x_dot_des_NE.
y;
2456 oneloop_nB.sta_nB_state.nI_des.x = acc_des[0];
2457 oneloop_nB.sta_nB_state.nI_des.y = acc_des[1];
2458 oneloop_nB.sta_nB_state.nI_des.z = acc_des[2];
2462 oneloop_nB.sta_nB_state.nI_des.x = -stheta_des;
2463 oneloop_nB.sta_nB_state.nI_des.y = sphi_des * ctheta_des;
2464 oneloop_nB.sta_nB_state.nI_des.z = -cphi_des * ctheta_des;
2470 nI_des_NED.
x =
oneloop_nB.sta_nB_state.nI_des.x * cos_psi -
oneloop_nB.sta_nB_state.nI_des.y * sin_psi;
2471 nI_des_NED.
y =
oneloop_nB.sta_nB_state.nI_des.x * sin_psi +
oneloop_nB.sta_nB_state.nI_des.y * cos_psi;
2481 BoundAbs(des_r,
max_r);
2483 float delta_psi_des_rad = des_r *
dt_1l;
2485 NormRadAngle(delta_psi_rad);
2486 if (fabs(delta_psi_rad) > RadOfDeg(30.0))
2488 delta_psi_des_rad = 0.0;
2495 Bound(radio_thrust_cmd, 0.0,
MAX_PPRZ);
2540 oneloop_nB.sta_nB_state.nI_des.x = acc_des[0];
2541 oneloop_nB.sta_nB_state.nI_des.y = acc_des[1];
2542 oneloop_nB.sta_nB_state.nI_des.z = acc_des[2];
2557#ifdef ROTWING_EFF_SCHED_MP_dFdu
2569#ifdef ROTWING_EFF_SCHED_MP_dFdu
2585 float push_delta_v[2];
2591 float push_delta_v_norm = sqrtf(push_delta_v[0] * push_delta_v[0] + push_delta_v[1] * push_delta_v[1]);
2592 float r_int_sol =
oneloop_nB.sta_state.att_d[2];
2593 BoundAbs(r_int_sol, 5.0);
2594 float push_cmd_A = fabs(r_int_sol) * sqrtf((
float)
oneloop_nB.push_nB.n) / (2.0 * sqrtf((
float)M_PI) *
RW.mP.dFdu /
RW.m) * push_delta_v_norm;
2595 Bound(push_cmd_A, 0.0f,
oneloop_nB.push_nB.max_push_cmd);
2606 commands[COMMAND_MOTOR_PUSHER] = 0;
2610 if (!in_flight_oneloop)
2626#define OVERRIDE_ATT_RM
2627#ifdef OVERRIDE_ATT_RM
2636 static float psi_vec[4] = {0.0, 0.0, 0.0, 0.0};
2637 rm_3rd_attitude(
dt_1l,
oneloop_nB.sta_ref.att,
oneloop_nB.sta_ref.att_d,
oneloop_nB.sta_ref.att_2d,
oneloop_nB.sta_ref.att_3d, att_des,
false,
psi_vec,
k_att_rm.k1,
k_att_rm.k2,
k_att_rm.k3,
sta_bounds);
2659 bool in_flight_oneloop =
false;
2662 in_flight_oneloop =
true;
2666 in_flight_oneloop =
true;
2728 float att_jerk_des[3];
2729 float nu_stab[3] = {0.0, 0.0, 0.0};
2736 float dummy1[3] = {1.0, 1.0, 1.0};
2737 float dummy0[3] = {0.0, 0.0, 0.0};
2745 ec_3rd_att(att_jerk_des, att_des,
oneloop_nB.sta_ref.att,
oneloop_nB.sta_ref.att_d,
oneloop_nB.sta_ref.att_2d,
oneloop_nB.sta_ref.att_3d,
oneloop_nB.sta_state.att,
oneloop_nB.sta_state.att_d,
oneloop_nB.sta_state.att_2d,
k_att_e.k1,
k_att_e.k2,
k_att_e.k3,
sta_bounds, ctrl_effort_model_att);
2747 nu_stab[0] = att_jerk_des[0];
2748 nu_stab[1] = att_jerk_des[1];
2749 nu_stab[2] = att_jerk_des[2];
2753 ec_3rd_att(att_jerk_des, att_des,
oneloop_nB.sta_ref.att,
oneloop_nB.sta_ref.att_d,
oneloop_nB.sta_ref.att_2d, dummy0,
oneloop_nB.sta_state.att,
oneloop_nB.sta_state.att_d,
oneloop_nB.sta_state.att_2d,
k_att_e.k1,
k_att_e.k2, dummy1,
sta_bounds, ctrl_effort_model_att);
2754 nu_stab[0] = att_jerk_des[0];
2755 nu_stab[1] = att_jerk_des[1];
2756 nu_stab[2] = att_jerk_des[2];
2760 ec_3rd_att(att_jerk_des, att_des,
oneloop_nB.sta_ref.att,
oneloop_nB.sta_ref.att_d,
oneloop_nB.sta_ref.att_2d,
oneloop_nB.sta_ref.att_3d,
oneloop_nB.sta_state.att,
oneloop_nB.sta_state.att_d,
oneloop_nB.sta_state.att_2d,
k_att_e.k1,
k_att_e.k2,
k_att_e.k3,
sta_bounds, ctrl_effort_model_att);
2765 nu_stab[2] = att_jerk_des[2];
2769 ec_3rd_att(att_jerk_des, att_des,
oneloop_nB.sta_ref.att,
oneloop_nB.sta_ref.att_d,
oneloop_nB.sta_ref.att_2d, dummy0,
oneloop_nB.sta_state.att,
oneloop_nB.sta_state.att_d,
oneloop_nB.sta_state.att_2d,
k_att_e.k1,
k_att_e.k2, dummy1,
sta_bounds, ctrl_effort_model_att);
2774 nu_stab[2] = att_jerk_des[2];
2821 float temp_thrust = 0.0;
2822 static int counter_afc = 0;
2823 float min_fault_mot = 0.0;
2824 float time_afc = 30.0;
2825 float m_afc = (min_fault_mot -
max_fault_mot) / (time_afc * PERIODIC_FREQUENCY);
2829 counter_afc = counter_afc + 1;
2830 if (counter_afc > time_afc * PERIODIC_FREQUENCY)
2844 float abs_r = fabsf(
oneloop_nB.sta_state.att_d[2]);
2879 andi_u[COMMAND_MOTOR_FRONT] = temp_thrust;
2880 andi_u[COMMAND_MOTOR_BACK] = temp_thrust;
2884 andi_u[COMMAND_MOTOR_RIGHT] = temp_thrust;
2885 andi_u[COMMAND_MOTOR_LEFT] = temp_thrust;
2893 for (
int k = 0; k < 2; k++)
2906#if ONELOOP_NB_DEBUG_MODE
2945 float prev_actuator_state_1l;
3017 EFF_MAT_G[i][COMMAND_MOTOR_FRONT] = 0.0;
3027 EFF_MAT_G[i][COMMAND_MOTOR_RIGHT] = 0.0;
3031#ifdef COMMAND_AILERONS
3064 ratio_u_un[i] = ratio_numerator / ratio_denominator;
3070 float ratio_denominator = 1.0;
3075 ratio_vn_v[i] = ratio_numerator / ratio_denominator;
3079 ratio_vn_v[i] = ratio_numerator / ratio_denominator;
3083 ratio_vn_v[i] = ratio_numerator / ratio_denominator;
3087 ratio_vn_v[i] = ratio_numerator / ratio_denominator;
3121 switch (
nav.setpoint_mode)
3134 switch (
nav.vertical_mode)
3156 Bound(airspeed_turn, 1.0f, 30.0f);
3158 float coordinated_turn_roll =
eulers_zxy.phi;
3165 BoundAbs(coordinated_turn_roll,
max_phi);
3166 omega =
g / airspeed_turn * tanf(coordinated_turn_roll);
3167#ifdef FWD_SIDESLIP_GAIN
3186 float cpsi = cosf(psi);
3187 float spsi = sinf(psi);
3190 struct FloatVect2 airspeed_v = {cpsi * airspeed, spsi * airspeed};
3196 VECT2_DIFF(windspeed, groundspeed, airspeed_v);
3201 if (norm_des_as <
min_as)
3210 float groundspeed_factor = 0.0f;
3213 float av = NT_v_NE.
x * NT_v_NE.
x + NT_v_NE.
y * NT_v_NE.
y;
3214 float bv = -2.f * (windspeed.
x * NT_v_NE.
x + windspeed.
y * NT_v_NE.
y);
3215 float cv = windspeed.
x * windspeed.
x + windspeed.
y * windspeed.
y -
max_as *
max_as;
3216 float dv = bv * bv - 4.0f * av * cv;
3222 float d_sqrt = sqrtf(dv);
3223 groundspeed_factor = (-bv + d_sqrt) / (2.0f * av);
3225 des_as_NE.
x = groundspeed_factor * NT_v_NE.
x - windspeed.
x;
3226 des_as_NE.
y = groundspeed_factor * NT_v_NE.
y - windspeed.
y;
3227 NT_v_NE.
x = groundspeed_factor * NT_v_NE.
x;
3228 NT_v_NE.
y = groundspeed_factor * NT_v_NE.
y;
3231 des_as_B.
x = norm_des_as;
3235 float delta_psi = atan2f(des_as_NE.
y, des_as_NE.
x) - psi;
3237 des_acc_B.
y = delta_psi * 5.0;
3238 des_acc_B.
x = (des_as_B.
x - airspeed) *
k_pos_rm.k2[0];
3314 float p_dot =
oneloop_nB.sta_state.att_2d[0];
3315 float q_dot =
oneloop_nB.sta_state.att_2d[1];
3316 float r_dot =
oneloop_nB.sta_state.att_2d[2];
3319 nu[
IDX_ap] -= (r * q_dot + q * r_dot) * (
RW.I.yy -
RW.I.zz) /
RW.I.xx;
3320 nu[
IDX_aq] -= (r * p_dot +
p * r_dot) * (
RW.I.zz -
RW.I.xx) /
RW.I.yy;
3354 case COMMAND_MOTOR_FRONT:
3355 case COMMAND_MOTOR_RIGHT:
3356 case COMMAND_MOTOR_BACK:
3357 case COMMAND_MOTOR_LEFT:
3358#ifdef COMMAND_AILERONS
3359 case COMMAND_AILERONS:
3368 bool IN_QUAD =
true;
3369#ifdef COMMAND_ROT_MECH
3370 if (
RW.skew.deg > 70.0)
3501 pqr_dot.
x =
LP.p_dot.meas;
3502 pqr_dot.
y =
LP.q_dot.meas;
3503 pqr_dot.
z =
LP.r_dot.meas;
3504 pqr_ddot.
x =
LP.p_ddot.meas;
3505 pqr_ddot.
y =
LP.q_ddot.meas;
3506 pqr_ddot.
z =
LP.r_ddot.meas;
3526 static bool nB_2d_inited =
false;
3533 nB_2d_inited =
true;
3535 oneloop_nB.sta_nB_state.nB_2d.x = (
oneloop_nB.sta_nB_state.nB_d.x - nB_d_prev.
x) * PERIODIC_FREQUENCY;
3536 oneloop_nB.sta_nB_state.nB_2d.y = (
oneloop_nB.sta_nB_state.nB_d.y - nB_d_prev.
y) * PERIODIC_FREQUENCY;
3537 oneloop_nB.sta_nB_state.nB_2d.z = (
oneloop_nB.sta_nB_state.nB_d.z - nB_d_prev.
z) * PERIODIC_FREQUENCY;
3557 static bool nB_3d_inited =
false;
3564 nB_3d_inited =
true;
3566 oneloop_nB.sta_nB_state.nB_3d.x = (
oneloop_nB.sta_nB_state.nB_2d.x - nB_2d_prev.
x) * PERIODIC_FREQUENCY;
3567 oneloop_nB.sta_nB_state.nB_3d.y = (
oneloop_nB.sta_nB_state.nB_2d.y - nB_2d_prev.
y) * PERIODIC_FREQUENCY;
3568 oneloop_nB.sta_nB_state.nB_3d.z = (
oneloop_nB.sta_nB_state.nB_2d.z - nB_2d_prev.
z) * PERIODIC_FREQUENCY;
3626 float sigma_1 =
RW.I.yy * (pqr.
y * pqr_dot.
z + pqr_dot.
y * pqr.
z) -
RW.I.zz * (pqr.
y * pqr_dot.
z + pqr_dot.
y * pqr.
z);
3627 float sigma_2 =
RW.I.xx * (pqr.
x * pqr_dot.
z + pqr_dot.
x * pqr.
z) -
RW.I.zz * (pqr.
x * pqr_dot.
z + pqr_dot.
x * pqr.
z);
3628 float sigma_3 =
RW.I.xx * (pqr.
x * pqr_dot.
y + pqr_dot.
x * pqr.
y) -
RW.I.yy * (pqr.
x * pqr_dot.
y + pqr_dot.
x * pqr.
y);
3629 float upsilon_1 =
oneloop_nB.sta_nB_state.nB.y * sigma_3 /
RW.I.zz +
oneloop_nB.sta_nB_state.nB.z * sigma_2 /
RW.I.yy;
3630 float upsilon_2 =
oneloop_nB.sta_nB_state.nB.z * sigma_1 /
RW.I.xx -
oneloop_nB.sta_nB_state.nB.x * sigma_3 /
RW.I.zz;
3631 float upsilon_3 = -
oneloop_nB.sta_nB_state.nB.x * sigma_2 /
RW.I.yy -
oneloop_nB.sta_nB_state.nB.y * sigma_1 /
RW.I.xx;
3651 nB_d_des[0] = k1_e[0] * (mu_B.
x - nB.
x);
3652 nB_d_des[1] = k1_e[1] * (mu_B.
y - nB.
y);
3653 nB_d_des[2] = k1_e[2] * (mu_B.
z - nB.
z);
3655 nB_2d_des[0] = k2_e[0] * (nB_d_des[0] - nB_d.
x);
3656 nB_2d_des[1] = k2_e[1] * (nB_d_des[1] - nB_d.
y);
3657 nB_2d_des[2] = k2_e[2] * (nB_d_des[2] - nB_d.
z);
3659 nB_nu[0] = k3_e[0] * (nB_2d_des[0] - nB_2d.
x) + dist[0];
3660 nB_nu[1] = k3_e[1] * (nB_2d_des[1] - nB_2d.
y) + dist[1];
3694 e_x[0] = k1_rm[0] * (x_des->
x - x_ref->
x);
3695 e_x[1] = k1_rm[1] * (x_des->
y - x_ref->
y);
3696 e_x[2] = k1_rm[2] * (x_des->
z - x_ref->
z);
3698 e_x_d[0] = k2_rm[0] * (e_x[0] - x_d_ref->
x);
3699 e_x_d[1] = k2_rm[1] * (e_x[1] - x_d_ref->
y);
3700 e_x_d[2] = k2_rm[2] * (e_x[2] - x_d_ref->
z);
3702 e_x_2d[0] = k3_rm[0] * (e_x_d[0] - x_2d_ref->
x);
3703 e_x_2d[1] = k3_rm[1] * (e_x_d[1] - x_2d_ref->
y);
3704 e_x_2d[2] = k3_rm[2] * (e_x_d[2] - x_2d_ref->
z);
3711 x_3d_ref->
x = e_x_2d[0];
3712 x_3d_ref->
y = e_x_2d[1];
3713 x_3d_ref->
z = e_x_2d[2];
3716 x_2d_ref->
x += dt * x_3d_ref->
x;
3717 x_2d_ref->
y += dt * x_3d_ref->
y;
3718 x_2d_ref->
z += dt * x_3d_ref->
z;
3721 x_d_ref->
x += dt * x_2d_ref->
x;
3722 x_d_ref->
y += dt * x_2d_ref->
y;
3723 x_d_ref->
z += dt * x_2d_ref->
z;
3726 x_ref->
x += dt * x_d_ref->
x;
3727 x_ref->
y += dt * x_d_ref->
y;
3728 x_ref->
z += dt * x_d_ref->
z;
3758 BoundAbs(
SQ_r, 40.0);
3763 Bound(
SQ_r, 0.0, 40.0);
3769 *nu_stab_2 = (*nu_stab_2 -
oneloop_nB.sta_state.att_2d[2]) * gain;
3770 *nu_stab_2 += ce_model;
3782 (void)max_climb_speed_quad;
3783 (void)max_climb_speed_fwd;
3789 (void)max_descend_speed_quad;
3790 (void)max_descend_speed_fwd;
3797 float c = cosf((psi -
xi) / 2.0f);
3800 for (
int i = 0; i < n; i++)
3810 float out = -atan2f(r, w);
3815float xi_fun(
float r,
float w,
float aN_des,
float aE_des)
3825 float a_des_norm = sqrtf(aN_des * aN_des + aE_des * aE_des);
3827 if (a_des_norm > 0.1)
3837 float pusher_cmd =
cos_2n(psi,
xi, n);
3838 Bound(pusher_cmd, 0.0f, 1.0f);
Main include for ABI (AirBorneInterface).
struct pprz_autopilot autopilot
Global autopilot structure.
bool autopilot_get_motors_on(void)
get motors status
Hardware independent code for commands handling.
static struct uart_periph * dev
float G2_RW[EFF_MAT_COLS_NB]
float EFF_MAT_RW[EFF_MAT_ROWS_NB][EFF_MAT_COLS_NB]
#define FLOAT_ANGLE_NORMALIZE(_a)
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
void float_eulers_of_quat_zxy(struct FloatEulers *e, const struct FloatQuat *q)
euler rotation 'ZXY' This rotation order is useful if you need 90 deg pitch
#define FLOAT_VECT3_ZERO(_v)
void float_rmat_vmult(struct FloatVect3 *vb, const struct FloatRMat *m_a2b, const struct FloatVect3 *va)
rotate 3D vector by rotation matrix.
static void float_vect_copy(float *a, const float *b, const int n)
a = b
static void float_vect_diff(float *o, const float *a, const float *b, const int n)
o = a - b
static float float_vect_norm(const float *a, const int n)
||a||
#define FLOAT_VECT2_NORM(_v)
#define VECT2_DIFF(_c, _a, _b)
#define VECT3_SUB(_a, _b)
#define VECT3_ADD(_a, _b)
#define POS_FLOAT_OF_BFP(_ai)
#define SPEED_FLOAT_OF_BFP(_ai)
#define POS_BFP_OF_REAL(_af)
#define ACCEL_FLOAT_OF_BFP(_ai)
#define SPEED_BFP_OF_REAL(_af)
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
static struct FloatRMat * stateGetNedToBodyRMat_f(void)
Get vehicle body attitude rotation matrix (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).
static struct Int32Vect3 * stateGetAccelBody_i(void)
Get acceleration in Body coordinates (int).
static float stateGetAirspeed_f(void)
Get airspeed (float).
bool force_forward
forward flight for hybrid nav
Butterworth2LowPass accely_filt
struct FloatEulers eulers_zxy
state eulers in zxy order
float gi_unbounded_airspeed_sp
Integrated Navigation System interface.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
Simple first order low pass filter with bilinear transform.
struct SecondOrderLowPass Butterworth2LowPass
Second order Butterworth low pass filter.
static void init_first_order_low_pass(struct FirstOrderLowPass *filter, float tau, const float sample_time, float value)
Init first order low pass filter.
static float update_first_order_low_pass(struct FirstOrderLowPass *filter, const float value)
Update first order low pass filter state with a new value.
static void init_butterworth_2_low_pass(Butterworth2LowPass *filter, const float tau, const float sample_time, const float value)
Init a second order Butterworth filter.
static float update_butterworth_2_low_pass(Butterworth2LowPass *filter, const float value)
Update second order Butterworth low pass filter state with a new value.
static float update_butterworth_4_low_pass(Butterworth4LowPass *filter, const float value)
Update fourth order Butterworth low pass filter state with a new value.
static void init_butterworth_4_low_pass(Butterworth4LowPass *filter, const float tau, const float sample_time, const float value)
Init a fourth order Butterworth filter.
Hardware independent API for actuators (servos, motor controllers).
#define NAV_HYBRID_MAX_AIRSPEED
float nav_hybrid_max_bank
float nav_max_acceleration_sp
float nav_hybrid_pos_gain
#define NAV_HYBRID_MAX_DECELERATION
Specific navigation functions for hybrid aircraft.
static void notch_filter_update(struct SecondOrderNotchFilter *filter, int32_t *input_signal, int32_t *output_signal)
Notch filter propagate.
static void notch_filter_init(struct SecondOrderNotchFilter *filter, float cutoff_frequency, float bandwidth, uint16_t sample_frequency)
Initialize second order notch filter.
void init_poles(void)
Initialize Position of Poles.
struct PolePlacement p_pos_e
static float Wv_backup[ANDI_OUTPUTS]
void chirp_pos(float time_elapsed, float f0, float f1, float t_chirp, float A, int8_t n, float psi, float p_ref[], float v_ref[], float a_ref[], float j_ref[], float p_ref_0[])
Reference Model Definition for 3rd order system specific to positioning with bounds.
float act_dynamics[ANDI_NUM_ACT_TOT]
float ratio_u_un[ANDI_NUM_ACT_TOT]
static float Wu_backup[ANDI_NUM_ACT_TOT]
void init_filter(void)
Initialize the filters.
void reinit_controller(void)
Re-Init function of controller variables.
struct PolePlacement p_head_rm
void oneloop_calc_model_disturbance(bool in_flight)
Function that calculates the model disturbance (Control Effort) The control effort is equalt to : EFF...
static Butterworth2LowPass airspeed_filt
float n_array[ANDI_OUTPUTS]
float act_max_norm[ANDI_NUM_ACT_TOT]
struct Gains3rdOrder k_att_rm
void float_euler_dot_of_rates_vec(float r[3], float e[3], float edot[3])
Attitude Euler to Rates Conversion Function ZYX.
static Butterworth2LowPass u_filt[ANDI_NUM_ACT_TOT]
float act_dyn_ctrl[ANDI_NUM_ACT_TOT]
struct FloatEulers eulers_zxy_des
struct PolePlacement p_att_rm
struct Gains3rdOrder k_att_e
float EFF_MAT_G[ANDI_OUTPUTS][ANDI_NUM_ACT_TOT]
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.
struct Gains3rdOrder k_pos_e
bool actuator_is_servo[ANDI_NUM_ACT_TOT]
void float_vect_diff_euler(float err[3], float a[3], float b[3])
Calculate Error between two 3D euler arrays with the psi normalized.
float num_thrusters_oneloop
static float act_dynamics_d[ANDI_NUM_ACT_TOT]
static float andi_u_n[ANDI_NUM_ACT_TOT]
float act_min_norm[ANDI_NUM_ACT_TOT]
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], struct OneloopStabilizationRef bounds)
Reference Model Definition for 3rd order system with attitude conversion functions.
static void send_wls_u_oneloop(struct transport_tx *trans, struct link_device *dev)
float bound_v_from_a(float e_x, float v_bound, float a_bound)
Calculate velocity limit based on acceleration limit for a float From SUVAT we have that v^2 = u^2 + ...
struct PolePlacement p_alt_rm
void init_controller_gains(void)
Initialize Controller Gains FIXME: Calculate the gains dynamically for transition.
float andi_u[ANDI_NUM_ACT_TOT]
void calc_normalization(void)
Calculate Normalization of actuators and discrete actuator dynamics.
struct Gains3rdOrder k_pos_e_indi
struct PolePlacement p_att_e
struct PolePlacement p_alt_e
float bound_v_from_a_vect(float e_x[], float v_bound, float a_bound, int n)
Calculate velocity limit based on acceleration limit for a vector From SUVAT we have that v^2 = u^2 +...
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.
void get_act_state_oneloop(void)
Function to reconstruct actuator state using first order dynamics.
struct PolePlacement p_roll_e
void ec_3rd_pos(float y_4d[], float x_des[], 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[], float x_d_bound, float x_2d_bound, float fb[], int n)
Error Controller Definition for 3rd order system.
struct PolePlacement p_head_e
float andi_du[ANDI_NUM_ACT_TOT]
static void send_wls_v_oneloop(struct transport_tx *trans, struct link_device *dev)
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.
struct Gains3rdOrder k_pos_rm
float m_array[ANDI_NUM_ACT_TOT]
void chirp_call(bool *chirp_on, bool *chirp_first_call, float *t_0_chirp, float *time_elapsed, float f0, float f1, float t_chirp, float A, int8_t n, float psi, float p_ref[], float v_ref[], float a_ref[], float j_ref[], float p_ref_0[])
void G1G2_oneloop(int ctrl_type)
Function that samples and scales the effectiveness matrix FIXME: make this function into a for loop t...
float act_max[ANDI_NUM_ACT_TOT]
void normalize_nu(void)
Function to normalize the pseudo control vector.
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 float_rates_of_euler_dot_vec(float r[3], float e[3], float edot[3])
Attitude Rates to Euler Conversion Function ZYX.
struct OneloopStabilizationRef sta_bounds
struct PolePlacement p_pos_rm
float ratio_vn_v[ANDI_OUTPUTS]
float actuator_state_1l[ANDI_NUM_ACT_TOT]
void vect_bound_nd(float vect[], float bound, int n)
Scale a 3D array to within a 3D bound.
void err_sum_nd(float err[], float a[], float b[], float k[], float c[], int n)
Calculate Scaled Error between two 3D arrays.
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
void integrate_nd(float dt, float a[], float a_dot[], int n)
Integrate in time 3D array.
struct Gains3rdOrder k_att_e_indi
static void send_oneloop_debug(struct transport_tx *trans, struct link_device *dev)
float act_min[ANDI_NUM_ACT_TOT]
void acc_body_bound(struct FloatVect2 *vect, float bound)
Scale a 3D array to within a 3D bound.
float * bwls_1l[ANDI_OUTPUTS]
static float nav_target_new[3]
void ec_3rd_att(float y_4d[3], float x_des[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], struct OneloopStabilizationRef bounds, float fb[3])
Error Controller Definition for 3rd order system specific to attitude.
static float u_pref[ANDI_NUM_ACT_TOT]
#define ANDI_NUM_VIRTUAL_ACT
#define CTRL_ANDI
Control types.
void init_poles(void)
Initialize Position of Poles.
static void send_oneloop_nB_ctrl(struct transport_tx *trans, struct link_device *dev)
#define ONELOOP_NB_PID_V_MAX_NAV
float oneloop_nB_filt_cutoff
#define ONELOOP_NB_SPIN_MAN_TRIM_RATE
static void reinit_LP(struct LP_t *LP, bool reinit)
#define ONELOOP_NB_DEBUG_MODE
static float spin_man_dir
#define ONELOOP_NB_SPIN_MAN_RAMP_RATE
static Butterworth2LowPass nB_filt[3]
void init_filter(void)
Initialize the filters.
float spin_man_blend_time
float ctrl_effort_model[ANDI_OUTPUTS]
void reinit_controller(void)
Re-Init function of controller variables.
static bool vec3_saturated(const float u_unsat[3], const float u_sat[3], float eps)
void oneloop_calc_model_disturbance(bool in_flight)
Function that calculates the model disturbance (Control Effort) The control effort is equalt to : EFF...
static void update_filter_on_type(struct LP_t *filter, float input)
Update a filter based on its type.
static void eul_of_acc(float a[3], float psi)
static void init_all_LP(void)
Initialize all Low Pass Filters.
static void send_eff_mat_stab_oneloop_nB(struct transport_tx *trans, struct link_device *dev)
void float_euler_dot_of_rates_vec(float r[3], float e[3], float edot[3])
Attitude Euler to Rates Conversion Function ZYX.
void oneloop_nB_propagate_filters(void)
Propagate the filters.
float pusher_cmd_fun(float aN_des, float aE_des, float r, float psi, float w, int n)
static void ARW_ClampVec3(const float err[3], const float u_unsat[3], const float u_sat[3], const float I_prev[3], const float I_cand[3], float I_next[3])
static float k_rm_3_3_f(float omega_n, float zeta, float p1)
static Butterworth2LowPass nB_2d_filt[3]
#define ONELOOP_NB_PID_V_MAX_MANUAL
bool safety_killer_trigger
void guidance_set_max_bank_angle(float max_bank)
Guidance limit setters called by rotwing_state (also implemented by guidance_indi_hybrid).
float xi_fun(float r, float w, float aN_des, float aE_des)
#define ONELOOP_NB_SPIN_TRIM_BLEED_RATE
static float spin_man_u_last[ANDI_NUM_ACT]
float oneloop_nB_sideslip(void)
Function to calculate corrections for sideslip DEPRECIATED.
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 guidance_set_max_climb_speed(float max_climb_speed_quad, float max_climb_speed_fwd)
void float_vect_diff_euler(float err[3], float a[3], float b[3])
Calculate Error between two 3D euler arrays with the psi normalized.
static void Vel_PID_ARW(float x_dot_des[3], const float x_dot[3], float k_P, float k_I, float k_D, float a_sp[3], float a_max, float v_max)
static void spin_man_set_pair(uint8_t pair)
Select the motors of a pair (pitch: FRONT/BACK, roll: RIGHT/LEFT) for the blend.
#define ONELOOP_NB_SPIN_MAN_PITCH_DIR
#define ONELOOP_NB_SPIN_PROT_START_RATE
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], struct OneloopStabilizationRef bounds)
Reference Model Definition for 3rd order system with attitude conversion functions.
static float ec_poles(float p_rm, float slow_pole, float k)
Calculate EC poles given RM poles.
static void send_wls_u_oneloop(struct transport_tx *trans, struct link_device *dev)
#define ONELOOP_NB_SPIN_PROT_MAX_RATE
float spin_trim_release_rate
static bool spin_man_rate_ctrl(void)
Yaw rate tracking is used by the manoeuvre (no fault active).
void nB_EC(struct FloatVect3 nB, struct FloatVect3 nB_d, struct FloatVect3 nB_2d, struct FloatVect3 mu_B, float k1_e[3], float k2_e[3], float k3_e[3], float dist[3], float nB_nu[3])
void oneloop_from_nav(bool in_flight)
Function that maps navigation inputs to the oneloop controller for the generated autopilot.
float phase_first_order(float r, float w)
float bound_v_from_a(float e_x, float v_bound, float a_bound)
Calculate velocity limit based on acceleration limit for a float From SUVAT we have that v^2 = u^2 + ...
static Butterworth2LowPass KPID_filt[3]
float cos_2n(float psi, float xi, int n)
void init_controller_gains(void)
Initialize Controller Gains FIXME: Calculate the gains dynamically for transition.
static uint8_t spin_man_mot[2]
static void reinit_all_LP(bool reinit)
Reinitialize all the Low Pass Filters.
static float positive_non_zero(float input)
Function to make sure that inputs are positive non zero vaues.
#define ONELOOP_NB_SPIN_MAN_DONE_RATE
float safety_killer_cutoff
#define ONELOOP_NB_SPIN_PROT_MIN_GAP
#define SPIN_MAN_PAIR_PITCH
void guidance_set_min_max_airspeed(float min_airspeed, float max_airspeed)
float oneloop_nB_filt_cutoff_q
void calc_normalization(void)
Calculate Normalization of actuators and discrete actuator dynamics.
static void send_eff_mat_guid_oneloop_nB(struct transport_tx *trans, struct link_device *dev)
static void spin_man_update(bool in_flight, bool nb_ctrl)
Spin transition manoeuvre state machine.
void drop_axis(void)
Function that drops control along selected axes.
static void spin_man_start_blend(void)
Start a bumpless transfer of the selected pair from the average of its last applied commands,...
static void send_oneloop_nB(struct transport_tx *trans, struct link_device *dev)
static void debug_vect(struct transport_tx *trans, struct link_device *dev, char *name, float *data, int datasize)
float bound_v_from_a_vect(float e_x[], float v_bound, float a_bound, int n)
Calculate velocity limit based on acceleration limit for a vector From SUVAT we have that v^2 = u^2 +...
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.
void get_act_state_oneloop(void)
Function to reconstruct actuator state using first order dynamics.
void ec_3rd_pos(float y_4d[], float x_des[], 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[], float x_d_bound, float x_2d_bound, float fb[], int n)
Error Controller Definition for 3rd order system.
#define SPIN_MAN_PAIR_ROLL
static void spin_prot_bound_params(void)
Enforce valid spin protection / spin trim parameters (they can be changed in flight from the settings...
static Butterworth2LowPass nB_3d_state_filt[2]
static void init_LP(struct LP_t *LP, float fc)
Initialize the Low Pass Filter Struct.
static float spin_man_alpha
float oneloop_nB_filt_cutoff_v
float spin_trim_bleed_rate
struct OneloopGeneral oneloop_nB
static void send_wls_v_oneloop(struct transport_tx *trans, struct link_device *dev)
void err_nd(float err[], float a[], float b[], float k[], int n)
Calculate Scaled Error between two 3D arrays.
void oneloop_nB_state_compensation(bool state_compensation_on)
Function that performs state compensation for gyroscopic effects.
#define ONELOOP_NB_FAULT_AILERONS
float oneloop_nB_yaw_dist_limit
static void init_filter_on_type(struct LP_t *filter, float x0)
Initialize a filter based on its type.
bool autopilot_in_flight_end_detection(bool motors_on UNUSED)
Quadplanes can still be in-flight with COMMAND_THRUST==0 and can even soar not descending in updrafts...
void guidance_set_max_descend_speed(float max_descend_speed_quad, float max_descend_speed_fwd)
#define ONELOOP_NB_SPIN_PROT_MAX_CMD
static void reinit_LP_synchronous(struct LP_t *LP, struct LP_t *f, bool reinit)
Reinitialize Low Pass filter if new frequency setting or if forced.
static void spin_man_reset(void)
Stop the spin manoeuvre and clear its GCS triggers (fault flags are left as they are).
bool state_compensation_on
static Butterworth2LowPass push_PID_vel[2]
void oneloop_nB_enter(bool half_loop_sp, int ctrl_type)
Function that resets important values upon engaging Oneloop ANDI.
static void Pos_KPID_ARW(const float x_des[3], const float x[3], const float x_dot[3], float k_K, float k_P, float k_I, float k_D, float a_sp[3], float a_max, float v_max)
void G1G2_oneloop(int ctrl_type)
Function that samples and scales the effectiveness matrix FIXME: make this function into a for loop t...
#define ONELOOP_NB_SPIN_TRIM_RELEASE_RATE
#define ONELOOP_NB_SPIN_MAN_BLEND_TIME
static void spin_man_ramp_ref(float target)
Move the yaw rate reference towards target at spin_man_ramp_rate.
void set_WLS_settings(void)
Function that sets the WLS settings for oneloop controller.
void normalize_nu(void)
Function to normalize the pseudo control vector.
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 float_rates_of_euler_dot_vec(float r[3], float e[3], float edot[3])
Attitude Rates to Euler Conversion Function ZYX.
void SpinQuad_overwrite(float gain, float ce_model, float *nu_stab_2)
static void send_eff_mat_stab_thrust_oneloop_nB(struct transport_tx *trans, struct link_device *dev)
#define ONELOOP_NB_SPIN_TRIM_ON
static Butterworth2LowPass push_PID_vel_d[2]
static float k_rm_1_3_f(float omega_n, float zeta, float p1)
Reference Model Gain Design.
void init_poles_att(void)
Initialize Position of Poles.
#define ONELOOP_NB_MAX_FAULT_MOT
void oneloop_nB_calc_nB_states(void)
Function which estimates the nB states.
void oneloop_nB_run(bool in_flight, bool half_loop, struct FloatVect3 PSA_des)
Main function that runs the controller and performs control allocation.
float oneloop_nB_filt_cutoff_a
void vect_bound_nd(float vect[], float bound, int n)
Scale a 3D array to within a 3D bound.
void err_sum_nd(float err[], float a[], float b[], float k[], float c[], int n)
Calculate Scaled Error between two 3D arrays.
#define ONELOOP_NB_AIRSPEED_SWITCH_THRESHOLD
void integrate_nd(float dt, float a[], float a_dot[], int n)
Integrate in time 3D array.
void rm_3rd_nI(float dt, struct FloatVect3 *x_ref, struct FloatVect3 *x_d_ref, struct FloatVect3 *x_2d_ref, struct FloatVect3 *x_3d_ref, const struct FloatVect3 *x_des, const float k1_rm[3], const float k2_rm[3], const float k3_rm[3])
static Butterworth2LowPass KPID_vel_filt[3]
static void send_oneloop_debug(struct transport_tx *trans, struct link_device *dev)
static void send_guidance_oneloop_nB(struct transport_tx *trans, struct link_device *dev)
float oneloop_nB_filt_cutoff_p
void oneloop_nB_RM(bool half_loop, struct FloatVect3 PSA_des, bool in_flight_oneloop)
Function to generate the reference signals for the oneloop controller.
float oneloop_nB_filt_cutoff_r
static float spin_man_u_hold[2]
void acc_body_bound(struct FloatVect2 *vect, float bound)
Scale a 3D array to within a 3D bound.
void init_poles_pos(void)
#define ONELOOP_NB_SPIN_TRIM_RATE
void skew_symmetric(struct FloatRMat *out, const struct FloatVect3 *in)
#define ONELOOP_NB_PID_A_MAX
static float k_rm_2_3_f(float omega_n, float zeta, float p1)
void ec_3rd_att(float y_4d[3], float x_des[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], struct OneloopStabilizationRef bounds, float fb[3])
Error Controller Definition for 3rd order system specific to attitude.
#define ONELOOP_NB_SPIN_MAN_PAIR
void calc_HB_matrix(float HB[3][3], struct FloatVect3 nB)
float spin_prot_start_rate
void oneloop_nB_init(void)
Init function of Oneloop ANDI controller.
static void shape_vector(float a[3])
union LP_t::@324202153354356061211053020005360346147215120230 meas_filt
enum FilterType filter_type
Paparazzi floating point algebra.
vector in North East Down coordinates Units: meters
struct RadioControl radio_control
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).
struct RotorcraftNavigation nav
Rotorcraft navigation functions.
#define NAV_SETPOINT_MODE_SPEED
#define NAV_VERTICAL_MODE_CLIMB
#define NAV_VERTICAL_MODE_ALT
#define NAV_SETPOINT_MODE_POS
Nav setpoint modes these modes correspond to submodes defined by navigation routines to tell which se...
static const ShellCommand commands[]
struct Stabilization stabilization
API to get/set the generic vehicle states.
int16_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint16_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.
static const float scale[]
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
signed char int8_t
Typedef defining 8 bit char type.
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup).
void send_wls_v(char *name, struct WLS_t *WLS_p, struct transport_tx *trans, struct link_device *dev)
void wls_alloc(struct WLS_t *WLS_p, float **B, float *u_guess, float *W_init, int imax)
active set algorithm for control allocation
void send_wls_u(char *name, struct WLS_t *WLS_p, struct transport_tx *trans, struct link_device *dev)