ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

AP_Baro: support for barometer position compensation

Open ahmedmsalah99 opened this issue 6 months ago • 6 comments

Addressing: #30727

Added baro position offset simulation and variables SIM_BARO_POS_. Added baro position offset variables BARO_POS_ in the barometer implementation.

Added correction for barometer offset in both EKF2 and EKF3.

ahmedmsalah99 avatar Aug 10 '25 13:08 ahmedmsalah99

Test:

After launching a plane SITL simulation with a normal mission

wp load ../Tools/autotest/Generic_Missions/CMAC-circuit.txt

param set SIM_BARO_POS_X 60 param set SIM_BARO_POS_Y 60 param set SIM_BARO_POS_Z 10

mode auto arm throttle

then mid flight set BARO_POS_* to same values as above

results for EKF2 and EKF3 show big fluctuations in estimation when compensation variables are not set correctly which is corrected when the parameters are set:

EKF2_Pos_D EKF3_State_Values_Pos_D

ahmedmsalah99 avatar Aug 10 '25 14:08 ahmedmsalah99

Currently now I added BARO_POS_* which accounts for 1 barometer only. Should I extend the work for all barometers possible ?

ahmedmsalah99 avatar Aug 10 '25 14:08 ahmedmsalah99

@peterbarker I added the if condition and the variable in the baro configurations. Should I add the if statement to every change in the code related to the compensation too (EKF2 and EKF3 code) ?

ahmedmsalah99 avatar Aug 12 '25 08:08 ahmedmsalah99

@Williangalvani will be interested in this

peterbarker avatar Oct 31 '25 10:10 peterbarker

@peterbarker I didn't work with the testing part before. The EKF3 algorithm accounts for height offset with fusion so it's hard to see the effect immediately. Instead the effect shows well with big offset + plane turns.

Normal baro with no offset or with offset + compensation in turning Screenshot from 2025-11-18 14-34-51

Baro with offset and no compensation: image

This maybe tricky to test (or not, IDK).

ahmedmsalah99 avatar Nov 18 '25 15:11 ahmedmsalah99

There was also a small logic error which I fixed

ahmedmsalah99 avatar Nov 18 '25 15:11 ahmedmsalah99