The purpose of this blog is to have an overall understanding of the px4 project, an understanding of the flow of each signal, and the control framework used by the control algorithm.
PX4 autopilot softwareCan be divided into three parts: real-time operating system, middleware and flight control stack.
1.NuttX real-time operating system
Provide POSIX-style user operating environment (such as printf (), pthreads, / dev / ttyS1, open (), write (), poll (), ioctl ()) Task scheduling.
2. PX4 middleware
PX4 middleware runs on top of the operating system, providing device drivers and a micro object request broker (uORB) for asynchronization between individual tasks running on the pilot Communication. After Px4 was open sourced by 3DR, the entire code structure was changed, the original system was abandoned, and Nuttx was adopted, but the core idea has not changed-in order to simplify development and use a message passing mechanism that sacrifices some efficiency, this is the most essential of Px4 and ArduPilot difference.
3. PX4 flight control stack
The flight control stack can use the PX4 control software stack or other control software, such as APM: Plane, APM: Copter, but it must run on PX4 middleware.
This part can be divided into
Decision navigation part: According to the aircraft's own safety status and received commands, decide which mode to work in and what to do next.
Position and attitude estimation part: According to the sensor to get its own position and attitude information, this part of the algorithm has the highest gold content, and there are quite a few algorithms.
Position and attitude control part: design the control structure according to the desired position and attitude, and achieve the desired position and attitude as quickly and stably as possible.
Controller output part: mixer and actuator, PWM limiter.
Algorithm inFirmware / src / modules, driven byFirmware/src/drivers
px4 native firmware module list:
System command program
mavlink-Send and receive mavlink information through the serial port
sdlog2-Save system logs / flight data to SD card
tests-Test procedures in the test system
top-List the current process and CPU load
uORB- Micro Object Request Broker-Distribute information between other applications
drive
mkblctrl--Blctrl electronic module driver
esc_calib-ESC calibration tool
fmu-Definition of FMU pin input and output
gpio_led——– GPIO LED driver
gps-GPS receiver driver
pwm-Update rate command of PWM
sensors-Sensor application
Flight control procedures
Flight safety and navigation
commander-Main flight safety state machine
navigator-Mission, fail-safe and RTL navigator
Estimate pose and position
attitude_estimator_ekf-Attitude estimation based on EKF
ekf_att_pos_estimator-Estimation of pose and position based on EKF
position_estimator_inav– Position estimation for inertial navigation
multirotor attitude and position controller
mc_att_control--Multirotor attitude controller
mc_pos_control--Multirotor position controller
fixedwing attitude and position controller
fw_att_control-Attitude control of fixed-wing aircraft
fw_pos_control_l1-Fixed wing position controller
VTOL attitude controller
vtol_att_control——Vertical take-off and landing attitude controller
3.1 Decision
3.1.1 Task decision. Mission-oriented, mission decision mainly decides where to go next for the multi-rotor. Further, the path needs to be planned so that the whole process can meet the requirements such as flying to the waypoint and flying along the route, and flying to the waypoint and obstacle avoidance .
3.1.2Health management and failure protection. Taking safety as the guide, the failure protection mainly decides where to go next for the multi-rotor. Before or during the flight of a multi-rotor aircraft, communication failures, sensor failures, and abnormal power systems may occur. These accidents will directly lead to the inability to complete control tasks. This part includes the introduction of safety issues, health assessment of airborne equipment, health monitoring of airborne equipment, and protection recommendations after failure.
Sensor calibrationinside commander
The corresponding program is in Firmware / src / modules / commander andFirmware/src/modules/navigator
Complete task mode switching, taking into account information such as battery power, GPS and other sensors are working properly.
3.2 Position estimation and attitude estimation
This part requires a lot of theoretical knowledge, which is temporarily lacking.
sensorsIt is a processing of gyroscope and accelerometer geomagnetic meter
3.3 Position control and attitude control
3.4pwm output
3.4.1mixer
The content corresponding to the official address (expired)
The mixer output defines how the controller output is mapped to the motor and servo output. All built-in mixer files are located in the / etc / mixers directory of the ROM file system and are compiled into firmware. Mixer is a set of independent mappers that read from the control and write to the output of the actuator. A module combines a set of inputs based on predefined rules and parameters to produce a set of outputs.
If it is zero, the output is zero, and the fixed value output by Mixer is limited.
The second line defines the output scaler and scalar parameters. Although the calculation is performed as a floating point operation, the value stored in the definition file is scaled by 10000 times, and the -0.5 offset is encoded as -5000.
This definition continues to describe the control input and zoom items:
S: <group> <index> <-ve scale> <+ve scale> <offset> <lower limit> <upper limit>
These values define the control group reading data from those scalers and the offset of the values within the group. It is specific to the device reading Mixer's definition.
When used for hybrid vehicle control, the mixer group 0 is the vehicle attitude control group, and the index values from 0 to 3 are usually: roll, pitch, yaw, thrust.
For details, see: https://pixhawk.org/dev/mixing?s[]=mixer
(3) Multi-rotor Mixer
The multi-rotor mixer combines four control inputs (roll, pitch, yaw, thrust) into a set of brake output for driving the motor speed controller.
The form defined by Mixer:
R: <geometry> <roll scale> <pitch scale> <yaw scale> <deadband>
Parameter explanation:
Machinery: including quad (4x, 4+), hex (6x, 6+), octo (8x, 8+)
Individual roll, pitch and yaw control factors
Motor output dead zone
Analysis of source code of vtol attitude control in px4 The /src/modules/vtol_att_control/ folder contains vtol_att_control_main, vtol_type, standard/tailsitter/tiltrotor and other files. Here is the ...
Share the artificial intelligence tutorial of my teacher, God! Zero basis, easy to understand! You are also welcome to reprint this article. Sharing knowledge, benefiting the people and realizing the ...
Share the artificial intelligence tutorial of my teacher, God! Zero basis, easy to understand! You are also welcome to reprint this article. Sharing knowledge, benefiting the people and realizing the ...
turn! turn! turn! https://blog.csdn.net/iqingfen/article/details/44703035 Keep your own Android framework source code structure diagram for your own convenience. The first 6 will be involved in the ba...
1. Some characteristics of redis Non -relationalKey valueThe database, the bottom layer is hashtable, can be taken out or inserted into the correlation value according to the time complexity of 0 (1) ...
Partial structure and redis-cli, redis-server structure diagram ZSkipList (structzskiplist) ZSet (structzset) listTypeEntry Struct (structlist_type_entry) redis DB structure diagram (structredis_db) r...
write at the beginning I recently started to learn the PX4 source code and carried out secondary development. I suffered from the lack of analysis of the PX4 source code on the Internet, so I opened a...
Ubuntu16.04 environment setup: If the cross-compilation chain cannot be downloaded with apt, use the following method. Next, download the source code and compile: Generally speaking, as long as there ...
PX4 has a good reputation and is currently the mainstream open source flight control project, and is used as a reference for flight control development by many companies. The project code can be downl...
PX4 open source engineering structure is concise introduction Step1 get open source code 1.1 Open source code version 1.2 clone open source code Step2 understand the project situation 2.1 Support mode...