Basic Experiment | uORB message reading and writing and custom experiment (2)

guide

uORB is one of the very important and key modules in the PX4/Pixhawk system, and it is a protocol mechanism for communication between UAV modules. This article will introduce uORB in detail and disassemble the whole process of uORB message reading and writing and custom experiment (2).

Basic Experiment | uORB message reading and writing and custom experiment (2)

01

uORB message reading and writing function of RflySim platform

The uORB message system of PX4 provides a very powerful and convenient data interaction capability between internal modules. All modules can store data in the message pool, and other modules can subscribe to the required data from the message pool. However, the development process of uORB message reading, writing and custom message is relatively cumbersome as shown in the previous routine.

The RflySim platform developed the Pixhawk Target Block toolbox based on MATLAB/Simulink software. The uORB Read and Write in the toolbox provides a wealth of uORB message reading, writing and custom message modules; the main models are as follows:

picture

Using these three interfaces in Simulink, its parameter configuration includes message type, topic name and message data. The message type refers to the type of message to be written, and the corresponding message type definition file can be found under the "msg" directory in the PX4 source code. The topic name refers to the topic name corresponding to the message to be written, and the corresponding topic definition file can be found in the "topics" directory in the PX4 source code. Select the following format for the uORB message column: the double underscore "__" in the middle is a separator line, before the separator line indicates the file name of the uORB message, and after the separator line indicates the uORB message ID. actuator_controls__actuator_controls_0 The above format indicates that the message file is actuator_controls.msg, the message ID is actuator_controls_0, and multiple different message IDs can be customized under the same main message. Message data refers to the actual data to be written, which can be generated in other blocks in the Simulink model. Note: The above three modules can only be used in the PX4 flight control system, so you need to ensure that the PX4 development environment has been correctly configured before use, and the Simulink model has been successfully deployed to the PX4; and use "uORB Read Function-Call Trigger" module, you need to define the corresponding uORB message in PX4.

①: uORB message data monitoring interface module. This interface can respond to new messages received by calling external functions. Using the uORB Read Function-Call Trigger interface in Simulink, you can process new messages through a callback function (not used in this routine).

picture

②: uORB message data publishing interface module. This interface allows users to publish specified values ​​or structures to uORB topics.

picture

③: uORB message data publishing interface advanced module. This interface allows users more flexible control over the data they publish. Using the uORB Write Advanced interface in Simulink can achieve more complex and precise message publishing methods. Optionally a message file to write and a message ID. In addition, advanced options such as message priority and queue size can be set.

picture

02

UORB message reading and writing experiment based on RflySim platform

Based on the rich uORB message reading and writing interfaces provided by RflySim, it can be used in the experimental development of controller design and flight control internal data monitoring. The overall framework of this experiment is as follows:

picture

At the same time, the RflySim platform provides the uORB message rfly_px4 to send data (send specific data to 40100 series ports). In this experiment, after the message read from the flight controller is forwarded through the rfly_px4 message, the message can be monitored in Simulink during hardware-in-the-loop simulation. The demo of Simulink listening to uORB messages is as follows:

picture

After burning the uORB message reading and writing demo file into the flight controller through automatic code generation, open the Anslyze Tools->MAVLINK console of QGC, enter listener actuator_controls, listener actuator_controls_0 to see the operation effect of this routine as follows:

picture

When performing hardware-in-the-loop simulation, open the Simulink listener and click Run to monitor the written uORB message, as shown in the following figure:

References

[1]. https://doc.rflysim.com/

Guess you like

Origin blog.csdn.net/FEISILAB_2022/article/details/132097582