Does anybody have experience with using optical flow at a much higher altitude, such as ~20m? ... My initial guess is that ~20m is probably not doable, but I would like to hear otherwise. :) We have some work that could benefit from it.
In case someone might find it useful, here's my notes on using the sonar on PX4FLOW as the analog rangefinder.
Since I mostly fly small quads indoors, I thought it would be nice to shed some weight by eliminating bulky and heavy LiDAR unit so I gave it a try, but it turns out my sonar unit was too noisy to be usable so I decided not to go this route, but your milage may vary.
Using the Sonar on PX4FLOW as RangeFinder
The sonar module that comes with 3DR PX4FLOW module is either LV-MaxSonar-EZ4 (a.k.a MB1040, according to the schematics) or HRLV-MaxSonar-EZ4 (a.k.a. MB1043, according to 3DR's site).
MB1040 is a low-resolution version that has 1 inch resolution and usable range of 6 to 254 inches (152mm to 6,450mm).
MB1043 is a high-resolution version that has 1mm resolution and usable range of 300mm to 5,000mm.
Range of analog output is between 0.0v and the Vcc supplied to the sonar. So if you hook it up to 3.3 Vcc, maximum will be 3.3V. If you use 5V source, maximum output will be 5V.
PX4FLOW supplies 5V to the sonar, so the maximum output voltage from pin 3 is going to be roughly 5V (slightly lower in practice). Note that this fluctuates depending on the quality of power source. When powered via USB, it's usually lower than 5v, but when powered via battery and power module, it goes over 5V.
Make sure you connect the analog out of the sonar to Pixhawk's 6.6V ADC input.
DO NOT connect the PX4FLOW's sonar to the 3.3V ADC input directly as the maximum voltage will be too high for the 3.3V ADC port.
Pixhawk's 6.6V ADC input socket is 3 pos DF13. The center pin is the analog input. The pin on the right (when viewed from above) is the ground (if you are using pre-assembled cable from 3DR, it will be the other black cable). On Pixhawk, pin #1 (one one the left) is always Vcc on any of the DF13 sockets.
# Analog=1, I2C=4RNGFND_TYPE=1
# Analog output on EZ4 is linear
RNGFND_FUNCTION=0
# Analog input pin on ADC 6.6V socket is mapped to virtual pin 15.
# If you've connected the sonar to ADC 3.3V socket (using voltage converter), it will either be virtual pin 13 or 14 (ADC 3.3V socket has 2 analog input pins combined).
RNGFND_PIN=15
# EZ4 is linear and ratiometric
RNGFND_FUNCTION=0
RNGFND_RMETRIC=1
# Don't connect stop pin (sonar will always be on)
RNGFND_STOP_PIN=-1
# The wiki says you should set this to 7m for EZ0 and EZ4, but that's for XL-MaxSonar series. HRLV-Max-Sonar-EZ4 on PX4FLOW only mesures up to 5m.
RNGFND_MAX_CM=500
# EZ4 on PX4FLOW won't return reliable data if the distance is closer than 30cm.
RNGFND_MIN_CM=30
# Adjust the following according to the description given by Paul Riseborough in the previous comment.
# Distance in cm of the PX4FLOW unit from the ground.
RNGFND_GNDCLEAR=2
# In theory, the voltage range should be between 0.293V and 4.885V (300mm to 5000mm) when Vcc = 5V for the EZ4 sonar on PX4FLOW.
RNGFND_OFFSET=0.293
# Acroding to the datasheet, EZ4 will return 4.885mV at 5m when given 5V Vcc.
# 5m / 4.885v
RNGFND_SCALING=1.02354
# Finally, if you are using EKF.
AHRS_EKF_TYPE=1
EKF_ENABLE=1
EKF_GPS_TYPE=3
# Use range finder instead of baro.
EKF_ALT_SOURCE=1
# If you are using EKF2.
AHRS_EKF_TYPE=2
EK2_ENABLE=1
EK2_GPS_TYPE=3
# Use range finder instead of baro.
EK2_ALT_SOURCE=1
Testing
Before arming with range finder attached, you need to raise the aircraft to at least 50cm, but no more than 2m in height. Pre-arm logic checks the rangefinder's health status by confirming that both minimum and maximum values registered before arming is within certian pre-determined threshold (i.e. if the range does not go over 50cm, pre-arm check will fail. It will also fail if the reading goes over 200cm)
If the sonar is noisy and if it spikes to full output even for a short while before pre-arm check clears, you won't be able to ARM unless you reboot.
Also, if your sonar is mounted too close to the ground, the output on these EZ sonars tend to max out or fluctuate between min and max values, and you won't be able to arm. Again, you'll have to reboot.
Hi Paul, I'm not sure why log shows like that and I've tested it indoor like space under big bridge which protected GPS signal perfectly. I'll do test it again. Thanks for your comment ^^
Hi! I'm testing v3.3.2-RC2 using PIXHAWK and PX4FLOW. I read reply Goro Senzai and all comments. But still have two questions
1) I’m set the EKF_GPS_TYPE parameter equal to 3 and trying take-off in Loiter mode. But copter lost PITCH control via transmitter and autopilot also cann’t control PITCH. 2) On the floor always "Error compass variance". I arm copter in hand and then put on the floor. I set FS_EKF_THRESH 0 (and second test set 1), but nothing changed.
Help me please with my questions. Thanks in advance
Interesting. It must've been fixing some other issue with my quad then. To be clear, it was the setting labeled "Loiter PID" in the upper right hand corner of Mission Planner's settings that appeared to "fix" my loiter issues. The settings labeled "Rate Loiter PID" did not resolve my issues.
Under ideal Optical Flow conditions on a typical 450 class quadcopter (lots of incandescent light, varied ground texture, focused PX4flow, tuned PID settings, and altitude of ~1 meter) how much X-Y drift should we expect to see in Loiter Mode?
We're doing a project where we would like to follow LED beacons in a parking garage, so we're going to be pretty much between 1 and 2m altitude all the time.
Are there any plans to incorporate sonar backup for the lidar? If nobody is working on that yet, I could commit our changes? My idea would be to look at both sonar and lidar, then switch to sonar and reboot lidar if it becomes unstable.
Thomas Stone > Fabien BruningNovember 28, 2015 at 12:49pm
Hi Fabien,
We are working on a somewhat similar project, but at a higher altitude. Let me know if I can shoot you a PM sometime. :)
We're interested in developing a "next generation" optical flow sensor where the camera lens is slaved to a high accuracy laser altimeter in order to provide dynamic focus and increase the useable range. We're looking for someone to flight test our new SF11 laser altimeter with the PX4Flow so that we can collect some real world data before moving forward with the final design. @Fabien, would you be interested in testing the SF11 on your project? We already have some high altitude flight data but we need verification of the short range performance as well :).
Replies
Thanks, Paul. That sounds promising.
We intend to fuse the data from PX4Flow and our IR-LOCK system. In the simplest implementation, IR-LOCK would be used to correct the drift.
Also, we were thinking of using IR-LOCK to compute x-y velocities, but I am not 100% confident in that approach.
What exactly do you mean by "accurately focused and calibrated sensor"? Did you use the default 16mm lens?
Does anybody have experience with using optical flow at a much higher altitude, such as ~20m? ... My initial guess is that ~20m is probably not doable, but I would like to hear otherwise. :) We have some work that could benefit from it.
In case someone might find it useful, here's my notes on using the sonar on PX4FLOW as the analog rangefinder.
Since I mostly fly small quads indoors, I thought it would be nice to shed some weight by eliminating bulky and heavy LiDAR unit so I gave it a try, but it turns out my sonar unit was too noisy to be usable so I decided not to go this route, but your milage may vary.
Using the Sonar on PX4FLOW as RangeFinder
Connection
PX4FLOW supplies 5V to the sonar, so the maximum output voltage from pin 3 is going to be roughly 5V (slightly lower in practice). Note that this fluctuates depending on the quality of power source. When powered via USB, it's usually lower than 5v, but when powered via battery and power module, it goes over 5V.
Make sure you connect the analog out of the sonar to Pixhawk's 6.6V ADC input.
If in doubt, consult these pages.
Configuration
Testing
Hi Paul, I'm not sure why log shows like that and I've tested it indoor like space under big bridge which protected GPS signal perfectly. I'll do test it again. Thanks for your comment ^^
Hi!
I'm testing v3.3.2-RC2 using PIXHAWK and PX4FLOW.
I read reply Goro Senzai and all comments. But still have two questions
1) I’m set the EKF_GPS_TYPE parameter equal to 3 and trying take-off in Loiter mode. But copter lost PITCH control via transmitter and autopilot also cann’t control PITCH.
2) On the floor always "Error compass variance". I arm copter in hand and then put on the floor. I set FS_EKF_THRESH 0 (and second test set 1), but nothing changed.
Help me please with my questions. Thanks in advance
2015-11-25 17-14-18 26.bin
Interesting. It must've been fixing some other issue with my quad then. To be clear, it was the setting labeled "Loiter PID" in the upper right hand corner of Mission Planner's settings that appeared to "fix" my loiter issues. The settings labeled "Rate Loiter PID" did not resolve my issues.
Randy/Paul--
Under ideal Optical Flow conditions on a typical 450 class quadcopter (lots of incandescent light, varied ground texture, focused PX4flow, tuned PID settings, and altitude of ~1 meter) how much X-Y drift should we expect to see in Loiter Mode?
We're doing a project where we would like to follow LED beacons in a parking garage, so we're going to be pretty much between 1 and 2m altitude all the time.
Are there any plans to incorporate sonar backup for the lidar? If nobody is working on that yet, I could commit our changes? My idea would be to look at both sonar and lidar, then switch to sonar and reboot lidar if it becomes unstable.
Hi Fabien,
We are working on a somewhat similar project, but at a higher altitude. Let me know if I can shoot you a PM sometime. :)
-Thomas (IR-LOCK)
We're interested in developing a "next generation" optical flow sensor where the camera lens is slaved to a high accuracy laser altimeter in order to provide dynamic focus and increase the useable range. We're looking for someone to flight test our new SF11 laser altimeter with the PX4Flow so that we can collect some real world data before moving forward with the final design. @Fabien, would you be interested in testing the SF11 on your project? We already have some high altitude flight data but we need verification of the short range performance as well :).