Servers by jDrones

Summary of Optical Flow Development in ArduPilot

(Greg Covey) #41

Hi Nafnaf,

Thank you for the detailed information. I will try to replicate the circle mode dips in another area (or surface) when the weather permits. I will also look at your tutorial link and see if it deviates from the APM Wiki where I set up my PX4 Flow board and firmware.


(Ben Freudberg) #42

Hi Greg,

I noticed that you have two sonars installed on your copter (one on PX4Flow and one Maxbotix). You can’t have two sonars powered at the same time because they will interfere with each other. The way they work is to send a pulse and then listen for that pulse to bounce back and measure the latency. If you have two sonars sending pulses, they will hear each other’s pulses and return incorrect readings.


(Greg Covey) #43

Hi Ben,

It is true that there are two sonars but only the one external to the PX4Flow board is activated. The sonar that comes with the PX4Flow board is not accurate enough for good distance measurements.

The installation I used is in the APM Wiki here. The Wiki also contains a list of appropriate external sonar devices with a wide range of pricing.

(Rotem Shfaim) #44

Hello All,

Is it possible to use a sonar or LIDAR as obstacle avoidance system (pointing to the front of the UAV)?

Thank you

(Mike Boland) #45

@Rotemshf Have a look in the documentation

(Akm) #46

Hi Greg

Thanks for sharing your experience. I am also trying to use Optical flow and I am sure your experience will help.

I have a few doubts:

  1. Why do you need to arm in loiter mode? How is it different from Arming in STABILIZE mode and changing it to LOITER when attained certain height?
  2. Did you tried getting position hold using Optical flow in GUIDED mode or GUIDED_NO_GPS mode?

(Greg Covey) #47


I do not know why you need to arm in Loiter mode. I typically arm in Stabilize mode and move the quad out onto the field for testing before changing to other modes. Currently, Stabilize mode is the only mode I can count on for accurate flight when Optical Flow is enabled. Note that you still need to pick up the quad before arming to calibrate the range finder.

I just happened to re-test my Tarot 650 quad yesterday in a wild field of long grass and bushes. I did video the two flights but decided not to render them on Vimeo since the performance was so poor. Several times, even though I was at a proper height, the quad was almost destroyed. I am still using the same firmware and parameters as mentioned above in my previous post and video.

When switching from Stabilize mode to Alt Hold mode, the copter would always dip significantly in height forcing me to raise the throttle setting to gain height. When switching to Loiter mode, the copter would usually stay in proper position. In this tall grass field, Circle mode did not work well. Switching back to Loiter mode from Circle mode made the copter move off rapidly in a wrong direction. I was forced to switch back to Stabilize mode and fly manually home.

It seems that BARO works much better for altitude hold and my M8N GPS works best for position hold than using the Optical Flow feature. It may be that my choice of an inexpensive rangefinder (Maxbotic I2C EZ4 $40.) does not perform well. Using a more expensive Lightware SF11/C 120m unit for $249 or Lightware SF10/B laser rangefinder for $400 may provide better results but they are not in my hobby budget.

I will likely abandon my Optical Flow testing for now and simply switch back to BARO and GPS with a parameter change. Perhaps the better sensors will come down in price for DIY users and I can revisit Optical Flow on a new copter firmware release. I am also waiting for prices to drop on RTK since $700 is beyond my hobby budget.

(Akm) #48

Hi Greg,

Thanks for sharing your experience. I can understand the difficulties you have gone through. Even I am on the same page.

Let me share my story:

My stack:

  1. Firmware installed - APM:Copter V3.5.0-rc6 (efab409b)
  2. PixFlow - Optical Flow
  3. Range Finder - Garmin Lidar Lite V3. Used PWM Connection.

I followed this guide step by step -

Test 1:

