ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
app_config.h File Reference

Phase-1 configuration: P-NUCLEO-WB55 (NUCLEO-WB55RG) + X-NUCLEO-IKS4A1 in Mode 3 (LSM6DSV16X is the sensor-hub master, LIS2MDL sits behind it). More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEG2RAD_F   0.017453292519943295f
 
#define APP_IMU_ODR   IMU_ODR_960HZ
 
#define APP_IMU_WATERMARK   4u
 FIFO words: 2 gyro + 2 acc -> IRQ at 960 Hz.
 
#define APP_GY_LPF1_BW   LSM6DSV16X_GY_LIGHT
 gyro anti-alias filter: to be tuned
 
#define APP_XL_LPF2_ENABLE   1
 
#define APP_XL_LPF2_BW   LSM6DSV16X_XL_STRONG
 
#define APP_MAG_FAST   1
 LIS2MDL 100 Hz, hub 120 Hz: halves the age of mag data.
 
#define APP_STEP_HZ   960u
 propagation + rate loop

 
#define APP_STEPS_PER_ACC   4u
 -> 240 Hz acc update + attitude loop

 
#define APP_CALIB_SAMPLES   100u
 mag samples at ~50 Hz -> ~2 s standing still
 
#define APP_CALIB_GYRO_STILL   (5.0f * DEG2RAD_F)
 
#define IEKF_SIGMA_GYRO   (0.5f * DEG2RAD_F)
 
#define IEKF_SIGMA_BIAS   1e-4f
 
#define IEKF_SIGMA_VEC_MIN   0.01f
 
#define IEKF_ACC_TOL   0.08f
 
#define IEKF_MAG_TOL   0.08f
 
#define IEKF_P0_ATT   ((2.0f * DEG2RAD_F) * (2.0f * DEG2RAD_F))
 
#define IEKF_P0_BIAS   ((0.2f * DEG2RAD_F) * (0.2f * DEG2RAD_F))
 
#define IEKF_ESTIMATE_BIAS   1
 
#define IEKF_ADAPTIVE   1
 
#define IEKF_TILT_COMP_MAG   1
 
#define IEKF_ACC_NIS_GATE   4.0f
 
#define IEKF_MAG_NIS_GATE   0.0f
 not recommended, see iekf.h
 
#define IEKF_INFL_TAU_S   0.5f
 
#define IEKF_DIP_TOL   (5.0f * DEG2RAD_F)
 
#define IEKF_DECOUPLE   0
 tried: does not help, see 03 - Docs/theory/iekf-embedded.md
 
#define IEKF_RESET_JACOBIAN   1
 
#define IEKF_TANGENT_INNOV   1
 
#define IEKF_INFL_MAX   100.0f
 
#define IEKF_LOCKOUT_S   0.5f
 
#define IEKF_LOCKOUT_BUMP   ((10.0f * DEG2RAD_F) * (10.0f * DEG2RAD_F))
 
#define IEKF_GRACE_S   0.25f
 
#define IEKF_PERSIST_TAU_S   1.0f
 
#define IEKF_PERSIST_RATIO   0.6f
 
#define IEKF_PERSIST_MIN   0.02f
 
#define APP_PROFILE_PREVIOUS   0
 
#define APP_STILL_ACC_TOL   0.02f
 
#define APP_STILL_GYRO_THR   (3.0f * DEG2RAD_F)
 
#define APP_STILL_TIME_S   0.3f
 
#define APP_COMPARE_ORIGINAL   0
 
#define MAG_AXIS_MAP   { 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f }
 
#define MAG_HARD_IRON   { 31.61f, 16.44f, -26.23f }
 uT, body frame
 
#define APP_TLM_DECIMATION   1u
 1 = every acc update (240 Hz), ~18.5 kB/s
 
#define APP_TLM_DECIM_REPLAY
 
#define APP_TLM_TX_TIMEOUT_MS   20u
 max wait for the UART DMA before dropping
 
#define APP_INIT_EVERY_N   480u
 repeat INIT ~once per second (2 frames per window)
 
#define APP_TLM_REPLAY
 
#define APP_TLM_BLE
 
#define APP_BLE_STATE_DECIM
 
#define APP_BLE_FLUSH_MS
 
#define APP_BLE_CONN_INT_MIN   12u
 x1.25 ms = 15 ms (iOS minimum)

 
#define APP_BLE_CONN_INT_MAX   24u
 x1.25 ms = 30 ms (iOS: max >= min + 15 ms)

 
#define APP_BLE_SUPERV_TIMEOUT   400u
 x10 ms = 4 s

 
