Cannot switch to loiter mode with optical flow

My problem:

  • I cannot arm copter 3.4 in LOITER mode.
  • I cannot switch to LOITER mode after take off in ALTHOLD.

My setup:

  • PX2 controller with Copter 3.4.5 stable firmware.
  • LIDAR Lite v2 set as range finder.
  • PX4FLOW Optical Flow sensor reporting good values.
  • ALTHOLD flight mode works well.
  • No GPS is attached.

My symptoms:

  • I get a pre-arm check error: “Need 3D Fix”
  • When I switch in-flight to LOITER, I get an error message in the logs: “Subsystem:10 ErrorCode:5”, which I believe is: ERROR_SUBSYSTEM_FLIGHT_MODE and ERROR_CODE_DEST_OUTSIDE_FENCE.
  • There seems to be no effect when I switch to LOITER mode during flight. The copter has significant drift.

What I have tried:

  • I have gone over the PX4Flow setup instructions several times and confirmed that I am getting good values from the sensor.
  • I have triple-checked that my EK2_GPS_TYPE is 3 for optical flow.
  • I have triple-checked that the geofence is disabled.
  • Set GPS_HDOP_GOOD to a high value (9999)
  • Upgraded firmware from 3.4.3 to 3.4.5.
  • Confirmed that the GPS pre-arm check is disabled.

Any suggestions greatly appreciated! Thanks!

This purely means it couldn’t enter Loiter mode - which means it had no position information.

I have no ideas for your issue, but you should share a log.

Hi Francisco,

Thanks for taking a look. I have not looked at this further, but hope to get back to it this weekend. I have uploaded a flight log and my parameters.

px4flow.param (11.6 KB)
2017-MAR-05 11-49-01.bin (678.6 KB)


I am also facing the same issue with my copter 3.4.6. Please let me know if you make any progress.

Upgrade to latest stable firmware (3.5) , all the features for OpticalFlow and Lidar are present and functionnal.

Hi @ppoirier,

Thanks for the reply. Today I found the problem. Since px4flow sonar cant be used, I have connected the analog pin of sonar to 6.6 v Adc of pixhawk. It is working very good with Alt Hold mode. But when I switch to loiter it is not working. But if I put the EK2_ALT_SOURCE to Baro meter it is going to loiter. Can this issue be solved ?

As per your suggestion, will that Copter 3.5 work with the above sonar configuration instead of lidar ?

Yes it should you need an external distance measurement and a sonar can be used.

Thank you @ppoirier.

I will test with Copter 3.5 and update the progress.

Hi Madhu,

I was able to resolve my issues by reloading the firmware. I had tried this unsuccessfully before, but I found some other advice that said to load the firmware for a different type of airframe (e.g., ArduPlane), then reload the ArduCopter firmware. This resolved my issue of not being able to switch to loiter mode.

Last time I checked, there was a strong recommendation not to use the onboard sonar because it is unreliable over a large number of surface types. I recommend doing some testing on surfaces you will be flying over before actually flying.


Hi David , ppoirier,

I tried the both the ways as you suggested. But still I am not able to enter into loiter mode.

Its is beeping twice and showing flight mode is not changed. I observed one thing with copter 3.5.1, after putting FLOW ENABLE to 1 and restarting the pixhawk again the FLOW ENABLE is going back to 0.

Help me with this.

If you have good readings from optical flow (numbers change values an polarity according to movements) and that you have readings from sonar and EKF is ser correctly it should get into loiter

Otherwise click on the reset the parameters button and reconfigure

I am having similar issues with PX4flow and LidarLite v3 and pixhawk 2.1, on 3.5 copter release.

They are giving meaningful values, and I disabled the arming check for GPS and Range finder already.

I can’t arm or switch to LOITER mode. Althold works, no GPS module.

Any ideas would be helpful!
00-01-01_01-14-30.bin (936 KB)

@proficnc Phillip, what is the Bus Address of the external I2C ?

Copter 3.5 has one bug with booting the px4flow on start up.

Check one thing, are you getting optical flow readings when you power up the pixhawk with battery ?

In my case I was getting readings only when I power the pixhawk with usb, it was not showing values with battery.

Help me with this.

I tried calibrating my px4flow sensor as per the documentation. My optical flow data is very very noisy. I have kept chess checker board to focus and tune the FLOW_FX and FLOW_FY. I am gettingg very noisy values.

Help me how can I sort this out ?

I didn’t in fact have readings when flying with battery. You are right. I will see how I can use copter 3.6. Does copter 3.6 dev exist?

Are you using pixhawk 2.1 as well? I don’t know maybe 1m/s error is still fine for flying?

Otherwise I will check if loaded the required version of firmware and calibrate again. I will see what kind of measure I am getting for comparison

Which firmware version are you using?

Is this data recorded during flight, or just while you’re holding it in your hand? If it’s during flight, you might want to make sure that your props are very well balanced. If you have your Pixhawk connected to MissionPlanner or QGroundControl while you try to arm in loiter mode, it should give you a reason why it is unable to arm. Have you checked this? What was the reason?

If you connect your pixhawk to the MissionPlanner or QGroundControl software while you try to arm the system, it will give you a reason why it cannot arm. Have you tried this? What was the reason given for not being able to arm?

Hi thanks for reply.

Arming in LOITER works when powered with USB, LOG file displays OF information.

Currently I don’t have telemetry so I have to read the log to see why the arming doesn’t work with battery.

When powered with battery, arming/ mode switch fails, and the log doesn’t have optical flow data. I enabled logging while not armed and FLOW parameters are alright. Is the reason for arming/mode switch failure logged somewhere in the log file?

Are you using pixhawk2 the cube together with arducopter 3.5?