Pixhawk学习笔记(3)——PX4FLOW

http://copter.ardupilot.com/wiki/common-px4flow-overview/


PX4FLOW Optical Flow Camera Board Overview

This article describes the PX4FLOW (Optical Flow) Sensor.

Warning

The PX4FLOW is supported as an experimental feature starting from Copter 3.3. It is not supported in Plane or Rover.

Overview

The PX4FLOW (Optical Flow) Sensor is a specialized high resolution downward pointing camera module that uses the ground texture and visible features and a rangefinder to determine aircraft ground velocity. Although the sensor has plus a built-in Maxbotix LZ-EZ4 sonar to measure height, this has not been reliable enough over a range of surfaces in testing, so its readings are not used and instead a separate Range Finder such as the Lidar Lite should also be attached to the vehicle.

The built-in 3 axis gyro enables automatic compensation for vehicle tilt and heading relative to the ground. The PX4-FLOW incorporates the same powerful Cortex M4F Microcontroller as is used in the PX4-FMU.

More information on this sensor including how to upgrade the sensor’s firmware using QGroundControl can be found on the ETH’s PX4FLOW wiki page.

Warning

To use this flow sensor to perform optical flow loiter as seen in the following video, you will need to purchase a separate range finder. Our testing has been performed using thePulsed Light unit

Upgrade the PX4Flow sensor’s firmware

The PX4Flow firmware must be updated prior to connecting to the Pixhawk:

  1. Download and unzip the PX4Flow-KLT firmware (source code here)

  2. Download, install and start QGround Control

  3. Select PX4 Autopilot from the splash screen

  4. Press the Config button to open the Firmware Upgrade screen

    QGroundControl: Firmware Upgrade Screen

  5. Click Advanced, then set Port to “”, Board to “PX4FLOW v1.1”

  6. Push the Select File button and find the .px4 file downloaded from step #1

  7. Push the “Flash” firmware and then push the small reset button on the edge of the px4flow sensor near the sonar.

Connect to the Pixhawk

Pixhawk学习笔记(3)——PX4FLOW_第1张图片

The sensor should be connected to the Pixhawk’s the 4-pin I2C port. In most cases an I2C splitter should be used to allow other I2C devices (like the external RGB LED and GPS/Compass module’s compass) to the same port.

Mounting to the Frame

Mount the flow sensor pointing straight down with the X axis forwards and the Y axis to the right. The FLOW_ORIENT_YAW parameter can be used to account for other yaw orientations. It is important that the flow sensor be mounted where it does not experience angular angular vibration that could blur the image.

Note

The default mounting orientation is different to that shown on the ETH PX4FLOW wiki. If you mount the board as shown in the ETH PX4FLOW wiki, you will need to setFLOW_ORIENT_YAW to -9000.

Setup through the Mission Planner

../_images/OptFlow_MPSetup.png

The sensor can be enabled by connecting with the Mission Planner and then on the Initial Setup | Optional Hardware | Optical Flow page check the Enable checkbox. Alternatively theFLOW_ENABLE parameter should be set to “1” through the full parameters list. The sensor will be initialised once the Pixhawk board is rebooted.

Testing the sensor

The raw data from the sensor will eventually be visible on the Mission Planner’s Flight Data screen’s Status tab (issue raised here). Until then you can perform the following test in a well lit room. Note that some artificial lighting has strobing that can reduce the sensor performance. Natural light or a high power incandescent light source is best.

Warning

Follow the instructions on the ETH PX4FLOW wiki page on how to use QGroundControl to check and adjust the focus of your sensor. Do not assume it was in focus as shipped. You should be pointing it at a high contrast object about 3m away when you check the focus.

Warning

Disconnect the sensor I2C connection from your flight computer before you connect it to via USB to your computer, Otherwise the sensor will be trying to power the flight computer and it may not have enough voltage to work properly.

  1. Remove the lens cap from the sensor
  2. We recommend you upgrade to this modified PX4FLOW sensor firmware. using QGroundControl. This modified firmware uses a different method to determine the optical flow and provides readings over a wider range of light and distance, but has a smaller maximum flow speed compared to the standard firmware.
  3. Reconnect the I2C connection your flight computer and change the following parameters:FLOW_ENABLE = 1 turns on use of the sensor and LOG_BITMASK = 131071 turns on pre-arm logging and will help diagnose problems
  4. Power up the vehicle (you can power up via the flight computer USB) to start logging and rotate the vehicle with the sensor pointing at the floor.
  5. Download the dataflash logs and graph the OF message’s data including “Qual”, flowX, flowY, bodyX and bodyY values. The quality reading should be greater than 0, and you should see the flow and body rates changing.
  6. Power up the vehicle using the battery and repeat steps 4. and 5. If you get no data, but works when the Pixhawk is powered via USB, then it is likely you have encountered a start-up problem with the PX4-Flow sensor and the APM+Pixhawk combination that is known to affect some sensors. Currently there is no solution to this other than to always power up via USB first before connecting the battery. Please notify the APM developers and PX4Flow supplier if this occurs.

