Indoor position hold using ekf2 with flow sensor has toilet bowling

Indoor position hold becomes toilet bowling as seen below video.

Build is from https://github.com/PX4/Firmware/tree/crazyflie_optflow and pmw3901 sensor used for flow sensor.
I noticed magnetic field around this room is not so good and might affect the performance of ekf2.
Is there a way to make ekf2 more tolerable to poor compass? I am asking because some other reference drones such as hover camer or DJI’s spark flies just fine in the same area.

Above issue can be resolved by increasing update rate of optical flow data.
As I found in below pmw3901 code, raw delta x, y from the sensor are summed until time elapsed from last flow data transmission gets to 45000 or 45 ms however this is too long for ekf2 estimator.

I changed this code to send for every delta x,y update and all of sudden the drone stops toilet bowling.
Also I noticed that PMW3901_SAMPLE_RATE is set to 10000 or 10ms but is not guaranteed by the system.
When measured dt between the measurement, it is not solid and off about 2 to 3 ms and sometimes gets to 10ms delay.
/-----------------------------------Added below
Below plot is time dt of flow data gathered while flying. I clearly shows there are lots of jitter in timing.


-------------------------------------/End Add

If dt becomes more solid, stability would be much improved.
One solution would be changing the main processor but is currently fixed so I have to find other solution now.

1 Like

Hi

For the jitter you can try to run the driver on the high-priority work queue: change the following 2:



to HPWORK.

@bkueng Thank you for letting me know about this.
I should give it a try and see how it works.

Kyu

It works!
Not I am getting dt between flow measurements more close to 10ms and 11ms at worst case ase below.

Overall position control performance is to be investigated but it looks good not.
Thanks,

1 Like

Cool! Are there other changes required? Can you create a pull request for this?

@bkueng I’m not sure whether PR to master or just crazyflie_optflow branch.
Do you think this affects to all and master as well?

Yes this should be changed on master.