Optical Flow
This page features information on how to set up your autopilot to fuse the optical flow and synthetic rangefinder that cyclops provides.
Ardupilot Parameters
Set these on the FC via Mission Planner / MAVProxy.
Optical flow
FLOW_TYPE 5 # MAVLink optical flow source
FLOW_FXSCALER <computed below>
FLOW_FYSCALER <computed below>
FLOW_ORIENT_YAW 0 # 0 if camera +X aligns with vehicle +X; 180 if reversed
FLOW_DELAY 30 # ms; bump to 50 if post-flight XKFR innovations are biased
EK3_FLOW_USE 1
## for the following params you may use a different source if wanted
EK3_SRC1_VELXY 5 # OPTFLOW
EK3_SRC1_POSXY 0 # none (flow gives velocity, not absolute position)
EK3_SRC1_POSZ 1 # baro
RC7_OPTION 90 # EKF_SOURCE_SET — flip SRC1↔SRC2 from the TX in flightSynthetic Rangefinder
RNGFND1_TYPE 10 # MAVLink rangefinder
RNGFND1_ORIENT 25 # PITCH_270 (down)
RNGFND1_ADDR 0
RNGFND1_MIN_CM 5
RNGFND1_MAX_CM <ceiling, e.g. 5000 for 50 m>
## this value (MAX_CM) varies depending on you use case (see below)When using VTOL drones, the MAX_CM parameter should be ~30m higher than your transition altitude. For example, if transition from quad into forward flight at 50m, set the param to <8000> cm. However, for stol drones, this parameter should be dropped down to <3000 cm
Compute the flow scalers
oflow sends OPTICAL_FLOW at 25 Hz, so T = 1/25 = 0.04 s, T² = 0.0016.
Read fx, fy (pixels) from the rectified camera intrinsics found on vozilla.

SCALER = (1 / (f × 0.0016) − 1) × 1000Round to integer. FLOW_FXSCALER uses fx, FLOW_FYSCALER uses fy.
f (px)
Scaler
320
+953
514.57
+214
800
−219
AP rejects scalers outside roughly ±800 (true scale 0.20×–4.00×). If the formula gives something extreme, recheck fx / fy — you may be reading the raw sensor matrix instead of the rectified one.
Bench Verification
Power up the FC and the companion. In Mission Planner, hit Ctrl+F → MAVLink Inspector.
Under Vehicle 255 (the companion) you should see:
OPTICAL_FLOW—flow_x/flow_ychange when you wave a hand in front of the cameraDISTANCE_SENSOR—current_distanceroughly tracksrelative_altreported by the FC
Under Vehicle 1 (the FC):
RANGEFINDERreports a fresh distanceMission Planner → Status tab →
RNGFND1andOFrows are live
If OPTICAL_FLOW or DISTANCE_SENSOR is missing under Vehicle 255: SSH to the NanoPi and run journalctl -u oflow.service -f. You should see SEND OPTICAL_FLOW and SEND DISTANCE_SENSOR lines. If RECV GLOBAL_POSITION_INT is also missing, MAVProxy isn't routing the FC stream to UDP 127.0.0.1:14555.
Flying Without GPS
The FC needs an EKF origin and home position before any GPS-denied mode (LOITER, FlowHold, etc.) will engage.
VTOL
Set the EKF origin and home position via Mission Planner. Optical flow + the synthetic rangefinder give EK3 enough to hold position during takeoff, and into forward flight.
STOL / fixed-wing (TALON)
Same as above, but EK3 also needs a few seconds of plausible position fix before it'll release for arming. Use the GPS spoof tool on vozilla:
Vozilla → Settings → Lab → GPS Spoof
Set Duration to 15
Click Spoof Home Position
Wait the full duration before arming
Arm, take off.

Last updated
