Search...
Menu

Px4 Multirotor Parameter Tuning Tutorial Ⅱ

Data Analysis

Data analysis is definitely required for parameter tuning. You can use Flight Review for the analysis, mainly focusing on the tracking of angles and angular rates, as well as whether the motors are saturated. Except for the first graph, the following data are all attitude response curves of larger-sized aircraft. Therefore, the response is slower after a stimulus is given, not as good as the tracking effect of small-sized aircraft.

A good situation of angular rate tracking is shown in the figure below:

The situation of poor tracking with oscillations is as follows:

The situation of giving incentives when the attitude tracking is good is as follows:

The situation where the attitude tracking is poor is as follows:

 

Summary

This article describes how to debug the main parameters of the attitude controller. When adjusting the parameters, it should be noted that you should not adjust too much at once. The aircraft must be landed when debugging the parameters. With more debugging and more summarizing, you can basically master the debugging skills. Regarding the attitude parameter tuning, the relevant parameters of TPA and THR_MDL_FAC have not been elaborated yet and will be supplemented later.

 

Debugging Document 2

Link: http://www.coder100.com/index/index/content/id/979526

PX4 Native Firmware Attitude PID Parameter Adjustment:

Step 1: Preparation
First, set all parameters to their initial values.

  1. Set all MC_XXX_P to 0 (ROLL, PITCH, YAW).
  2. Except for MC_ROLLRATE_P and MC_PITCHRATE_P, set all MC_XXXRATE_P, MC_XXXRATE_I, and MC_XXXRATE_D to 0.
  3. Set MC_ROLLRATE_P and MC_PITCHRATE_P to very small values, such as 0.02.
  4. Set MC_YAW_FF to 0.5.

Note: All gains must be increased slowly, by 20% to 30% each time. When it is almost reaching the optimal value, the increase should be even in the range of 10%. Excessively large gains can easily lead to... 

 

Debugging Document 3

Link: https://www.cnblogs.com/kinson/p/12105955.html

 

Debugging Document 4

Wiki Chinese Link: https://www.bookstack.cn/read/TranslationPx4/3_Tutorial-multicopter-PID-tuning.md

This parameter tuning tutorial involves manually holding the drone for debugging, which is a relatively dangerous operation. Please use it with caution.

This tutorial is only applicable to advanced users/experts. If you don't understand what PID parameter tuning means, it is very likely to cause a crash.

Never perform multirotor parameter tuning with carbon fiber propellers or reinforced carbon fiber propellers.

Never use damaged propellers.

For safety reasons, the default gains are all set to relatively small values. Before you want to obtain a control response, you must first increase the corresponding gains.

This tutorial is valid for all multirotors (AR.Drone, PWM quadcopters/hexacopters/octocopters). The Proportional-Integral-Derivative (PID) controller is the most widely used control technique. There are some better control techniques (LQR/LQG) in model predictive control, but these control techniques require more or less an accurate system model, so they have not been widely used. The control goal of the PX4 series flight control boards is to switch between MPCs as quickly as possible. Since not all supported system models are available, PID parameter tuning is very important (and PID control is sufficient in many cases).

 

Introduction

The multirotor_att_control application in PX4 executes the outer loop of the outer-loop attitude controller, which depends on the following parameters:

  • Roll proportional control (MC_ROLL_P)
  • Pitch proportional control (MC_PITCH_P)
  • Yaw proportional control (MC_YAW_P)

Meanwhile, the inner loop controls the attitude angular velocity through three independent PID controllers:

  • Roll angular velocity control (MC_ROLLRATE_P, MC_ROLLRATE_I, MC_ROLLRATE_D)
  • Pitch angular velocity control (MC_PITCHRATE_P, MC_PITCHRATE_I, MC_PITCHRATE_D)
  • Yaw angular velocity control (MC_YAWRATE_P, MC_YAWRATE_I, MC_YAWRATE_D)

The output of the outer loop is the desired body angular velocity (for example, if a multirotor should be horizontal but currently has a 30-degree roll angle, the control output will generate an angular velocity of 60 degrees per second). The inner loop (i.e., the angular velocity control loop) changes the motor output to make the aircraft rotate at the desired angular velocity.

The gain actually has an intuitive meaning. For example, if the gain value of MC_ROLL_P is set to 6.0 and there is an offset of 0.5 radians (about 30 degrees) in the attitude angle, the aircraft will attempt to compensate at six times the angular velocity, that is, 3.0 radians per second (rad/s) or approximately 170 degrees per second (deg/s). For the inner loop, if the MC_ROLLRATE_P gain is set to 0.1, the output of the thrust on the roll angle will be 3 * 0.1 = 0.3. This means that the motors on one side of the aircraft will slow down by 30%, while the motors on the other side will speed up, so as to induce angular momentum to bring the aircraft back to a horizontal state.

