Purpose:
Mainly search for various debugging methods on the Internet or in forums, and then spend time continuously verifying them in practice to find safer, more reasonable, and more convenient debugging methods.
Px4 Firmware Debugging Document 1
Link:http://www.360doc.com/content/22/0206/22/70238708_1016223765.shtml
Preface
A large part of the debugging work for unmanned aerial vehicles (UAVs) lies in the adjustment of flight control parameters. In a broad sense, flight control parameters cover adjustable parameters in guidance, navigation, control laws, and various control strategies. Generally, a flight controller has hundreds of parameters that require manual adjustment, and some even have hundreds or thousands of them. As the foundation of UAV control, attitude control is often the first to be dealt with during UAV flight tests and debugging, thus becoming our primary debugging target. Of course, the navigation parameters and the vibration analysis we covered in the previous lecture on PX4 practical applications must be in a relatively good state before attitude debugging.
The attitude parameter debugging method we are going to talk about today is for the cascaded PID controllers that are most widely used currently. In attitude control, the controllers designed based on the time-scale separation hypothesis generally have an inner-outer loop structure. The inner loop controls the attitude angular rate, while the outer loop controls the attitude angle. Time-scale separation means that the response speed of the inner loop is much faster than that of the outer loop, so the inner loop can quickly catch up with the expectations given by the outer loop within a very short time. The P (outer loop)-PID (inner loop) structure used in PX4 is designed in this way. We will talk about the design of the control laws for attitude control later, and we will elaborate on the two descriptions of Euler angles and quaternions respectively. Today, let's discuss how to debug the parameters of this P-PID inner-outer loop attitude controller.
The parameter adjustment methods for fixed-wing aircraft, helicopters, and multirotors have some similarities. However, their sensitivities to parameters are completely different. Helicopters are extremely sensitive to parameters. Even a slight change in parameters can lead to a significant difference in control effects. In contrast, fixed-wing aircraft have a wide range of parameter adaptability and are the easiest to debug. Today, our parameter adjustment mainly focuses on multirotors (the rotor part of vertical take-off and landing vehicles). Taking PX4 as an example, the debugging methods for other flight controllers are basically the same, except that the parameter names may vary and their functions may be slightly different.
Parameter Tuning Preparation
Before starting the parameter tuning, we need to make some preparations for debugging. It goes without saying that all systems of the aircraft should be functioning normally, and the flight control parameters also need to be changed and verified:
- The electronic speed controllers (ESCs) have been calibrated;
- The PWM_MIN parameter should ensure that the motors will not stop rotating after the aircraft is unlocked. The reason for this is that in extreme attitude control situations in the air, the motor control signals output by the aircraft usually reach the minimum and maximum positions. If the motors stop rotating when the PWM value is at the minimum position, it means that the motor control in this part no longer works, which will cause an imbalance of forces and torques of the aircraft and problems in attitude control. Therefore, the following verifications should be carried out on the ground:
- Power on the aircraft without installing the propellers;
- Push the throttle to the lowest position;
- Shake the aircraft 45 degrees in the pitch, roll, and yaw directions (this angle depends on the maximum attitude angle you set);
- Check if any motors stop running;
- Also, open the high rate option of the SDLOG_PROFILE parameter to facilitate the analysis of the attitude control effect;
- Set the parameter MC_AIRMODE to 0. This parameter will give priority to ensuring attitude control when the motors are saturated and weaken the control of the throttle channel;
-
Roll rate controller: (MC_ROLLRATE_P, MC_ROLLRATE_I, MC_ROLLRATE_D)
Pitch rate controller: (MC_PITCHRATE_P, MC_PITCHRATE_I, MC_PITCHRATE_D)
Yaw rate controller: (MC_YAWRATE_P, MC_YAWRATE_I, MC_YAWRATE_D)
Roll angle control: (MC_ROLL_P)
Pitch angle control: (MC_PITCH_P
Yaw angle control: (MC_YAW_P)
Maximum roll rate: (MC_ROLLRATE_MAX)
Maximum pitch rate: (MC_PITCHRATE_MAX
Maximum yaw rate: (MC_YAWRATE_MAX)
Roll rate feed-forward control: (MC_ROLLRATE_FF)
Pitch rate feed-forward control: (MC_PITCHRATE_FF)
Yaw rate feed-forward control: (MC_YAWRATE_FF)
Parameter Debugging Methods
The debugging methods for the pitch, roll, and yaw channels are basically the same. Therefore, we will only explain one of the channels. Take the roll channel as an example. For flight safety, we take off in the manual/Stablized mode during debugging and do not conduct test flights in the Acro mode.
The debugging steps are generally as follows:
- Gently push the throttle and observe on the ground whether the aircraft shows any tendency to oscillate. If not, take off normally.
- In the air, give a roll-direction stimulus (quickly push the roll joystick on the remote control to the left or right and then return it to the neutral position). The remote control gives roll-channel stimuli from small to large (about 10 - 30 degrees of stimulus), and then observe the aircraft's feedback to see if there is any oscillation.
- First, debug the parameter MC_ROLLRATE_P. This parameter is the main force of the angular rate controller. It responds immediately as long as there is an error. The value of this parameter directly affects the sensitivity of the aircraft. Increase it by 10 - 20% each time until the aircraft shows slight oscillations after being stimulated. At this point, reduce this parameter to about 60 - 70%.
- Next, debug the parameter MC_ROLLRATE_I. Also increase it by 10 - 20% each time until the aircraft shows slight oscillations, and then reduce it to 60 - 70%. This parameter is mainly used to eliminate the static tracking error. If the parameter is too small, it will be unable to deal with external disturbances.
- The parameter MC_ROLLRATE_D is related to the noise of the aircraft. So for noisy aircraft, this parameter is basically set close to 0. For aircraft with little noise, this parameter can be appropriately increased, and then observe whether the aircraft has slight oscillations. If so, reduce it to 50%. If this parameter is too small, there will be multiple aftershocks when the aircraft returns to the neutral position after being stimulated.
- After fixing the inner-loop parameters, debug the parameter MC_ROLL_P. This parameter basically doesn't need much debugging. If it is increased too much, the aircraft will oscillate, and then it needs to be reduced.
- The MC_ROLLRATE_FF parameter actually directly feeds the output of the angular rate loop back to the motors. This parameter is beneficial for the aircraft to quickly respond after giving an attitude expectation, but it cannot be too large because it is not feedback control. If the proportion of its output is too large, it will interfere with the control of the angular rate loop. If the attitude response of the aircraft is slow, it can be appropriately increased. If the attitude response is too sensitive, this parameter should be reduced.
- Regarding the limit parameters for angles and angular rates, they actually need to be set according to the specific aircraft. If the aircraft's motors lack power, set the limits lower. If the motors have sufficient power, set the limits more liberally.
- The THR_MDL_FAC parameter is used to correct the relationship between lift and PWM output values. We often find that when the aircraft is hovering, its attitude control is fine. But when it climbs or descends rapidly, the aircraft shows unstable attitude. This is because the relationship between force and PWM output is non-linear, so the control effect is different at different throttle values. We will talk more about this parameter later.
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.
- Set all MC_XXX_P to 0 (ROLL, PITCH, YAW).
- Except for MC_ROLLRATE_P and MC_PITCHRATE_P, set all MC_XXXRATE_P, MC_XXXRATE_I, and MC_XXXRATE_D to 0.
- Set MC_ROLLRATE_P and MC_PITCHRATE_P to very small values, such as 0.02.
- 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...