Build and Flash PX4FLOW Firmware
Download the PX4FLOW Firmware Source and build the firmware
git clone https://github.com/PX4/Flow.git cd Flow make archives # this needs to be done only once make
Connect the PX4Flow unit to your PC via USB.
Make sure the I2C cable between PX4FLOW and Pixhawk is disconnected (otherwise, the Pixhawk will try to boot via PX4Flow and fail due to insufficient power). Alternately, use QGroundControl to load the latest binary firmware (may not support latest features).
NOTE: Some versions of QGroundControl are missing the menu to upload custom firmware from local filesystem. Use the latest version (v2.8.0) in order to upload the custome firmware to PX4FLOW. v2.8.0 also has PX4FLOW specific settings menu with auto-video streaming. If you want to run an older version of QGroundControl, use v2.5.2 or earlier in order to be able to load custom firmware to PX4FLOW.
All release versions of QGroundControl can be found here.
Adjust Lens Focus
NOTE: Do this before mounting PX4FLOW to your vehicle as it's much easier.
- Connect PX4FLOW to QGroundControl via USB.
- With the latest version of QGroundControl, video is automatically streamed and displayed in the PX4FLOW specific settings menu.
- From the parameters menu, set VIDEO_ONLY=1 in order to view high-resolution video for adjusting lens focus.
- While view the video stream via USB, twist the focus ring on the PX4FLOW lens so that the image is focused and edges are sharp at around 3 meters (or your average hovering height, which is 1m in my case).
- Tighten the focus ring screw once focus has been adjusted.
- Disable high-resolution video streaming mode by setting VIDEO_ONLY parameter to 0.
Mount the PX4FLOW unit
Once lens focus has been adjusted properly, mount the PX4FLOW to the underside of your vehicle using a good anti-vibration mount.
- Vibration can hinder the OpticalFlow performance.
- Pay attention to the mounting direction as described in the wiki. It's different from the orientation APM uses. If you've mounted per APM's directions (x facing forward), then set the following parameter on PX4 Firmware via QGroundControl.
SENSE_FLOW_ROT -> 2(90 degrees)
- Use DF13 4 pos connector to connect I2C port of PX4FLOW to I2C port of Pixhawk/PXF.
Mount and Setup RangeFinder
Update PX4 Firmware
Clone the source code from github and build the latest master. Do not use pre-compiled binary available via QGroundControl.
git clone https://github.com/PX4/Firmware.git cd Firmware # Use the latest master. This will also upload the compiled binary to Pixhawk make px4fmu-v2_default upload -j 4
PX4FLOW related parameters
Setup Using QGroundControl
Set the following parameters according to the documentation:
# Change the following parameters SENS_EN_LL40LS -> 1 INAV_LIDAR_EST -> 1 # Change these according to the documentation INAV_FLOW_DIST_X INAV_FLOW_DIST_Y INAV_LIDAR_OFF
Reboot the Pixhawk, pick it up in the air and make sure:
- OPTICAL_FLOW_RAD.quality is around 200
- DISTANCE_SENSOR.current_distance is showing your current distance
- LOCAL_POSITION_NED.x etc. are not zero
- You won't be able to switch to POSHLD unless you have a good flow reading, so take off in manual mode first and gain altitude before switching to POSHLD
- If LOCAL_POSITION_NED.x keeps increasing, you probably need to change your room lighting. Avoid LED and Florescent lights and go with incandescent light if possible. Also, avoid non-textured or shiny floors.
- PX4FLOW Developer Guide - Pixhawk Flight Controller Hardware Project
- Pixhawk PX4Flow indoor demo - YouTube
- Development for PX4Flow 2.0 hardware by kevinmehall · Pull Request #65 · PX4/Flow
- Position estimator