I tried the First Flight (Copter Only) as mentioned in the guide - I started flying the copter indoor in STABILIZE mode with EKF_GPS_TYPE = 0 at a height of 1 meter (approx). After a few minutes of flying, I switched to ALT_HOLD mode and my copter suddenly took an extreme hike in altitude and hit the ceiling and crashed, damaging the legs. Though it was not enabled to let ELF use Optical Flow, I am not able to figure out what went wrong.

Test 2:

I went to open space, set the EKF_GPS_TYPE parameter to 3 to make the EKF ignore GPS and use the flow sensor. Started flying in STABILIZE mode, took to copter to a height of 2 meters (approx), then switched to LOITER mode - Just in a nick of time, the poor copter dropped down damaging the legs, props and one motor. It didn’t get disarmed, I guess it just couldn’t respond to the throttle or something I don’t know.

Attached the logs for reference.
test1-stabilize-alt_hold-crash.bin (2.6 MB)
test2-stabilize-loiter-crash.bin.log (3.3 MB)

I am expecting to find the reason for these behavior before I do any further experiment with my copter.

My today’s goal was to test Position Hold using Optical flow and Lidar Lite V3 in LOITER & ALT_HOLD mode. But my ultimate goal is to make this thing work in GUIDED & GUIDED_NO_GPS mode. I want my copter to hold position even if GPS is not available for which I thought I could use Optical flow. So after this, i need to figure out - How to make this work in GUIDED mode.


(Soubhi) #49

Was you able to achieve position hold using PX4Flow in guided or guided_noGPS mode?

Thank you

(Just for fun) #50

Very helpful tread, thank you for posting!

What is the most up to date information on optical flow integration?
Best firmware version for success?

(Simon Cozzolino) #52

I’ve had a CUAV PX4 flow 2.1 sitting in the projects drawer for ages, waiting for a companion lidar to be purchased and for me to grow a pair.

I’ve just realised the sonar mounted is the maxbotix EZ4 1242 - so this should be a plug and play PX4 flow for anyone wanting to get started without buying an additional sonar or needing an i2c splitter as it’s done onboard. Correct me if I’m wrong. I’ll try it out. Nice work CUAV

Aside, is there any mileage to mounting the PX4flow to the bottom of a gimbal so it always faces straight down or is it ardupilot coded to account for pitch and roll? My Git fu isn’t strong enough to check.

(Alex) #53

hello @GregCovey
according to your tutorial that you have discarded above and that
the drivers of PX4flow and separate Maxbotix sonar are already taken by arducopter ??
just change some parameters in Mission Planner
to make a servo and landing with the PX4flow and sonar, is it true or it is necessary to modify the code that I clone since the source git clone ?

(Greg Covey) #54

Hi Alex,

Yes, that’s correct. The standard release of copter now contains the PX4flow support.


(Anna Sparks) #55

Hi @GregCovey
according to the wiki PX4flow

The PX4FLOW (Optical Flow) Sensor is a specialized high resolution downward pointing camera module and a 3-axis gyro that uses the ground texture and visible features to determine aircraft ground velocity. Although the sensor may be supplied with a built-in Maxbotix LZ-EZ4 sonar to measure height, this has not been reliable enough over a range of surfaces in testing, so its readings are not used

just out of curiosity, why the maxbotix of Px4flow is not used?
in what situation are these data false?
thanks for any answer

(Greg Covey) #56

Hi Anna,

The PX4FLOW Wiki Overview was not my writing. I do not know the author.


(Anna Sparks) #57

hi @GregCovey
take-off and landing using the PX4flow and a separate range finder are already supported by Ardupilot ?
how are used optical flow data as optical flow velocity controler ?

(James Pattison) #58

The flow sensor is an ekf input

(Mike Mahoney) #59

I’m struggling trough a similar problem with my PX4 and PX4Flow sensor on mission planner V3.5.5. I’m attempting to use the sonar as my rangefinder as well. Have you made any progress you could share? Here are my current parameters if that is helpful to you.

CurrentParams.param (13.2 KB)