#define APP_HW_REV   'N'
 CAPS hwRev: 'N' = NUCLEO-WB55 + IKS4A1 bench, 'A' = ACwing FC rev A.
 
#define APP_FLOW_SIGN_X   (1.0f)
 
#define APP_FLOW_SIGN_Y   (1.0f)
 
#define APP_FLOW_MIN_H   0.08f
 
#define APP_BATT_ADC   0
 
#define APP_BATT_VBAT_CH   1u
 
#define APP_BATT_VBAT_PORT   GPIOC
 
#define APP_BATT_VBAT_PIN   (1u << 0)
 
#define APP_BATT_CUR_CH   2u
 
#define APP_BATT_CUR_PORT   GPIOC
 
#define APP_BATT_CUR_PIN   (1u << 1)
 
#define APP_BATT_CURRENT   1
 a current sensor is wired (CAPS CURRENT)

 
#define APP_BATT_SENS_V_A   0.1f
 ACwing ESC 1S: TSC213 + 2 mOhm = 0.1 V/A

 
#define APP_LOG_FLASH   1
 
#define APP_LOG_RAM_KB   48u
 RAM log on the bench: ~14 s at ~3.4 kB/s

 
#define APP_USB_CDC   1
 NUCLEO-WB55: USB_USER connector (CN1)

 
#define APP_USB_TLM   1
 

Detailed Description

Phase-1 configuration: P-NUCLEO-WB55 (NUCLEO-WB55RG) + X-NUCLEO-IKS4A1 in Mode 3 (LSM6DSV16X is the sensor-hub master, LIS2MDL sits behind it).

Every tunable parameter of the application lives here.

Definition in file app_config.h.

Macro Definition Documentation

◆ DEG2RAD_F

#define DEG2RAD_F   0.017453292519943295f

Definition at line 10 of file app_config.h.

◆ APP_IMU_ODR

#define APP_IMU_ODR   IMU_ODR_960HZ

Definition at line 16 of file app_config.h.

◆ APP_IMU_WATERMARK

#define APP_IMU_WATERMARK   4u

FIFO words: 2 gyro + 2 acc -> IRQ at 960 Hz.

Definition at line 17 of file app_config.h.

◆ APP_GY_LPF1_BW

#define APP_GY_LPF1_BW   LSM6DSV16X_GY_LIGHT

gyro anti-alias filter: to be tuned

Definition at line 18 of file app_config.h.

◆ APP_XL_LPF2_ENABLE

#define APP_XL_LPF2_ENABLE   1

Definition at line 19 of file app_config.h.

◆ APP_XL_LPF2_BW

#define APP_XL_LPF2_BW   LSM6DSV16X_XL_STRONG

Definition at line 20 of file app_config.h.

◆ APP_MAG_FAST

#define APP_MAG_FAST   1

LIS2MDL 100 Hz, hub 120 Hz: halves the age of mag data.

Definition at line 21 of file app_config.h.

◆ APP_STEP_HZ

#define APP_STEP_HZ   960u

propagation + rate loop

Definition at line 23 of file app_config.h.

◆ APP_STEPS_PER_ACC

#define APP_STEPS_PER_ACC   4u

-> 240 Hz acc update + attitude loop

Definition at line 24 of file app_config.h.

◆ APP_CALIB_SAMPLES

#define APP_CALIB_SAMPLES   100u

mag samples at ~50 Hz -> ~2 s standing still

Definition at line 26 of file app_config.h.

◆ APP_CALIB_GYRO_STILL

#define APP_CALIB_GYRO_STILL   (5.0f * DEG2RAD_F)

Definition at line 27 of file app_config.h.

◆ IEKF_SIGMA_GYRO

#define IEKF_SIGMA_GYRO   (0.5f * DEG2RAD_F)

Definition at line 38 of file app_config.h.

◆ IEKF_SIGMA_BIAS

#define IEKF_SIGMA_BIAS   1e-4f

Definition at line 39 of file app_config.h.

◆ IEKF_SIGMA_VEC_MIN

#define IEKF_SIGMA_VEC_MIN   0.01f

Definition at line 40 of file app_config.h.

◆ IEKF_ACC_TOL

#define IEKF_ACC_TOL   0.08f

Definition at line 41 of file app_config.h.

◆ IEKF_MAG_TOL

#define IEKF_MAG_TOL   0.08f

Definition at line 42 of file app_config.h.

◆ IEKF_P0_ATT

#define IEKF_P0_ATT   ((2.0f * DEG2RAD_F) * (2.0f * DEG2RAD_F))

Definition at line 43 of file app_config.h.

