MechFlow V1 Optical Flow and Rangefinder Sensor¶
MechFlow V1 is a combined optical-flow and laser time-of-flight (ToF) rangefinder module built around a PixArt PMW3901 optical flow sensor and an ST VL53L1X ToF rangefinder, output over a single UART using the MSP v2 protocol. This can be used to improve horizontal position and altitude control especially in GPS denied or indoor environments.
Where to Buy¶
The sensor is available from The Mechintel Store.
Connection to Autopilot¶
The flow sensor should be mounted on the underside of the vehicle with the camera lens pointing downwards
MechFlow V1 exposes four signals: GND, 5V, RX and TX, available both on a 4-pin JST-SH 1.0mm connector (pin 1 to pin 4: GND, 5V, RX, TX) and on solder pads, so it can be wired to any autopilot’s UART port either with a JST-SH cable/adapter matching the autopilot’s connector, or by soldering directly to the pads. The
GND/5Vand auxiliary SPI pads are on the top (front) of the board with the lens; theTX/RXUART pads are on the bottom (back)Connect module
GND/5Vto the autopilot’s peripheral power rail, moduleTXto a spare serial port’sRXpin, and (optionally) moduleRXto that same serial port’sTXpinOnly
TXis required for normal operation.RXis reserved for a future configuration/passthrough mode and has no effect with current firmware, but can be wired now so it’s ready if that feature is added laterSupply voltage is 5V, drawn from the autopilot’s peripheral power rail. Do not exceed the rated voltage
TX/RX solder pads, underside of board¶
Parameters¶
For the following we will assume the sensor is connected to Serial2 of the autopilot. Any serial port can be used, however.
Set SERIAL2_PROTOCOL = 32 (MSP)
Set SERIAL2_BAUD = 115 (115200 bps)
Set FLOW_TYPE = 7 (MSP)
Set FLOW_FXSCALER = -800
Set FLOW_FYSCALER = -800
Set RNGFND1_TYPE = 32 (MSP)
Set RNGFND1_MIN = 0.04
Set RNGFND1_MAX = 4 to set the range finder’s maximum range to 4m
Reboot the autopilot after changing
RNGFND1_TYPE
Once the sensor is active you should be able to observe the optical flow and range sensor data on Mission Planner’s “Status” page. The “opt_qua” and “rangefinder1” fields should show non-zero values.
Additional Notes¶
As with all optical flow sensors, a range finder is required to use the sensor for autonomous modes including Loiter and RTL. MechFlow V1’s onboard VL53L1X rangefinder, configured via
RNGFND1_TYPEabove, satisfies this requirement on its own — no separate rangefinder needs to be purchased or connectedFlowHold does not require the use of a rangefinder but performance is generally worse than Loiter mode and is not recommended
Performance can be improved by setting the sensor’s position parameters. For example if the sensor is mounted 2cm forward and 5cm below the frame’s center of rotation set FLOW_POS_X to 0.02 and FLOW_POS_Z to 0.05
The onboard VL53L1X completes a new rangefinder measurement roughly every 55ms, while MSP telemetry is output at a fixed 100Hz; the rangefinder value is therefore repeated across several telemetry frames between updates rather than refreshed on every frame