Summary of Optical Flow Development in ArduPilot

Hi,

I am trying to understand the current state of development for using optical flow in ArduPilot. I’ve seen bits-n-pieces mentioned and even some non-released firmware to support various hardware. There was even a mention of “Glitter Chat” somewhere but I am quite ignorant on the current state of development of this feature in APM.

I know that the optical sensors were hard to purchase for a while but that seems to be relaxed now. I have some experience with DJI Inspire 1 capability and the Parrot visual control systems that have been out for more than 5 years now.

My initial question is if there is a forum or community where I can find more information on the current state of development for APM and perhaps help with some testing.

Thank you.

3 Likes

Hi Greg,

Optical flow is fully supported by ArduPilot. The supported hardware can be seen in https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_OpticalFlow/OpticalFlow.cpp#L86 and is as follows:

  • PX4Flow on any platform
  • Pixart PMW3900DH (not sold yet, but already supported) on Pixhawk1
  • Onboard camera in Bebop (not working by default as needs special library), Minlure and BBBmini

If you have any other question I’ll try to answer.

Hi Francisco,

Thank you for the kind reply. Can I assume then that I can start playing with the optical flow features in the new Copter v3.4 release? Also, is there a preferred sensor to purchase?

I did find some references in the APM Wiki.

[URL=“http://ardupilot.org/plane/docs/common-px4flow-overview.html?highlight=optical”]PX4FLOW Optical Flow Camera Board Overview[/URL]
[URL=“http://ardupilot.org/plane/docs/common-rangefinder-lidarlite.html?highlight=optical”]LIDAR-Lite Rangefinder[/URL]
[URL=“http://ardupilot.org/plane/docs/parameters.html?highlight=FLOW”]FLOW Parameters[/URL]
[URL=“https://pixhawk.org/modules/px4flow”]PX4FLOW Smart Camera[/URL]

I also found a v1.3.1 unit in the US.

[URL=“http://www.getfpv.com/holybro-px4flow-kit-v1-31.html?utm_source=bing&utm_medium=cpc&utm_campaign=**LP%20-%20NonTM%20-%20FPV%20Equipment&utm_term=PX4FLOW&utm_content=PX4FLOW”]Holybro PX4FLOW Kit v1.31[/URL] for $105.

Regards.

Yes, Copter 3.4 has everything needed to use optical flow. I would recommend a PX4Flow because it is supported in all platforms. Be aware that the sonar in it isn’t supported in ArduPilot so you need to have a separate supported rangefinder.

Excellent, thanks!

My next question would be on integration. I see that it replaces the use of GPS using parameter settings. What are the plans for automatic switch-over from GPS to Optical Flow and back? Is this something I can do using Copter v3.4 with a flight mode change or transmitter switch change?

It also looks like you need to purchase a $400 Lightware SF10/B laser rangefinder. So this now makes the optical flow feature an additional $500 hardware setup. Does this sound accurate?

I’m looking for future capabilities where GPS is used for normal outdoor flight but optical flow is then used for near ground flight or can be invoked on take-off in close quarters. After the 3-15 meter height limit, it then switches to GPS. I am curious about the planned path forward.

Thank you.

Hi Greg,

The documentation might be a little outdated: a short time before the release of 3.4 the optical flow support had an important change, it can now be used together with GPS. So when you have both available it will integrate information from both to get the best estimates and if you lose GPS it will switch to using optical flow only, if available.

Regarding rangefinder, we support multiple brands and models, including several from LightWare (I’m not sure, but I think the most used is the SF11/C). Have you checked the wiki pages?

Francisco,

Your information here is very much appreciated as it does seem the documentation is a bit dated…hence my need for this thread. The current integration looks to be what I wanted.

On the plus side, the Lightware SF11/C 120m unit is only $249 which makes the new higher-end entry cost for testing optical flow around $349 instead of $500. Further, using a lower cost unit like the Maxbotic I2C EZ4, the rangefinder portion drops greatly to only $40 making a lower end entry cost around $145. This is a very reasonable range.

My assumption here is that the PX4FLOW Kit v1.31 comes with the sonar (MB1043) already mounted and installed but it is unusable for some reason so the Lightware SF11/C unit is required.

Thanks again, you have been most helpful!

Hi Greg,

A rangefinder is needed to use optical flow. Sonars are usually not very accurate and I guess that is the reason a driver for the one present in PX4Flow was never added to ArduPilot. If you just want to use the rangefinder for experimenting with optical flow I guess the Maxbotic one is probably enough - you can always change rangefinder later.

The Pixart one I talked about is supposedly a cheap optical flow sensor that is expected to lower prices in this market (we basically only have the “expensive” PX4Flow). If you want to wait maybe there will be cheaper solutions available, but I have no idea of timelines.

Ok, it sounds good. I have selected my initial hardware for testing and already ordered it. I am looking forward to having some fun and testing this interesting new feature.

[B][U]Hardware Used:[/U][/B]
[URL=“http://www.getfpv.com/holybro-px4flow-kit-v1-31.html?utm_source=bing&utm_medium=cpc&utm_campaign=**LP%20-%20NonTM%20-%20FPV%20Equipment&utm_term=PX4FLOW&utm_content=PX4FLOW”]Holybro PX4FLOW Kit v1.31[/URL] $105.
[URL=“http://www.maxbotix.com/Ultrasonic_Sensors/MB1242.htm”]Maxbotic I2C EZ4[/URL] $40.
Tarot 650 Sport Quadcopter
Tarot 680 Pro Hexacopter

1 Like

Install Notes:

  • Use APM Wiki Instructions here.
  • Upgrading the PX4Flow sensor’s firmware had issues:
    • Used this article here on disabling driver signature in Win10 but it still failed. Win7 worked fine the first time.
    • Mission Planner v1.3.43 failed to show the “Load Custom Firmware” option when the PX4 Flow device was connected.
    • Used QGroundControl v3.0.2 and it worked first time without issue.
  • Focusing the lens worked fine in Mission Planner v1.3.43
  • Tarot 650 Sport upgraded to Copter v3.4.3 - No issues

I started some Install Notes in my project above. Once the PX4Flow sensor’s firmware was upgraded, I installed the unit along with my Maxbotix Range Finder on and old GoPro Hero2 gimbal top plate that mates with either of my Tarot MRCs. An I2C expansion card is needed as my Pixhawk I2C slot was already filled with the external M8N compass.

1 Like

Calibrating the sensor:

Next, I calibrated the sensor and ended up using a value of 50 for FLOW_FXSCALER and FLOW_FYSCALER.

Range Sensor Check:

For the Range Sensor Check, I could not find the EKF5.meaRng message in the flashlog per the Wiki. Perhaps this has been renamed?

I think it is NKF5.rng now.

1 Like

Right you are! It looks like I have some issue with my Maxbotix Range Finder. It appears that I skipped the part on setting it up in Mission Planner.

That was it. The NKF5.rng looks to be tracking reasonably now. Thank you!

1 Like

The Optical Flow assembly mounted easily on my Tarot 650 Sport rails. Both the PX4FLOW unit and Maxbotix Rangefinder simply plugged into the I2C Distribution Board along with my compass from the M8N module. The I2C Distribution Board then plugged into the Pixhawk I2C port. The board was placed about midway between the two areas so that the 4-pin cables would reach without modification.

I’m ready to test fly as soon as our 1-2" of snow melts, which should be in a day or two. I didn’t want to initially test the Optical Flow unit with a cover of snow.

So much for waiting for better weather. It was cold, windy, and I had an inch or two of snow in my backyard. Further, it is a smallish area surrounded by tree limb hazards on three sides and above. In other words, risky business!

I decided to test Alt. Hold and GPS-only Loiter modes first since it was my initial flight with Copter v3.4.3. My Alt. Hold was not solid so I discovered that the replacement for THE_MID, MOT_THST_HOVER was initially around 0.4 and slowly learning that it needed to be 0.3. Once I set it to 0.3, based upon my THR_OUT readings, the Alt Hold was rock solid and the GPS Loiter mode was very nice!

Next up, I changed EK2_GPS_TYPE (wrongly called EKF_GPS_TYPE on the Wiki) from 0 (use GPS) to 3 (ignore GPS and use the flow sensor). It was time for the nervous litmus test in a confined area. I got the Tarot 650 in position in Alt. Hold mode at around 4’ and switched to Loiter. I almost couldn’t believe it as it sat there perfectly still in the wind better then when using GPS. I was thrilled and will make a video soon when possible.

What should EK2_GPS_TYPE be set to for normal GPS/Optical Flow switch-over operation? 0?

Happy New Year!

2 Likes

We lost our snow today as the temperature rose to 37 degrees and the wind was down to around 10mph so it made for a fun initial test of the APM PX4 Optical Flow feature in my backyard. The EK2_GPS_TYPE parameter was set to 3 to ignore GPS and use the flow sensor.

2 Likes

Great stuff!
Thanks for the report and guide.
Have the parts laying around some time but couldnt get to it.

Time to get it done finally while upgrading to 3.4.3 :slight_smile:

1 Like

Yes, it should be 0.