Can't switch to GUIDED or LOITER with optical flow

Hi everyone
I am having some trouble with flying the drone in GUIDED or LOITER modes. I am running ardupilot 4.4 on pixracer r15, I have connected Matek 3901-L0X optical flow module, which seems to be working fine. OptFlow quality is usually around 50-60, and i can see all the values like rangefinder, opt_x and opt_m_x change, which means i am getting the necessary data. I have completed all the necessary steps per the guide Optical Flow Sensor Testing and Setup, like changing EK3_SRC1_VELXY to 5 etc. The drone flies kinda fine in FlowHold mode, although the opt_m_x does not look great, but that is another issue. I want to eventually fly it autonomously with dronekit, so i have to fly it in Guided mode, which it can’t, because it won’t switch to it, citing “Switch to GUIDED failed: Need position estimate”. I have changed all of parameters, can’t even hope to remember the exact ones, so here is the param file. If there is a need for log file, I can also provide one.
no_guided.param (17.0 KB)
I will be very grateful for any advice on this topic, including on why my optical flow is so inaccurate. Thank you.

Set the EKF origin using a GCS.

Sorry, forgot to mention. I have also done that, both “Set Home Here” and “Set EKF Origin” in Mission planner both separately and together, did not help.

welp, after reinstalling ardupilot firmware, I was stuck at the same issue. Turns out, RNGFND1_MIN_CM was the problem. I am not sure that it was a problem before the reinstalling, but definitely was after. The issue is solved