Chapter 10 PX4-Pixhawk-Attitude Control

第十章 PX4-Pixhawk-姿态控制    

- In this chapter, we analyze the attitude control. We still start from the startup file for attitude calculation, and find the startup file rc.mc_app for attitude calculation. Here, the startup item for attitude calculation is mc_att_control start, which does not contain any The parameter is directly start. 
According to the compilation rules, we can know the mc_att_control_main.cpp file that is called. Here, we will not continue to interpret the call between this function and new. If you don't understand, please refer to the previous blogs. Here we go directly to the task_main function to interpret it. 
The first is to subscribe to relevant data and update relevant data, mainly PID data and relevant limiter data write picture description here. Note that the parameters related to attitude can be adjusted here. The adjusted parameters are in mc_att_control params.c. If you are not afraid of fried chicken, you can try to adjust them. 
Then enter the big loop, the first is the anti-blocking time configuration, after the configuration is completed, it goes to the polling. The first is to limit the sampling time to between 2ms and 20ms, and then to update the relevant data of the aircraft write picture description here
At this point, we start to enter the control mode. The first is whether the attitude speed control mode is enabled. This is mainly controlled by the remote control to control the rate of pitch and roll, and then judge whether the value given by the remote control exceeds the threshold. If it exceeds the rate mode, the premise is to be enabled, otherwise it will enter the angle control mode write picture description here
According to the process, let's share the angle control first. First of all, it is necessary to judge whether it is a tailstock aircraft in the angle control. We only analyze the multi-rotor here, so we only analyze the multi-rotor here, and the multi-rotor directly enters the attitude control function write picture description here. We go directly to the conrtol_attitude function, where the parameter is the time interval parameter that will be used in the integral term. 
First, get the expected value. As for which value to get, you can go to the msg file to see it yourself. There are specific notes in it that are easier to understand. They are all written in English. Then get the desired throttle value write picture description here. The rotated R matrix is ​​then obtained by going through the DCM by expecting four elements write picture description here. Then it is to calculate the yaw value. The algorithm here is to find the theory by itself. This uses the calculation method of the vector write picture description here, and then calculates the deviation angle write picture description here. There are a lot of theories involved in this pile, which are basically vector operations. I have limited strength and I am not sure if I can explain them clearly, so I will not explain them in detail here. These are mainly a series of calculations for yaw. 
Going back to the function, we will know that after passing through the attitude control function, we will get the expected value of the attitude roll, pich, yaw, throttle write picture description hereand then publish the data. 
Entering into the else, here is the speed control, and then the remote control exceeds the threshold. Here, the remote control data will be converted to obtain the expected value write picture description hereand finally the data will be released. 
Then it enters the angle control loop. write picture description hereThe first is to obtain the angular rate of control, including roll, pich, and yaw, to write picture description herecalculate the deviation between the current angular rate and the desired angular rate, and then to calculate the control amount, which uses PID adjustment. The range of each data is judged, needless to say here, there is no problem with the algorithm here for aircraft. Just a classic PID. 
This is basically the end of the story, mainly to calculate the control amount and then publish the data. Here we will mention the control of those modes in commander.cpp. We will also talk about this file, but this is far away, because the things in PX4 are far from finished. Interested students can go to see it first, where it can be said It is a control of the APP layer, and many commands and controls are in this file.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326685975&siteId=291194637