This article describes the PX4FLOW (Optical Flow) Sensor.
Warning
The PX4FLOW is supported as an experimental feature starting from Copter 3.3. It is not supported in Plane or Rover.
The PX4FLOW (Optical Flow) Sensor is a specialized high resolution downward pointing camera module that uses the ground texture and visible features and a rangefinder to determine aircraft ground velocity. Although the sensor has plus 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 and instead a separate Range Finder such as the Lidar Lite should also be attached to the vehicle.
The built-in 3 axis gyro enables automatic compensation for vehicle tilt and heading relative to the ground. The PX4-FLOW incorporates the same powerful Cortex M4F Microcontroller as is used in the PX4-FMU.
More information on this sensor including how to upgrade the sensor’s firmware using QGroundControl can be found on the ETH’s PX4FLOW wiki page.
Warning
To use this flow sensor to perform optical flow loiter as seen in the following video, you will need to purchase a separate range finder. Our testing has been performed using thePulsed Light unit
The PX4Flow firmware must be updated prior to connecting to the Pixhawk:
Download and unzip the PX4Flow-KLT firmware (source code here)
Download, install and start QGround Control
Select PX4 Autopilot from the splash screen
Press the Config button to open the Firmware Upgrade screen
Click Advanced, then set Port to “
Push the Select File button and find the .px4 file downloaded from step #1
Push the “Flash” firmware and then push the small reset button on the edge of the px4flow sensor near the sonar.
The sensor should be connected to the Pixhawk’s the 4-pin I2C port. In most cases an I2C splitter should be used to allow other I2C devices (like the external RGB LED and GPS/Compass module’s compass) to the same port.
Mount the flow sensor pointing straight down with the X axis forwards and the Y axis to the right. The FLOW_ORIENT_YAW parameter can be used to account for other yaw orientations. It is important that the flow sensor be mounted where it does not experience angular angular vibration that could blur the image.
Note
The default mounting orientation is different to that shown on the ETH PX4FLOW wiki. If you mount the board as shown in the ETH PX4FLOW wiki, you will need to setFLOW_ORIENT_YAW
to -9000.
The sensor can be enabled by connecting with the Mission Planner and then on the Initial Setup | Optional Hardware | Optical Flow page check the Enable checkbox. Alternatively theFLOW_ENABLE
parameter should be set to “1” through the full parameters list. The sensor will be initialised once the Pixhawk board is rebooted.
The raw data from the sensor will eventually be visible on the Mission Planner’s Flight Data screen’s Status tab (issue raised here). Until then you can perform the following test in a well lit room. Note that some artificial lighting has strobing that can reduce the sensor performance. Natural light or a high power incandescent light source is best.
Warning
Follow the instructions on the ETH PX4FLOW wiki page on how to use QGroundControl to check and adjust the focus of your sensor. Do not assume it was in focus as shipped. You should be pointing it at a high contrast object about 3m away when you check the focus.
Warning
Disconnect the sensor I2C connection from your flight computer before you connect it to via USB to your computer, Otherwise the sensor will be trying to power the flight computer and it may not have enough voltage to work properly.
FLOW_ENABLE = 1
turns on use of the sensor and LOG_BITMASK = 131071
turns on pre-arm logging and will help diagnose problemsFind a location with a textured surface and good lighting (natural light or strong incandescent)
Remove Propellers (safety first)
Power on the vehicle and hold level away from your body and at eye level
Rotate about the vehicle in roll through a range from -15 to +15 degrees in about a second and then back again. Repeat this 10 times. By closing one eye you will be able to keep the centre of the sensor stationary against the background while you do the rotation.
Repeat about the vehicle pitch axis.
Download the data flash logs and plot the OF.flowX
, OF.bodyX
and IMU.GyrX
data. It should look something like this:
If OF.flowX
is larger or smaller than OF.bodyX
, then it can be adjusted by changing theFLOW_FXSCALER
parameter
IF OF.bodyX
is uncorrelated or opposite sign to IMU.GyrX
, the FLOW_ORIENT_YAW
parameter is probably set incorrectly or you do not have the flow sensor pointing downwards
Plot the OF.flowY
, OF.bodyYband
, IMU.GyrY
data. It should look something like this:
If OF.flowY
is larger or smaller than OF.bodyY
, then it can be adjusted by changing theFLOW_FYSCALER
parameter
IF OF.bodyY
is uncorrelated or opposite sign to IMU.GyrY
, the FLOW_ORIENT_YAW
parameter is probably set incorrectly or you do not have the flow sensor pointing downwards
Check the EKF5.meaRng message in the flashlog from your flow sensor calibration test. Check the following:
To allow arming and taking off in Loiter without a GPS the GPS arming check should be turned off as shown below. Unchecking “All” and “GPS” and leave all other options checked.
Because optical flow requires good sonar/range finder data when the optical flow is enabled, an additional pre-arm check is enforced.
While the vehicle is disarmed you should lift the vehicle straight up to at least 50cm but no higher than 2m (if the rangefinder sees a distance of over 2m you will need to restart the flight controller).
The error message when arming fails this check is “PreArm: check range finder”
This check can be disabled by unchecking the “Parameter/Sonar” arming check.
EKF_GPS_TYPE = 0
(we don’t want the optical flow being used by the EKF at this stage)OF.flowX
and OF.flowY
should be varyingOF.bodyX
and OF.bodyY
should be consistent with IMU.GyrX and IMU.GyrYWarning
You will need at least 15m of clear space around the vehicle to do this flight safely.
Set the EKF_GPS_TYPE parameter to 3 make the EKF ignore GPS and use
Warning
STABILIZE, ALT_HOLD or ACRO to a GPS mode, eg LOITER when flying with EKF_GPS_TYPE set to 3. If the optical flow velocity estimates are bad, you will have no warning and the copter could go to maximum roll or pitch when you make the switch. This vulnerability will be fixed in subsequent SW releases.
Ensure you have LOITER mode and STABILIZE mode available on you transmitter.
Take-off in loiter and bring the copter to about 1m height
Warning
to LOITER
If it starts to accelerate away or there is erratic pitch or roll movement, then switch to stabilise and land. You will need to download the log file and share it on the forum to understand why.
If it holds location then congratulations, you have succeeded and can now start experimenting with height changes and moving it around in LOITER