• 2019-11-25 13:19
  • 2479

光流模块 px4flow

分类: 飞控硬件 > pixhawk



购买链接:购买原版光流模块:购买



PX4FLOW is an optical flow smart camera. It has a native resolution of 752x480 pixels and calculates optical flow on a 4x binned and cropped area at 400 Hz, giving it a very high light sensitivity.

PX4Flow v1.0

Unlike many mouse sensors, it also works indoors and in low outdoor light conditions without the need for an illumination LED. It can be freely reprogrammed to perform any other basic, efficient low-level computer vision tasks.

  • 168 MHz Cortex M4F CPU (128 + 64 KB RAM)

  • 752x480 MT9V034 image sensor, L3GD20 3D Gyro

  • 16 mm M12 lens (IR block filter)

  • Size 45.5 mm x 35mm

  • Power consumption 115mA / 5V

Specifications

  • MT9V034 machine vision CMOS sensor with global shutter

  • Optical flow processing at 4x4 binned image at 400 Hz

  • Superior light sensitivity with 24x24 μm super-pixels

  • Onboard 16bit gyroscope up to 2000°/s and 780 Hz update rate, default high precision-mode at 500°/s

  • Onboard sonar input and mount for Maxbotix sonar sensors. (HRLV-EZ4 recommended, SparkFun Product Link)

  • USB bootloader

  • USB serial up to 921600 baud (including live camera view with QGroundControl)

  • USB power option

  • Does fit the MatrixVision Bluefox MV mounting holes (camera center off-centered)

PX4Flow Top px4flow-bottom

Pixhawk Setup

In order to use the PX4Flow board, just connect it with I2C (on any Pixhawk series controller).

This does not work on FMUv5 (Pixhawk 4) for PX4 versions less than 1.9.0. All other PX4/Firmware versions should work.

  • Update the firmware on PX4Flow using QGroundControl (in the top left menu, click on CONFIG, then on Firmware Upgrade)

  • Connect PX4Flow I2C to the Pixhawk I2C

The module will be detected on boot. Flow data should be coming through at 10Hz if the autopilot is connected via USB. Flow data is transmitted via wireless at a lower rate.

Mounting/Orientation

The recommended mounting orientation (meaning: zero rotation) is defined as Y on flow board pointing towards front of vehicle, as shown in the following picture.

PX4Flow align with Pixhawk

On PX4, the orientation should be set using the parameter SENS_FLOW_ROT. The above orientation maps to SENS_FLOW_ROT=270 degrees (the default).

Make sure the the PX4Flow board is well dampened.

PX4Flow emits a significant amount of electromagnetic radiation, and should be placed as far away from other electronics (in particular GPS modules) as possible. (see Hardware/issues/8 for more information).

Connecting

The PX4flow is connected to the I2C bus. If you are connecting multiple devices to the same bus you will need to set each with a unique address. The next section explains how.

PX4FLOW I2C Device address

The default I2C address of the PX4Flow is 0x42, but it can be incremented using the three solder jumpers labeled "I2C BUS ADDR". This is useful if another device has the same address.

The address increment is equal to the 3-bit value encoded by the jumpers. For example if jumper 0 and 1 are soldered and jumper 2 is unsoldered, the address is incremented by 1*1 + 1*2 + 0*4 = 3, which gives address 0x45. If all jumpers are unsoldered, the camera will be automatically discovered by the autopilot firmware.

The address range for the 8 possible choices is: 0x42 - 0x49.

AddressBit 2Bit 1Bit 0
7 Bit Address 0x42 (default)000
7 Bit Address 0x43001
::::
7 Bit Address 0x49111

There are different I2C readouts available. Details about the I2C frame and the I2C integral frame are in the driver source code.

If you modify the I2C address of the PX4Flow, make sure to start the PX4 driver with the correct address:

px4flow start                  # address=0x42 (default) px4flow stop px4flow start -a 0x45          # address=0x45

Focusing the Lens

In order to ensure good optical flow quality, it is important to focus the camera on the PX4Flow to the desired height of flight. To focus the camera, put an object with text on (e. g. a book) and plug in the PX4Flow into USB and run QGroundControl. Under the settings menu, select the PX4Flow and you should see a camera image. Focus the lens by unscrewing the set screw and loosening and tightening the lens to find where it is in focus.

If you fly above 3m, the camera will be focused at infinity and won't need to be changed for higher flight.

Flow Focus Book

Figure: Use a text book to focus the flow camera at the height you want to fly, typically 1-3 meters. Above 3 meters the camera should be focused at infinity and work for all higher altitudes.

Flow Focusing

Figure: The QGroundControl px4flow interface that can be used for focusing the camera

Accuracy

The ortho photo below shows that a flight on the park roads is accurately measured. This was done with a PX4FMU on a 7" quad flying at about 1.6 m altitude in manual flight. No GPS, only PX4FLOW integration of position.

PX4FLOW trajectory

Downloads

Manual and Schematics

USB Driver

Linux and MacOS come with the required drivers. Windows drivers can be downloaded from: px4flow_win_drivers.zip