◆ IEKF_P0_BIAS

#define IEKF_P0_BIAS   ((0.2f * DEG2RAD_F) * (0.2f * DEG2RAD_F))

Definition at line 44 of file app_config.h.

◆ IEKF_ESTIMATE_BIAS

#define IEKF_ESTIMATE_BIAS   1

Definition at line 45 of file app_config.h.

◆ IEKF_ADAPTIVE

#define IEKF_ADAPTIVE   1

Definition at line 46 of file app_config.h.

◆ IEKF_TILT_COMP_MAG

#define IEKF_TILT_COMP_MAG   1

Definition at line 47 of file app_config.h.

◆ IEKF_ACC_NIS_GATE

#define IEKF_ACC_NIS_GATE   4.0f

Definition at line 57 of file app_config.h.

◆ IEKF_MAG_NIS_GATE

#define IEKF_MAG_NIS_GATE   0.0f

not recommended, see iekf.h

Definition at line 58 of file app_config.h.

◆ IEKF_INFL_TAU_S

#define IEKF_INFL_TAU_S   0.5f

Definition at line 59 of file app_config.h.

◆ IEKF_DIP_TOL

#define IEKF_DIP_TOL   (5.0f * DEG2RAD_F)

Definition at line 60 of file app_config.h.

◆ IEKF_DECOUPLE

#define IEKF_DECOUPLE   0

tried: does not help, see 03 - Docs/theory/iekf-embedded.md

Definition at line 61 of file app_config.h.

◆ IEKF_RESET_JACOBIAN

#define IEKF_RESET_JACOBIAN   1

Definition at line 66 of file app_config.h.

◆ IEKF_TANGENT_INNOV

#define IEKF_TANGENT_INNOV   1

Definition at line 70 of file app_config.h.

◆ IEKF_INFL_MAX

#define IEKF_INFL_MAX   100.0f

Definition at line 71 of file app_config.h.

◆ IEKF_LOCKOUT_S

#define IEKF_LOCKOUT_S   0.5f

Definition at line 72 of file app_config.h.

◆ IEKF_LOCKOUT_BUMP

#define IEKF_LOCKOUT_BUMP   ((10.0f * DEG2RAD_F) * (10.0f * DEG2RAD_F))

Definition at line 73 of file app_config.h.

◆ IEKF_GRACE_S

#define IEKF_GRACE_S   0.25f

Definition at line 74 of file app_config.h.

◆ IEKF_PERSIST_TAU_S

#define IEKF_PERSIST_TAU_S   1.0f

Definition at line 75 of file app_config.h.

◆ IEKF_PERSIST_RATIO

#define IEKF_PERSIST_RATIO   0.6f

Definition at line 76 of file app_config.h.

◆ IEKF_PERSIST_MIN

#define IEKF_PERSIST_MIN   0.02f

Definition at line 77 of file app_config.h.

◆ APP_PROFILE_PREVIOUS

#define APP_PROFILE_PREVIOUS   0

Definition at line 82 of file app_config.h.

◆ APP_STILL_ACC_TOL

#define APP_STILL_ACC_TOL   0.02f

Definition at line 91 of file app_config.h.

◆ APP_STILL_GYRO_THR

#define APP_STILL_GYRO_THR   (3.0f * DEG2RAD_F)

Definition at line 92 of file app_config.h.

◆ APP_STILL_TIME_S

#define APP_STILL_TIME_S   0.3f

Definition at line 93 of file app_config.h.

◆ APP_COMPARE_ORIGINAL

#define APP_COMPARE_ORIGINAL   0

Definition at line 102 of file app_config.h.

◆ MAG_AXIS_MAP

#define MAG_AXIS_MAP   { 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f }

Definition at line 109 of file app_config.h.

◆ MAG_HARD_IRON

#define MAG_HARD_IRON   { 31.61f, 16.44f, -26.23f }

uT, body frame

Definition at line 110 of file app_config.h.

◆ APP_TLM_DECIMATION

#define APP_TLM_DECIMATION   1u

1 = every acc update (240 Hz), ~18.5 kB/s

Definition at line 112 of file app_config.h.

◆ APP_TLM_DECIM_REPLAY

#define APP_TLM_DECIM_REPLAY
Value:
8u /* with REPLAY on, STATE drops to 30 Hz:
REPLAY already carries q and bias at 240 Hz */

Definition at line 113 of file app_config.h.

◆ APP_TLM_TX_TIMEOUT_MS

#define APP_TLM_TX_TIMEOUT_MS   20u

max wait for the UART DMA before dropping

Definition at line 114 of file app_config.h.

