Basic VISUAL_POSITION_ESTIMATE sample breaks EKF2

Hi,

I’m trying to make VISUAL_POSITION_ESTIMATE messages work. After a lot of trial and error, I ended up creating a very basic sample program, that simply feeds the position & orientation that PX4 reports for the drone in the form of VISUAL_POSITION_ESTIMATE messages. My expectation was that this would be a noop, as the visual position sent to PX4 is the same that it already has calculated.

The result is that one can’t even arm the drone in such a setup.

If one arms the drone and takes off without considering the VISUAL_POSITION_ESTIMATE messages, then starts to consider them after the drone is airborne, the drone will end up tumbling & moving erratically.

I wonder what I’m doing wrong, and how to make VISUAL_POSITION_ESTIMATE messages work. Any help is appreciated.

Details of the experiment:

I have a PX4 SITL setup using AirSim, as descrived here: AirSim Simulation · PX4 Developer Guide . I’m using the latest master for the PX4 Firmware. the ./build/posix_sitl_default/bin/px4 executable is started from the source directory. the PX4 startup script is this one: PX4 init script - Pastebin.com

after startup, I start my minimal VISUAL_POSITION_ESTIMATE app, which is based on the mavlink_upd.c sample code, here is the source: PX4 visual update sample - Pastebin.com

if I start PX4 with considering visual position estimates, I can’t even arm it:

pxh> param set EKF2_AID_MASK 25
+ EKF2_AID_MASK: curr: 1 -> new: 25
pxh> INFO  [ecl/EKF] EKF commencing external vision position fusion
INFO  [ecl/EKF] EKF commencing external vision yaw fusion

pxh> INFO  [ecl/EKF] EKF GPS checks passed (WGS-84 origin set, using GPS height)
INFO  [ecl/EKF] EKF commencing GPS fusion

pxh> commander arm
WARN  [commander_tests] PREFLIGHT FAIL: EKF INTERNAL CHECKS
ERROR [commander] arming failed

of I start it with GPS-only, I can arm & take off, but then it will time out on the fusion and the drone will tumble / move around:

pxh> commander arm
pxh> INFO  [logger] Start file log
INFO  [logger] Opened log file: ./log/2018-08-21/15_11_20.ulg

pxh> 
pxh> 
pxh> commander takeoff
pxh> INFO  [commander] Takeoff detected

pxh> param set EKF2_AID_MASK 25
+ EKF2_AID_MASK: curr: 1 -> new: 25
pxh> INFO  [ecl/EKF] EKF commencing external vision position fusion

pxh> WARN  [ecl/EKF] EKF GPS fusion timeout - reset to GPS
WARN  [ecl/EKF] EKF GPS fusion timeout - reset to GPS

tumbling is related to the fusion timeout events noted above.

I wonder what I’m doing wrong, and what is the simplest way to get a naive dummy sample of VISUAL_POSITION_ESTIMATE messages working.

Akos

I think you’re creating an instable feedback loop by sending delayed measurements back as actual measurements. You could try sending fixed values for position and attitude, but you won’t be able to fly then. At least you should see the EKF converge to that position.

first I tried sending a fixed value after takeoff (e.g. the actual value after the drone changes from takeoff state to airborne state). it had the same effect :frowning: