Indoor Positioning with Optical Flow

Note: This tutorial is applicable for Kerloud UAV with optical flow configuration.

The Kerloud UAV with optical flow configuration provides a convenient option for users to realize indoor positioning with minimum setup. The platform is equipped with a PX4FLOW optical sensor and a TF-Luna lidar distance sensor . The PX4FLOW sensor is a smart camera-based sensor in the PX4 community that can provide demonstrated performance in horizontal velocity estimation. The lidar distance sensor can offer accurate height measurement with centimeter accuracy. The configuration can achieve 0.1m and 0.05m accuracy for horizontal and vertical positioning respectively in indoor environment with textured ground. Moreover, it also supports GPS-less flight in outdoor environment.

How to Setup

Environment Requirements

The indoor ground is required to be with rich textures for the optical flow sensor, hence we recommend users to cover the ground with chess board paper or other patterns. The chess board images can be downloaded from the link. Besides, the light condition should be sufficient enough for PX4FLOW cameras.

Firmware Setup

The onboard autopilot for Kerloud UAV with optical flow is configured properlly in factory. The parameters can be configured below for indoor case in the QGroundcontrol interface:

SENS_EN_TF   2
SENS_EN_PX4FLOW: 1
EKF2_HGT_MODE: 2
EKF2_AID_MASK: 2
EKF2_MAG_TYPE: 0
EKF2_OF_POS_Y: -0.07

These parameters are clarified as:

  • SENS_EN_TF: enable the distance sensor driver for Benewake TF sensors.

  • SENS_EN_PX4FLOW: enable the PX4FLOW driver.

  • EKF2_HGT_MODE: set the lidar distance sensor as the primary height source.

  • EKF2_AID_MASK: enable the setting for optical flow in EKF estimator.

  • EKF2_MAG_TYPE: set the automatic mode for magnetometer heading measurement.

  • EKF2_OF_POS_Y: set the relative position the in body Y axis for the optical flow sensor.

PX4FLOW Focus Setup

The camera lens for the PX4FLOW sensor is tuned well in factory. The official tuning guide can be referred in https://docs.px4.io/master/en/sensor/px4flow.html.

For brevity, users can connect the PX4FLOW sensor with a PC running QGC by the provided micro-usb cable, and then select px4flow under the setting menu in QGC. The image from the PX4FLOW camera can be viewed shortly from the QGC interface. Users can simply a place a textbook on ground and lift the camera to a height you want to fly (typically 1~3 meters). Focus the lens by unscrewing the set screw and loosening and tightening the lens to find where it is in focus. The tuning can be deemed acceptable when the edges of the textbook can be clearly seen in image, as depicted below:

../_images/flow_focusing.png

Sensor Data Validation

Both optical flow and lidar distance sensor data can be viewed via commands in QGC console window:

../_images/oftutorial_opticalflow.png ../_images/oftutorial_tfmini_status.png

Demo Video

The video demonstrates a semi-autonomous indoor flight following the quick start guide procedures.

References