◆ APP_INIT_EVERY_N

#define APP_INIT_EVERY_N   480u

repeat INIT ~once per second (2 frames per window)

Definition at line 115 of file app_config.h.

◆ APP_TLM_REPLAY

#define APP_TLM_REPLAY
Value:
0 /* 1 only for the MATLAB comparison: raises the
telemetry from ~19 to ~44 kB/s, too much for
the real-time viewer -> record with
tlmCapture.m and analyse offline */

Definition at line 116 of file app_config.h.

◆ APP_TLM_BLE

#define APP_TLM_BLE
Value:
1 /* 1 once STM32_WPAN (BLE) is enabled in CubeMX
and the CPU2 wireless stack is flashed */

Definition at line 121 of file app_config.h.

◆ APP_BLE_STATE_DECIM

#define APP_BLE_STATE_DECIM
Value:
4u /* STATE over BLE: 240/4 = 60 Hz (~5.4 kB/s in
total with STATUS and INIT). Changeable at run
time with the CMD characteristic. */

Definition at line 122 of file app_config.h.

◆ APP_BLE_FLUSH_MS

#define APP_BLE_FLUSH_MS
Value:
10u /* TX thread period: groups frames in one
notification when the MTU allows it */

Definition at line 123 of file app_config.h.

◆ APP_BLE_CONN_INT_MIN

#define APP_BLE_CONN_INT_MIN   12u

x1.25 ms = 15 ms (iOS minimum)

Definition at line 124 of file app_config.h.

◆ APP_BLE_CONN_INT_MAX

#define APP_BLE_CONN_INT_MAX   24u

x1.25 ms = 30 ms (iOS: max >= min + 15 ms)

Definition at line 125 of file app_config.h.

◆ APP_BLE_SUPERV_TIMEOUT

#define APP_BLE_SUPERV_TIMEOUT   400u

x10 ms = 4 s

Definition at line 126 of file app_config.h.

◆ APP_HW_REV

#define APP_HW_REV   'N'

CAPS hwRev: 'N' = NUCLEO-WB55 + IKS4A1 bench, 'A' = ACwing FC rev A.

Definition at line 128 of file app_config.h.

◆ APP_FLOW_SIGN_X

#define APP_FLOW_SIGN_X   (1.0f)

Definition at line 131 of file app_config.h.

◆ APP_FLOW_SIGN_Y

#define APP_FLOW_SIGN_Y   (1.0f)

Definition at line 132 of file app_config.h.

◆ APP_FLOW_MIN_H

#define APP_FLOW_MIN_H   0.08f

Definition at line 136 of file app_config.h.

◆ APP_BATT_ADC

#define APP_BATT_ADC   0

Definition at line 153 of file app_config.h.

◆ APP_BATT_VBAT_CH

#define APP_BATT_VBAT_CH   1u

Definition at line 154 of file app_config.h.

◆ APP_BATT_VBAT_PORT

#define APP_BATT_VBAT_PORT   GPIOC

Definition at line 155 of file app_config.h.

◆ APP_BATT_VBAT_PIN

#define APP_BATT_VBAT_PIN   (1u << 0)

Definition at line 156 of file app_config.h.

◆ APP_BATT_CUR_CH

#define APP_BATT_CUR_CH   2u

Definition at line 157 of file app_config.h.

◆ APP_BATT_CUR_PORT

#define APP_BATT_CUR_PORT   GPIOC

Definition at line 158 of file app_config.h.

◆ APP_BATT_CUR_PIN

#define APP_BATT_CUR_PIN   (1u << 1)

Definition at line 159 of file app_config.h.

◆ APP_BATT_CURRENT

#define APP_BATT_CURRENT   1

a current sensor is wired (CAPS CURRENT)

Definition at line 161 of file app_config.h.

◆ APP_BATT_SENS_V_A

#define APP_BATT_SENS_V_A   0.1f

ACwing ESC 1S: TSC213 + 2 mOhm = 0.1 V/A

Definition at line 162 of file app_config.h.

◆ APP_LOG_FLASH

#define APP_LOG_FLASH   1

Definition at line 169 of file app_config.h.

◆ APP_LOG_RAM_KB

#define APP_LOG_RAM_KB   48u

RAM log on the bench: ~14 s at ~3.4 kB/s

Definition at line 171 of file app_config.h.

◆ APP_USB_CDC

#define APP_USB_CDC   1

NUCLEO-WB55: USB_USER connector (CN1)

Definition at line 174 of file app_config.h.

◆ APP_USB_TLM

#define APP_USB_TLM   1

Definition at line 180 of file app_config.h.