Papers

The flow module as been accepted as paper to the International Conference on Robotics and Automation (ICRA 2013) in Karlsruhe, Germany.

Libraries

The following are third party libraries that can be used to integrate the flow module in your projects.

  • mavros: A general MAVLink ROS interface, maintained by Vladimir Ermakov

  • px-ros-pkg]: A PX4FLOW ROS (Robot Operating System) interface, maintained by Lionel Heng (hengli@inf.ethz.ch).

  • arduino-px4flow-i2c: An Arduino library wrapping the I2C interface, maintained by Laurent Eschenauer (laurent@eschenauer.be).

Connectors

Optics

The correct optics are delivered by 3D Robotics already mounted and focused.

  • Lens mount

  • 16 mm M12 (S-mount) lens (with IR-cut filter)

The focal length influences the maximum measurable velocity.

maximum velocity = +/- 4 pixels / (1second/internalupdaterate)*grounddistance/focal length in pixels

The internal update rate is 400 Hz.

pixelsize is 24 micro meters, a 16mm lens has therefore a focal length of 0.016 meter / 24 micro meter per pixel = 666.666 pixels

Max velocities for different focal length lenses and ground distances:

Ground distance1m3m10m
16mm lens2.4m/s7.2m/s24m/s
8mm lens4.8m/s14.4m/s48m/s
6mm lens6.4m/s19.2m/s64m/s
4mm lens9.6m/s28.8m/s96m/s
max_vel = 4/(1/400)*grounddistance/(focallength/0.000024)

Configuration: Image Quality and Output

PX4FLOW is not designed as a camera, but does all processing on-chip. You can configure the image quality and output (the image output is only intended for focusing the lens).

Video Downlink

  • Download QGroundControl

  • Unplug your flow sensor

  • In QGroundControl, click on Configuration > Firmware Update. Hit the big green Scan button.

  • Connect the flow sensor. Click on upgrade once its detected (leave the default to “stable”)

  • Maximize the QGroundControl window. Click on Tool Widgets > Video Downlink

  • Enjoy the live view and focus the camera by loosening the locking screw and turning the lens at an object at 3m distance.

  • If you want to get higher res to focus the sensor, go to Config > Advanced Config and set the VIDEO_ONLY parameter to 1.

General Troubleshooting

  • Unplug the flow sensor if plugged

  • Start QGroundControl, select the PX4 startup mode go to Config > Firmware Upgrade.

    • Click on SCAN (green button in the center)

    • Connect the flow sensor now

    • Flash the stable firmware

  • Click on Advanced Config in the left menu to see the parameters

  • Display the video stream with QGroundControl (Tool Widgets > Video Downlink)

    • Check that there are no stripes on the stream. If you get stripes, set IMAGE_TEST_PAT to 1. It should look like the examples above. If you have stripes in the image but no stripes when this mode is enabled, right-click into the image once in both modes and save and send an image of each mode to the manufacturer's support team.

    • Check that you get a clear image (its a tele / zoom lens, so the visible area will be small)

  • Set the VIDEO_ONLY parameter to 1 to obtain a higher resolution image.

  • Check that the image is sharp at the operating distance (the typical flight altitude)

    Ask for help if you have a distorted image with visible dark lines (like the one below): Distorted video

PX4FLOW Developer Guide

Hardware Setup

  • PX4FLOW Board v1.3

  • HRLV-MaxSonar-EZ (MB1043)

  • 16mm Lens

  • Micro USB cable

PX4FLOW Testing

Software / Build Source

  • PC with QGroundControl installed

  • PX4FLOW Firmware (Firmware source code on Github: PX4/Flow)

PX4 driver code can be found here: PX4/Firmware/src/drivers/px4flow

Build

Install the PX4 toolchain (PX4 Developer Guide). Then and clone the sources from https://github.com/PX4/Flow using git.

cd flow make all make upload-usb

Then connect the flow sensor. It should show these steps on a successful upload:

Found board 6,0 bootloader rev 3 on /dev/ttyACM1 erase... program... verify... done, rebooting.

Troubleshooting

In case one doesn't see the aforementioned steps, the modem-manager should be removed by:

sudo apt-get remove modemmanager

User also needs to be in the plugdev group:

sudo usermod -a -G plugdev $USER

Focus Image

Connect PX4FLOW to QGroundcontrol:

  • Connect PX4FLOW sensor over USB to PC

  • Open QGroundcontrol

  • Switch to Plot perspective: Perspectives/Plot

  • Connect to PX4FLOW sensor: Communication/Add Link

PX4 Onboard Parameters

  • Link Type: Serial

  • Protocol: MAVLink

  • Serial Port: corresponding Port (e.g. /dev/ttyACM or COMM)

Now a new Unmanned System should appear and Onboard Parameters are loaded (click on "Get" if not)

Change Parameter VIDEO_ONLY to 1 and press Set.

The Widget Video Downlink shows now the Image in full resolution. Focus the lens on 1.5m. Fix the lens position and switch VIDEO_ONLY Mode off.

Data Output

