For the complete documentation index, see llms.txt. This page is also available as Markdown.

Optical Flow

This page features information on how to set up your autopilot to fuse the optical flow and synthetic rangefinder that cyclops provides.

This document assumes that you are using both the optical flow and synthetic rangefinder together. Your device can be configured to use an actual, more accurate, rangefinder if preferred.

1

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 flight

Synthetic 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)
2

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) × 1000

Round to integer. FLOW_FXSCALER uses fx, FLOW_FYSCALER uses fy.

f (px)

Scaler

320

+953

514.57

+214

800

−219

3

Bench Verification

Power up the FC and the companion. In Mission Planner, hit Ctrl+FMAVLink Inspector.

Under Vehicle 255 (the companion) you should see:

  • OPTICAL_FLOWflow_x / flow_y change when you wave a hand in front of the camera

  • DISTANCE_SENSORcurrent_distance roughly tracks relative_alt reported by the FC

Under Vehicle 1 (the FC):

  • RANGEFINDER reports a fresh distance

  • Mission Planner → Status tab → RNGFND1 and OF rows 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.

4

GPS Spoof Params

VTOL

No need to set GPS parameters for VTOL drone.

STOL / fixed-wing (TALON)

GPS2_TYPE        14      # MAVLink
GPS_PRIMARY      1
5

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:

  1. Vozilla → Settings → Lab → GPS Spoof

  2. Set Duration to 15

  3. Click Spoof Home Position

  4. Wait the full duration before arming

  5. Arm, take off.

To use GPS Spoof you must ensure you set the params appropriately. You need to GPS spoof to be able to use optical flow on STOL bird.

Last updated