The parameter MC_YAW_FF reflects the feedforward proportion of user input to the yaw speed controller. A value of 0 represents an extremely slow response speed. The controller will only start the yaw movement when a yaw position error occurs; a value of 1 represents a very sensitive control, but with some overshoot. The controller will immediately carry out the yaw movement and always keep the yaw error close to zero.

 

Motor Band / Limiting

As shown above, under certain conditions, one motor may receive an input higher than its maximum speed while another motor gets an input lower than zero. If this happens, the forces generated by the motors will violate the control model, and the multirotor is very likely to flip. To prevent this from occurring, the multirotor mixer on PX4 uses a band limit. If a motor exceeds the safe range, the total thrust of the system will be reduced so that the relative percentages of the controller output can be satisfied. As a result, the multirotor may not climb or may even lose a little altitude, but it will never flip. Similarly, for the lower side, even if the commanded roll angle is large, it will be scaled to a value that does not exceed the commanded total thrust, and the aircraft will not flip when taking off with near-zero thrust.

 

Step 1: Preparation

First, set all parameters to their initial values:

  1. Set all MC_XXX_P to 0 (ROLL, PITCH, YAW).
  2. Except for MC_ROLLRATE_P and MC_PITCHRATE_P, set all MC_XXXRATE_P, MC_XXXRATE_I, and MC_XXXRATE_D to 0.
  3. Set MC_ROLLRATE_P and MC_PITCHRATE_P to relatively small values, for example, 0.02.
  4. Set MC_YAW_FF to 0.5.

All gains should be increased slowly, by 20% - 30% each time. During the final fine-tuning, the increment should even be reduced to 10%. Note that gains that are too large (even just 1.5 - 2 times larger than the optimal gain value) may cause extremely dangerous oscillations!

 

Step 2: Stabilize the Roll and Pitch Angular Velocities

P Gain Adjustment

Parameters: MC_ROLLRATE_P,MC_PITCHRATE_P

If the aircraft is symmetrical, the values for ROLL and PITCH should be the same; if not, they should be adjusted separately.

Firmly hold the multirotor by hand and push the throttle to approximately 50% so that the weight of the aircraft is almost zero. Tilt the aircraft in the roll or pitch direction by hand and observe its response. The aircraft should gently resist the movement, but it will not attempt to return to the horizontal. If the aircraft oscillates, the RATE_P needs to be turned down. Once the control response becomes slower but correct, keep increasing the RATE_P until the aircraft starts to oscillate again. Then reduce the RATE_P until the aircraft has only slight oscillations or no oscillations at all (reduce by about 10%), leaving only overshoot. A typical value is approximately 0.1.

D Gain Adjustment

Parameters: MC_ROLLRATE_D, MC_PITCHRATE_D

Suppose the gains are in a state where the multirotor is oscillating and the RATE_P has been slightly decreased. Slowly increase RATE_D starting from 0.01 until the last bit of oscillation is eliminated. If the motors tremble, it means that RATE_D is too large and needs to be turned down. By adjusting the values of RATE_P and RATE_D, the response of the aircraft can be just right. Typical values are approximately between 0.01 and 0.02.
In the QGroundControl ground station, you can plot the roll and pitch angular velocity graphs (ATTITUDE.rollspeed/pitchspeed). It doesn't matter if there is some overshoot (10% - 20%) as long as the curves don't oscillate.

I Gain Adjustment

If the roll and pitch angular velocities never reach the set values and there is drift, start adding the gains of MC_ROLLRATE_I and MC_PITCHRATE_I, starting from 5% - 10% of the MC_ROLLRATE_P gain value.

 

Step 3: Stabilize the Roll and Pitch Angles

P Gain Adjustment

Parameters: MC_RATE_P, MC_RATE_P

Set MC_ROLL_P and MC_PITCH_P to relatively small values, for example, 3.

Firmly hold the multirotor by hand and push the throttle to approximately 50% so that the weight of the aircraft is almost zero. Tilt the aircraft in the roll or pitch direction by hand and observe its response. The aircraft should slowly return to the horizontal. If the aircraft oscillates, the P value should be decreased. Once the control response becomes slower but correct, keep increasing P until the aircraft starts to oscillate again. The optimal response has some overshoot (about 10% - 20%). After obtaining a stable response, fine-tune RATE_P and RATE_D again.
In the QGroundControl ground station, you can draw diagrams of the roll and pitch angles (ATTITUDE.roll/pitch) and control outputs (ctrl0, ctrl1). The overshoot of the attitude angles should not exceed 10 - 20%.
Previous
Px4 Multirotor Parameter Tuning Tutorial Ⅲ
Next
Installing PX4 Firmware
Last modified: 2025-01-02Powered by