Advanced Settings for Multi-rotor Aircraft-Ⅱ
Obstacle Avoidance
Copter 3.5 (and later versions) supports horizontal omnidirectional obstacle avoidance using the following:
360-degree LiDAR sensors, including the Lightware SF40C, TeraRanger Tower, or RPLidar A2/A3.
Any other two supported LiDAR sensors (you can use up to 4 LiDAR sensors in total if you recompile the code after changing the relevant definition to “4”).
Sensors capable of providing MAVLink distance sensor messages (such as OpenKai with a 3D camera).
Horizontal obstacle avoidance is not active in AltHold or Loiter modes. Upward obstacle avoidance is functional in all modes except Stabilize and Acro.
For detailed information on how obstacle avoidance is implemented, please refer to the developer wiki.
Setting Up LiDAR
For 360° LiDAR, please follow the instructions specific to the LiDAR unit installed on your drone (e.g., LightWare SF40C, TeraRanger Tower, or RPLidar A2/A3).
Configuring Obstacle Avoidance
Set AVOID_ENABLE = 7 (“All”) to enable all obstacle avoidance sensors, including “proximity” (distance) sensors. In Loiter mode, AVOID_MARGIN controls the distance from an obstacle at which the drone attempts to stop. AVOID_BEHAVE determines whether the drone should simply stop in front of an obstacle or slide around it. In AltHold mode, AVOID_DIST_MAX controls the distance at which the drone begins to tilt away from an obstacle, while AVOID_ANGLE_MAX controls the maximum tilt angle of the drone relative to the obstacle.
Real-time Distance
Real-time distance can be viewed in the “Static Distance Viewer” within Mission Planner.
You can open this window by navigating to the Flight Data screen in MP, pressing Ctrl-F, and clicking the Proximity button.
DataFlash Logging: Upward and downward rangefinder distances can be viewed in the RFND messages within the DataFlash log.
Distances to the nearest objects in eight sectors surrounding the drone are recorded in the PRX messages within the DataFlash log.
Limitations
The helicopter’s obstacle avoidance feature has the following limitations. Future versions may address these issues.
Obstacle avoidance is only functional in Loiter and AltHold modes. The drone is designed to stop before colliding with an object, but it will not back away from objects in its immediate vicinity (a slow-retreat behavior may be added in future firmware versions). Because the avoidance system is “sensor-based”—meaning it does not construct a 3D map—it has no “memory” of obstacles once they move out of the LiDAR’s field of view.
Reset Parameters
Sensor Testing
This section explains how to check whether key sensors—including those for location and GPS—are functioning correctly.
Check the Primary Sensors
Once connected to Mission Planner, move the flight controller board; you will see the artificial horizon move accordingly.
Displaying Data Curves on the Ground Station
You can view the output from various sensors by checking the “Debug” box located in the bottom-right corner of the display screen.
If you click on the area labeled ** 2 ** (Tuning)—as shown below—a “Graph” window will appear, allowing you to select which sensors and data outputs you wish to display.
Click on the “tuning” area in Figure 1 to open the selection menu for “Graph this” chart types.
RC Input Channel Mapping (RCMAP)
This section explains how to use the RCMAP feature to configure non-standard RC input channel mappings.
Note: This guide applies to firmware version AC3.2 and later.
Configuration
By default, the RC input channels are assigned as follows:
Channel 1: Roll input
Channel 2: Pitch input
Channel 3: Throttle input
Channel 4: Yaw input
These assignments can be modified by adjusting the `RCMAP_ROLL`, `RCMAP_PITCH`, `RCMAP_THROTTLE`, and `RCMAP_YAW` parameters.
Procedure:
Open the Mission Planner (MP) ground control station and navigate to the “Config/Tuning” tab, then select “Full Parameter Tree” (or “Full Parameter List”), as shown below.
After changing any of these parameters, the flight controller should be restarted.
Following the restart, RC calibration and ESC calibration should be performed again.
RC Output Mapping
This section explains how to change the default assignments for RC output channels used for motors (and other functions). These instructions focus primarily on multi-motor firmware, as individual function setup pages—such as the one for a servo-operated gripper—typically document how to assign output channels using the `RCx_FUNCTION` or `SERVOx_FUNCTION` parameters.
The ability to remap multiple motors was introduced in Copter-3.4 (and later versions). In Copter-3.5 and subsequent versions, the parameters used to control output channels were renamed from `RCx_FUNCTION` to `SERVOx_FUNCTION`.
Configuration
Depending on your firmware version, `RCx_FUNCTION` or `SERVOx_FUNCTION` can be set to any of over 85 different values to define the function of a given output channel (note: most ground control stations will display the full list of available options). Here, “x” represents the channel number; for instance, `RC1_FUNCTION` (or `SERVO1_FUNCTION`) corresponds to the “MAIN OUT 1” pin on the back of a Pixhawk, while `RC9_FUNCTION` (or `SERVO9_FUNCTION`) corresponds to the “AUX OUT 1” pin.
To assign motors for a multi-rotor aircraft, you can use the following function values:
- 33: Motor #1
- 34: Motor #2
- 35: Motor #3
- 36: Motor #4
- 37: Motor #5
- 38: Motor #6
- 39: Motor #7
- 40: Motor #8
- 82: Motor #9
- 83: Motor #10
- 84: Motor #11
- 85: Motor #12
For example, if you wish to reorder the motors of an “X” frame quadcopter—changing the default diagonal configuration to a more logical clockwise sequence (note that this is not recommended, as it will affect the motor test sequence)—you should make the following changes:
SERVO1_FUNCTION remains 33 (i.e., “Motor 1,” front-right)
SERVO2_FUNCTION changes from 34 (i.e., “Motor 2,” rear-left) to 36 (Motor #4, rear-right)
SERVO3_FUNCTION changes from 35 (i.e., “Motor 3,” front-right) to 34 (Motor #2, rear-left)
SERVO4_FUNCTION changes from 36 (i.e., “Motor 4,” rear-right) to 35 (Motor #3, front-left)
Sensor Position Offset Compensation
Heli 3.5 (and later versions) includes support for compensating for the physical placement of sensors on the aircraft. This page explains which parameters can be configured and how to set them up.
For sensors located within 15 cm of each other—including IMUs and optical flow sensors—applying such compensation is unlikely to yield any significant improvement in performance on most aircraft.
The sensor position offset is specified as a set of three values (X, Y, and Z) representing the distance (in meters) from the IMU—which can be assumed to be at the center of the flight controller board—or from the vehicle’s center of gravity (CG).
X: The longitudinal (front-to-back) distance between the IMU and the center of gravity. A positive value indicates that the flight controller is positioned toward the front, while a negative value indicates it is toward the rear.
Y: The lateral (left-to-right) distance between the IMU and the center of gravity. A positive value indicates that the center of gravity is to the right of the flight controller, while a negative value indicates it is to the left.
Z: The vertical distance between the IMU and the center of gravity. A positive value indicates a lower position, while a negative value indicates a higher position.
In practice, the distance of a sensor can be measured relative to the center of the flight controller. However, if the flight controller is placed at a significant distance from the vehicle’s center of gravity, you can specify the IMU position offset, and then define the position offset for other sensors relative to the vehicle’s center of gravity.
Parameter Details
IMU (also known as INS):
For optimal results, the flight controller (and thus the IMU) should be positioned at the vehicle’s center of gravity. If this is physically impossible, the offset can be partially compensated for by configuring the following parameters:
INS_POS1_X, INS_POS1_Y, INS_POS1_Z: The position of the first IMU relative to the vehicle’s center of gravity.
INS_POS2_X, INS_POS2_Y, INS_POS2_Z: The position of the second IMU relative to the vehicle’s center of gravity.
INS_POS3_X, INS_POS3_Y, INS_POS3_Z: The position of the third IMU relative to the vehicle’s center of gravity.
This compensation is only partial; while ArduPilot can account for offsets based on the vehicle’s estimated velocity and position, it cannot correct the acceleration estimates themselves. For example, if the flight controller is mounted toward the front of the vehicle and the vehicle suddenly tilts backward (rotating so that its nose points upward), the velocity estimate—without offset compensation—might momentarily indicate that the vehicle is climbing, even though it is not. With the position offset configured, this false “climb” indication is eliminated. However, the EKF (Extended Kalman Filter) will still register a transient vertical acceleration; since this acceleration data is used by the altitude-hold controller, it may still cause the vehicle to experience a momentary change in vertical speed.
Although individual position offsets can be defined for each IMU, the physical distance between IMUs on most flight controller boards is so small that the same values can typically be used for all of them.
Global Positioning System (GPS):
GPS_POS1_X, GPS_POS1_Y, GPS_POS1_Z: Distance from the position of GPS1 to the aircraft’s center of gravity
GPS_POS2_X, GPS_POS2_Y, GPS_POS2_Z: Distance from the position of GPS2 to the aircraft’s center of gravity
Range Finder (Sonar or LiDAR):
RNGFND_POS_X, RNGFND_POS_Y, RNGFND_POS_Z: Distance from the first range finder to the vehicle’s center of gravity
RNGFND2_POS_X, RNGFND2_POS_Y, RNGFND2_POS_Z: Distance from the second range finder to the vehicle’s center of gravity
Optical Flow:
FLOW_POS_X, FLOW_POS_Y, and FLOW_POS_Z represent the distances from the optical flow sensor to the vehicle’s center of gravity.
Telemetry/Serial Port Configuration
This section explains how to configure telemetry ports (also known as serial ports) on a flight controller. While the instructions use Pixhawk as an example, they apply to most flight controllers.
Overview
There are 5 serial ports on the Pixhawk. Their default uses are as follows:
- The Micro-USB port (also known as Serial0) is used to connect to a ground station via a USB cable. It should not be connected during flight, as certain safety features (such as battery failsafes) may be disabled if the flight controller is powered via USB.
- Telem1 (also known as Serial1) is used for MAVLink communication and supports flow control. It is particularly well-suited for high-power devices (up to 1 Amp), such as RFD900 telemetry radios.
- Telem2 (also known as Serial2) is used for MAVLink communication and supports flow control.
- GPS (also known as Serial3) is used for connecting a GPS module.
- Serial 4/5 consists of two serial connections on a single port. Serial4 is typically used for a second GPS, while Serial5 serves as a debug connection.
Configuring Telemetry Serial Ports via the Ground Station
You can configure the following telemetry port parameters through the ground station. If you are using the Mission Planner (MP) ground station, navigate to the Config/Tuning | Full Parameter List page.
- The `SERIALx_PROTOCOL` parameter (where “x” is a number from 0 to 4) controls the protocol or the intended purpose of the serial port. Refer to the relevant wiki pages—such as the one for LightWare LiDAR—for guidance on selecting the appropriate protocol.
- The `SERIALx_BAUD` parameter sets the baud rate (speed) of the serial port.
- The `BRD_SER1_RTSCTS` and `BRD_SER2_RTSCTS` parameters allow you to enable or disable flow control for the Telem1 and Telem2 ports.
MAVLink1, MAVLink2, and Data Rates
For telemetry ports used for MAVLink communication, you can choose between MAVLink1 and MAVLink2 by setting the `SERIALx_PROTOCOL` parameter to “1” or “2,” respectively.
MAVLink2 supports packet signing (for enhanced security) and variable-length messages; therefore, it should be used whenever possible. However, since some older telemetry radios do not support MAVLink2, the default is set to MAVLink1.
As described on the Telemetry Logs page, the `SRx_*` parameters can be used to control the data rates at which information is transmitted from the vehicle.
In the Mission Planner ground control station, these parameters can be conveniently configured via the “Telemetry Rates” drop-down menu found on the “Planner” screen (under the “Config/Tuning” tab).
Due to CPU bandwidth limitations, the actual data transmission rate may be lower than required.
u-blox GPS Configuration
This section explains how to connect to u-center to modify the configuration of a CUAV u-blox GPS module.
Note: Do not perform this procedure unless it is necessary to change parameters.
Connection Method 1 - Connecting via Mission Planner and Pixhawk
You can establish communication between the U-Center and the GPS module by following these steps:
- Connect your Pixhawk/Pixhack to your PC and establish a connection via Mission Planner.
- On the “Flight Data” screen, press Ctrl-F and select “MAVSerial pass.”
- Open u-center, go to “Receiver” > “TCP Client,” set the “Address” to “localhost” and the “Port” to “500” in the “Network Connection” window, then click “OK.”
- Please refer to the instructions on how to upload a configuration file using u-center.
Connection Method 2: Use a TTL adapter board to connect the GPS to a computer.
Construct a connecting cable between a TTL adapter board and the GPS module (you only need to connect four wires: 5V, GND, RX, and TX; ensure that the RX and TX pins are cross-connected, while the power pins should be connected as specified).
Configure the baud rate and COM port to establish a connection (the default baud rate is 9600).
UAVCAN Configuration
This section guides setting up the UAVCAN protocol in ArduPilot.
The UAVCAN protocol should be enabled first. Please refer to the CAN bus settings.
Overview
UAVCAN is a lightweight protocol that enables reliable communication over a CAN bus for aerospace and robotic applications. A UAVCAN network is a decentralized, peer-to-peer network in which each peer (node) has a unique numerical identifier—a “node ID”—and requires configuring only one parameter for basic setup.
For a detailed description of the protocol, please visit https://uavcan.org/.
The ArduPilot UAVCAN driver does not support the automatic node-numbering feature found in the current version of the protocol. All nodes must have their IDs explicitly configured.
Settings
There are currently three parameters under the CAN category:
- CAN_DX_UC_NODE – Node ID for the autopilot
- CAN_D1_UC_ESC_BM – Bitmask for enabling the transmission of ESC commands
- CAN_D1_UC_SRV_BM – Bitmask for enabling the transmission of servo commands
In a bitmask, each bit position corresponds to a specific ESC or servo ID for which commands will be generated. For helicopters, the ESC bitmask is typically populated, while for fixed-wing aircraft, the servo bitmask is primarily used—though any combination is possible. To reduce bandwidth, the `CAN_D1_UC_ESC_BM` and `CAN_D1_UC_SRV_BM` parameters should be configured to enable only those motor and servo channels that require CAN signal transmission. Example: For a configuration with CAN servos on channels 1, 2, and 4, and an ESC motor on channel 3, set: `CAN_D1_UC_SRV_BM = 0x0B` and `CAN_D1_UC_ESC_BM = 0x04`. GNSS Receiver Configuration: If a GNSS receiver is connected to the UAVCAN network, it must be enabled within the GPS subgroup parameters. For the corresponding GNSS receiver in the autopilot, the `TYPE` parameter should be set to 9.
GNSS Receiver Configuration Settings
If a GNSS unit is connected to the UAVCAN network, it must be enabled within the GPS subgroup parameters. For the corresponding GNSS receiver in the autopilot, the TYPE parameter should be set to 9.
Dual-Antenna Direction Finding
Due to complex and highly variable magnetic field environments, issues such as inconsistent compass readings are quite common. Dual-antenna direction finding can serve as an alternative to a magnetic compass for drone navigation, meeting operational requirements in specialized environments such as power line and pipeline inspections.
Operating principle of dual-antenna direction finding: The antennas of the base station and the rover form a baseline vector. Through differential calculation, the angle between this baseline and true north (measured counter-clockwise) is determined, thereby providing the current heading.
Verified hardware includes:
- CUAV C-RTK 9P
This feature is available in Copter 4.0.4 (and later versions), Plane 4.0.6 (and later versions), and Rover 4.1.0 (and later versions); the C-RTK 9p firmware version must be 1.13 or higher.
Hardware Setup
The two C-RTK 9P antennas should be installed at a horizontal distance of more than 30 cm from each other.
The second GPS unit should be connected to the Serial4/UART4 port on the flight controller; while it can be connected to any other serial port, doing so will require additional configuration of that port’s functions.
Both GPS modules must be connected to the flight controller via their respective UART1 connectors.
Setup
- Assuming the second GPS is connected to Serial Port 4, set SERIAL4_PROTOCOL = 5 (“GPS”)
- GPS_TYPE = 17 (“Moving Baseline”)
- GPS_TYPE2 = 18 (“Moving Baseline Rover”)
Configure the GPS_POS1_X/Y/Z and GPS_POS2_X/Y/Z parameters for the GPS units - AHRS_EKF_TYPE = 3 (use EKF3)
- EK2_ENABLE = 0 (disable EKF2)
- EK3_ENABLE = 1 (enable EKF3)
- EK3_MAG_CAL = 5 (“Use External Yaw Sensor”) or 6 (“External Yaw Sensor with Compass Backup”)
GPS_AUTO_SWITCH = 1
Other configurations:
To determine whether GPS-based heading (direction finding) is functioning, you can disable the compass by setting the following parameter during debugging (it is recommended to keep the compass enabled during actual operation).
- COMPASS_USE=0
- COMPASS_USE=0
- COMPASS_USE=0
The configuration above assumes that you want the RTCMv3 data to be transmitted between the two GPS modules via the flight controller board. Alternatively, you can install a UART crossover cable between the UART2 connectors on the two GPS modules. If you do this, you can set `GPS_DRV_OPTIONS=1`, which instructs the u-blox GPS driver to configure both GPS modules to transmit RTCMv3 data via their UART2 ports.
Testing
Find an open area with good GPS signal reception. Place the vehicle on the ground and wait for it to acquire a GPS lock. Then, use the Ground Control Station (GCS) to verify that the vehicle’s heading matches the actual magnetic heading (you can use a compass app on your smartphone for this). Rotate the vehicle and ensure that the heading displayed on the GCS updates to remain aligned with the actual magnetic heading.
If the heading is reversed, the `GPS_POS_xxx` parameters may be configured incorrectly.
Please note that it may take some time for the GPS modules to achieve a sufficiently accurate position fix for the yaw (heading) estimation to function correctly. The ArduPilot GPS driver employs several methods to verify whether the position fix is of sufficient quality.
- The rover GPS (GPS2) module status is “RTK FIX.”
- The error between the configured horizontal position offset for the two GPS antennas and their actual distance is no greater than 20%.
- The error between the configured vertical position offset for the two GPS antennas and their actual distance is no greater than 20%.
Firmware Version
The 4.0 ArduPilot firmware version does not support the `EK3_MAG_CAL = 6` option; this option is available starting from version 4.1.x. Using `EK3_MAG_CAL = 6` allows the EKF to learn a set of compass offsets during flight, which enables a fallback to the compass in the event of a GPS-based yaw failure.
The content above covers advanced settings for a multirotor aircraft’s maiden flight. Stay tuned for the next article:
《Overview and Analysis of Multirotor Flight Logs》