The PX4FLOW module outputs MAVLink packets on USB and serial port. Use QGroundControl to read data from the module. An I2C interface for sensor data reading is offered as well. Third party libraries are available to connect and integrate PX4FLOW data in your projects.

  • USART3: MAVLink at 115200, 8N1 baud: OPTICAL_FLOW message, OPTICAL_FLOW_RADHEARTBEAT message

  • USB: Baud rate is not relevant (USB ignores it): OPTICAL_FLOW message, OPTICAL_FLOW_RADHEARTBEAT message, image.

  • I2C1: latest Flow value (i2c_frame) and accumulated Flow (i2c_integral_frame) values since last I2C readout available for readout.

PX4FLOW Parameters

The following list gives a short explanation of the current available parameters in the PX4FLOW firmware.

Parameters are currently not written to ROM (they reset at power loss). To change them permanently build your own version of firmware using instructions in the PX4FLOW Developer Guide above. Relevant parameters can be found here.

BFLOW_F_THRD

This parameter is a feature threshold and limits the quality of patterns that are used to calculate the bottom flow. For low values (e.g. 10) almost every pattern is taken, for higher values (e.g. 100) only significant patters are taken.

BFLOW_V_THRD

This is a pattern correlation threshold for filtering bad matches. Lower means only strong correlations are accepted.

Others

NameDefaultAccessComment
BFLOW_F_THLD30RWThis parameter is a feature threshold and limits the quality of patterns that are used to calculate the bottom flow. For low values (e.g. 10) almost every pattern is taken, for higher values (e.g. 100) only significant patters are taken.
BFLOW_V_THLD5000RWThis is a pattern correlation threshold for filtering bad matches. Lower means only strong correlations are accepted.
BFLOW_HIST_FIL0RW1: Flow histogram filter is ON, 0: OFF
BFLOW_GYRO_COM0RW1: Gyro compensation is ON, 0: OFF
BFLOW_LP_FIL0RW1: Lowpass filter on flow output is ON, 0: OFF
BFLOW_W_NEW0.3RWFlow lowpass filter gain
DEBUG1RW1: Debug messages ON, 0: OFF
GYRO_SENS_DPS250RWGyroscope sensitivity: 250, 500, 2000 (dps)
GYRO_COMP_THR0.01RWGyro compensation threshold (dps): Gyro data lower than this threshold is not compensated to prevent drift
IMAGE_WIDTH64RImage width (pixels)
IMAGE_HEIGHT64RImage height (pixels)
IMAGE_L_LIGHT0RW1: Image sensor low light mode ON, 0: OFF
IMAGE_NOISE_C1RW1: Image sensor noise correction ON, 0: OFF
IMAGE_TEST_PAT0RW1: Gray-shaded test pattern mode ON, 0: OFF
LENS_FOCAL_LEN16RWFocal length of lens (mm)
POSITION0RW0: Only position 0 is used (Bottom: 0, Front: 1, Top: 2, Back: 3, Right: 4, Left: 5)
SONAR_FILTERED0RW1: Kalman filter on sonar output is ON, 0: OFF
SONAR_KAL_L10.8461RWSonar Kalman gain L1
SONAR_KAL_L26.2034RWSonar Kalman gain L2
SYS_ID81RWMAVLink System ID
SYS_COMP_ID50RWMAVLink Component ID
SYS_SENSOR_ID77RWMAVLink Sensor ID
SYS_TYPE0RWMAVLink System Type
SYS_AP_TYPE1RWMAVLink Autopilot Type
SYS_SW_VER13XXRSoftware Version
SYS_SEND_STATE1RW1: Send MAVLink Heartbeat, 0: Not
USART_2_BAUD115200RBaudrate USART 2
USART_3_BAUD115200RBaudrate USART 3 (Data Output)
USB_SEND_VIDEO1RW1: Send video over USB, 0: Not
USB_SEND_FLOW1RW1: Send flow over USB, 0: Not
USB_SEND_GYRO1RW1: Send gyro data over USB, 0: Not
USB_SEND_FWD0RW1: Send forwarded flow over USB, 0: Not
USB_SEND_DEBUG1RW1: Send debug msgs over USB, 0: Not
VIDEO_RATE150RWTime in milliseconds between images of video transmission
VIDEO_ONLY0RW1: High resolution video mode is ON, 0: OFF

Modes

VIDEO ONLY Mode

Set VIDEO_ONLY to 1 for high resolution mode. In this mode the camera image is transmitted at a higher resolution to ease the lens focus process. No flow values are calculated in this mode.

Low Light Mode

If IMAGE_L_LIGHT is set to 1, the sensor operates in low light mode.

This mode is under construction, and results are more noisy

Test Pattern Mode

If the parameter IMAGE_TEST_PAT is set to 1, the sensor inserts a vertical gray-shaded test pattern in the signal chain.

  • Test Pattern 64x64 (VIDEO ONLY Mode is OFF) test_pattern_64x64

  • Test Pattern 376x240 (VIDEO ONLY Mode is ON) test_pattern_376x240


作者

loucao

他发布了教程 159