Optical Flow Sudden Crash Log

Dear Ardupilot Community. I successfuly set PX4Flow and performed 4 successful flights outdoors. I am using Leddar One as ALT meter and PX4Flow standard 16 mm lens. Overall configuration is Intel RTF drone. FlowX,BodyX,GyroX and FlowY,BodyY,GyroY charts are aligned, also during the flight.

During one flight (GPS is off ofcourse), there was sudden fast drift of copter to side and than I switched to Lend mode to minimize the crash impact. Below is the picture (chart 1) of the log. I can see, that OF.flowX dramatically fluctuated from BodyX and GyroX (same case with Y axis). Also it had strong impact on EKF Optical flow Innovations (chart 2) and resulting into APM: EKF3 IMU0 stopped aiding (I have only 1 IMU).

FlowX:

EKF flow innovation:

Do you have got any idea or suggestion why that happened? Could it be Magnetometer? Attaching RAW Magnetometer management during the flow discourse event

Other option of such failure could be, that lidar light influence px4flow camera sensor?

Thank you for any guidance and recommendations.

What was the altitude (would be interesting you add rngfinder alt + baro to graph) ?
What was the surface you flew over, was it reflective, was it sunny?

hi @ppoirier thanks for fast response. Below is more info suggested by you

  1. Expanded graph

Note - as primary source of EKF3 is Lidar( Leddar One) not baro. It is used by EKF upto 20 m ALT (set by parameters)

2.Overall “world” conditions prior to flight - video log 1 min optical flow hover (rather cloudy, grass, please see in the video)

3.I am attaching also the whole log

  1. Messages received from EKF3 before crash. First error - RC related is ok. Since I set failsafe to lend if radio is lost so I switched off radio when drift escalated

Also I was wondering if I can add higher protection for such situations to set

FS_EKF_ACTION (now 1) and FS_EKF_TRESH (now 0.8) ?

There is something quite curious on the log, its the drift of the barometer - this is showned in your graph, and I wanted to compare with thw EKF Innovation of the Optical Flow:


In the white circle you can see that when you initiate a yaw (RCin C4) the vehicle started as showned by ATT.Yaw, and then the BARO.Alt is starting drifting and the RFIND.Dist does not move (was it wind or a particular sensor position) , then you can see the the EKF innovation start drifting and stop.

Questions:
Have you set the focus of PX4-FLOW to approx 5- 10 Meter range ?
Did you enable EK2 as well or just EK3?
Is the PX4Flow Centered to vehicle ?

Hi @ppoirier. Thanks for log analysis intro. Very helpful!

Answers:

Have you set the focus of PX4-FLOW to approx 5- 10 Meter range ?
- No. Focus was cca 1.2 m.

Did you enable EK2 as well or just EK3?
- Only EK3 calculations and usage by EKF

Is the PX4Flow Centered to vehicle ?
- Yes.
was it wind or a particular sensor position?
UAV started to accelerate very quickly after EKF stop guidance most likely driven by wind

Questions:

KLT algorithm looks for pixels in picture taken at time t and compares with pixels taken at t+1 to find velocity of these pixels and it assumes pixels will be still in the picture frame somewhere in t+1 picture.

So in case of my 1.2m focus, it means, that KLT suddenly lost relevant pixels due to receiving too blurry picture (grass was much higher uncut in the place, where EK3 stoped guidance)? Since I was flying in 10 m right?

Right focus? - So to provide reasonably focused picture for KLT alg. We should set hyperfocal distance = when our flight is in 10m. It means to focus on the point in the middle of that distance = 5m. It means all pixels between 0 - 10 m will be still reasonably sharp?

Still what should be correct parameters to make copter land in case of EKF stopped guidance? It seems FS_EKF_ACTION and FS_EKF_TRESH are not the correct params. Right?

Actually I never played with thes parameters, so I cant comment on this. Setting focus to operational distance if important, especially over grass because of the texture. From my experience, flying 10 meter over a grass field can yield to system degradation, it is rock solid at 6 meter.

Try enabling EK2 as well, the system can switch (blend) to this estimator in case of degradation.

Opticalflow is quite experimental, I suggest you practice reverting to stabilize in case of problem, because switching off takes precious time for the FC to react and you giving up control to an unstable system

@ppoirier ok. I will try to apply your suggestions. Thank you.

hi @ppoirier. I did progress in my project (finally commanding UAV only using PX4Flow trough dronekit) and currently I would like to simulate PX4Flow in SITL. But problem is, that After following and setting PX4Flow sim according documentation at http://ardupilot.org/dev/docs/using-sitl-for-ardupilot-testing.html ( I am using only px4flow, GPS turned off). It seems, that SITL is not simulating PX4Flow. Or am I missing something? In case you tried to simulate PX4Flow, please could you let me know any suggestions you may have?Here is log from simulator. Apparently PX4Flow is not set correctly.

additionally health of PX4Flos is around 50, which is also way beyond correct functioning

Have you enabled the rangefinder?

Yes.When taking off in SITL graph RANGEFINDER.distance is showing changes in ALT.

Enabled according
param set SIM_SONAR_SCALE 10
param set RNGFND_TYPE 1
param set RNGFND_SCALING 10
param set RNGFND_PIN 0
param set RNGFND_MAX_CM 5000