Flow Sensor Calibration

  1. Find a location with a textured surface and good lighting (natural light or strong incandescent)

  2. Remove Propellers (safety first)

  3. Power on the vehicle and hold level away from your body and at eye level

  4. Rotate about the vehicle in roll through a range from -15 to +15 degrees in about a second and then back again. Repeat this 10 times. By closing one eye you will be able to keep the centre of the sensor stationary against the background while you do the rotation.

  5. Repeat about the vehicle pitch axis.

  6. Download the data flash logs and plot the OF.flowXOF.bodyX and IMU.GyrX data. It should look something like this:

    ../_images/OF-roll-calibration.png
  7. If OF.flowX is larger or smaller than OF.bodyX, then it can be adjusted by changing theFLOW_FXSCALER parameter

  8. IF OF.bodyX is uncorrelated or opposite sign to IMU.GyrX, the FLOW_ORIENT_YAW parameter is probably set incorrectly or you do not have the flow sensor pointing downwards

  9. Plot the OF.flowYOF.bodyYbandIMU.GyrY data. It should look something like this:

    Pixhawk学习笔记(3)——PX4FLOW_第2张图片
  10. If OF.flowY is larger or smaller than OF.bodyY, then it can be adjusted by changing theFLOW_FYSCALER parameter

  11. IF OF.bodyY is uncorrelated or opposite sign to IMU.GyrY, the FLOW_ORIENT_YAW parameter is probably set incorrectly or you do not have the flow sensor pointing downwards

Range Sensor Check

Check the EKF5.meaRng message in the flashlog from your flow sensor calibration test. Check the following:

  1. There is continuous range measurement.
  2. It outputs a range on the ground that is 10cm of the expected value (remember that measured range will increase when you roll or pitch the vehicle because the laser is then measuring on a slant)

Pre-Arm checks

To allow arming and taking off in Loiter without a GPS the GPS arming check should be turned off as shown below. Unchecking “All” and “GPS” and leave all other options checked.

Pixhawk学习笔记(3)——PX4FLOW_第3张图片

Because optical flow requires good sonar/range finder data when the optical flow is enabled, an additional pre-arm check is enforced.

While the vehicle is disarmed you should lift the vehicle straight up to at least 50cm but no higher than 2m (if the rangefinder sees a distance of over 2m you will need to restart the flight controller).

The error message when arming fails this check is “PreArm: check range finder”

This check can be disabled by unchecking the “Parameter/Sonar” arming check.

First Flight (Copter Only)

  1. Perform a short test flight hovering in stabilise at small tilt angles at heights ranging from 50cm to 3m with EKF_GPS_TYPE = 0 (we don’t want the optical flow being used by the EKF at this stage)
  2. Download the flash log and plot the following in mission planner
  3. EKF5.meaRng should correlate with the change in vehicle height
  4. OF.flowX and OF.flowY should be varying
  5. OF.bodyX and OF.bodyY should be consistent with IMU.GyrX and IMU.GyrY

Second Flight (Copter only)

Warning

You will need at least 15m of clear space around the vehicle to do this flight safely.

  1. Set the EKF_GPS_TYPE parameter to 3 make the EKF ignore GPS and use

    Warning

    Do not switch from any non-gps mode, eg

    STABILIZE, ALT_HOLD or ACRO to a GPS mode, eg LOITER when flying with EKF_GPS_TYPE set to 3. If the optical flow velocity estimates are bad, you will have no warning and the copter could go to maximum roll or pitch when you make the switch. This vulnerability will be fixed in subsequent SW releases.

  2. Ensure you have LOITER mode and STABILIZE mode available on you transmitter.

  3. Take-off in loiter and bring the copter to about 1m height

    Warning

    Do not take-off in STABILIZE and switch

    to LOITER

  4. If it starts to accelerate away or there is erratic pitch or roll movement, then switch to stabilise and land. You will need to download the log file and share it on the forum to understand why.

  5. If it holds location then congratulations, you have succeeded and can now start experimenting with height changes and moving it around in LOITER

你可能感兴趣的:(无人机,视觉算法)