Seemingly good optical flow data, but copter ignoring it

Hello, first post here hopefully someone can give me a hand.

I’ve been trying to achieve a stable loiter without GPS on a 450 size quad using a Pixhawk Cube, Lidar Lite, and PX4Flow. My Quad flies very stable in normal loiter with EK2_GPS_TYPE set to 0 and using the rangefinder for altitude. The data from the rangefinder also seems to match the Baro altitude, so I think that’s working ok. Looking at the logs (which I’m not good at) it seems that the data coming from the flow sensor matches what the Wiki says it should so it seems to be working correctly as well. However, when I switch to EK2_GPS_TYPE 3 (no gps) it drifts away with the light breeze like its just in altitude hold mode and isn’t using the flow data at all. Not sure what else to check or what parameter I’m missing to allow the EKF to use the flow data. Attached are my logs from the last flight where it would drift away, then I’d correct and let go only for it to drift away again.

Log Files: https://drive.google.com/open?id=1qj5pNwA67FJ55tJqTiqFQiQRJXMv3lG5

And so the plot thickens. I’ve been mulling over the forums for the last few hours and read that EK3 needs to be enabled for flow to work. Well, I enabled EK3 and now my Pixhawk completely freezes up whenever I try to arm and requires a power cycle to alleviate. Even after I disabled EK3 again. Grrr…

To simply use only the optical flow sensor and not the GPS it’s definitely not necessary to use EKF3. It may be necessary to use the EKF3 if both GPS and optical flow are to be used at the same time but this is actually not a well tested setup. For now, I would go back to using the EKF2 which is what’s described on the wiki.

A few thoughts:

  • The flight controller should be rebooted if the EK2_GPS_TYPE parameter is changed
  • FlowHold mode will probably work
  • I’m suspicious of the EK2_FLOW_DELAY parameter’s default of 10. I had to change this to 80 for my recent tests with the Cheerson… but perhaps that is because the px4flow sensor’s update rate is 100hz while the Cheerson CX-OF is only 25hz. I’ll check into this.
1 Like

@rmackay9 as for delay, there is already 100msec delay in the code so 10 msec makes 110 msec effective

1 Like

So I was finally able to get it to arm and work correctly last night by switching completely over to EKF3. When it was failing to arm I had both EKF2 and EKF3 enabled, and it seemed like it was causing the board to hang so I set EK2_ENABLE to 0. Now my quad flies in LOITER with no GPS using only flow. Today I will try with flow and GPS together as that was my ultimate goal to achieve high accuracy loiter in sketchy GPS environments. Funny, I was unaware of FlowHold mode entirely as it doesn’t mention it in the optical flow section of the wiki.

1 Like

I agree with you about not knowing about flow hold, I think all of the setup guides for flow sensors need to be updated with that information. I personally found out about the flow hold mode and flew successfully with it, and then turned my EK TYPE GPS to 3 to simulate non gps environment, and also flew well in loiter…and then I turned the GPS back on and wrapped it in tin foil and tried again, and it flew well again… so that was lucky, but i struggled and fought with my px4 flow for like a week before I got it working correctly. I am using EKf2 still, with the board mounted with the X axis facing forwards and my FLOW YAW ORIENT set to 0. I had to seek help on the Ardupilot FB forums and luckily somebody gave me some info on their setup that is working correctly.