Method for efficiently communicating with ROS joint simulation threads

By introducing the LCM protocol stack and model design between ROS and Simulink, the communication latency and resource contention issues in a multi-threaded environment were resolved, achieving efficient multi-threaded communication and reasonable resource allocation, thus improving the real-time performance of the simulation model.

CN121070641APending Publication Date: 2025-12-05NORTH CHINA UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511147997.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-16
Publication Date
2025-12-05

AI Technical Summary

Technical Problem

The existing ROS platform suffers from problems such as high communication latency, poor real-time performance, severe resource contention, and low thread scheduling efficiency in multi-threaded and large-scale co-simulation environments.

Method used

We adopted the LCM protocol stack combined with Simulink model design and implemented multi-threaded high real-time communication between ROS and Simulink in the Linux operating system through the RCP toolchain. This included the deployment of the LCM communication module, interface design and model building. We used RTW and TLC to generate executable files to achieve efficient communication.

Benefits of technology

It improves the communication efficiency and real-time performance of the simulation model, achieves high real-time performance and reasonable resource allocation, and solves the communication bottleneck and resource competition problems in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121070641A_ABST
    Figure CN121070641A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of robots, in particular to a method for efficiently communicating with ROS joint simulation threads, which is characterized by comprising the following steps of: 1, deploying an LCM (Liquid Crystal Module) communication protocol stack; step 2, designing an LCM (Liquid Crystal Module) communication interface between the ROS and the Linux; step 3, establishing and deploying a Simulink model; 4, real-time simulation and monitoring are carried out; and 5, iterative optimization and verification are carried out. The invention provides an LCM (Liquid Crystal Module)-based multi-thread communication and joint simulation framework between ROS (Remote Operating System) and Simulink, which realizes dual improvement of communication real-time performance and multi-thread operation efficiency; an LCM message efficient conversion interface under the ROS is designed, and communication delay is remarkably reduced; a real-time communication mechanism between the ROS and the simulink is provided, and real-time interaction and synchronous operation of data are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of robot technology, and in particular to a method for efficient communication between simulation threads in combination with ROS. BACKGROUND

[0002] The closest prior art to the present application is mainly a simulation model constructed based on the ROS platform alone. Such systems mostly use the native TCP / IP communication protocol of ROS. Although they have the advantages of modularity and powerful functions, their defects are obvious when used in a multi-thread environment and large-scale joint simulation. Specifically, they have the following problems: Disadvantages of the prior art solution: 1. The communication mechanism of ROS is based on the TCP / IP protocol, which is prone to communication bottlenecks when processing a large amount of real-time data, resulting in data delays and even packet loss. 2. The message encoding and decoding mechanism of ROS is relatively complex. In particular, in a multi-thread scenario, when multiple threads concurrently access and process a large number of messages, it will cause serious resource competition and thread blocking, affecting communication efficiency. 3. ROS lacks an effective thread management mechanism, making it difficult to achieve reasonable allocation and scheduling of threads, and unable to fully utilize multi-core CPU resources, resulting in reduced overall system performance. 4. The default simulation communication interface of ROS performs poorly in a high-frequency data exchange environment and cannot effectively meet the requirements of multi-robot collaboration, real-time control, and simulation accuracy. Based on this, the present application proposes a new joint simulation framework for ROS and Simulink based on the LCM protocol, effectively improving the communication efficiency and real-time performance of the simulation model. SUMMARY

[0003] The technical problem to be solved by the present application is to address the problems of high communication delay, poor real-time performance, severe resource competition, and low thread scheduling efficiency of existing ROS platforms in a multi-thread and large-scale joint simulation environment. The present application proposes an LCM protocol communication method between ROS and Simulink and a joint simulation system to achieve high real-time performance, high communication efficiency, and reasonable resource allocation for ROS and Simulink joint simulation, improving simulation accuracy and system stability, and effectively solving the problems raised in the background technology.

[0004] To solve the above problems, the technical solution adopted by the present application is to build a model using the Model-Based Design (MBD) method in combination with Simulink, use an LCM communication module in the model to realize communication functions with ROS, and use an RCP tool chain to compile the model to generate an executable file for deployment in a Linux operating system, realizing multi-thread high real-time communication between ROS and Simulink models. The present application is characterized by the following steps: Step one, LCM communication protocol stack deployment: including compiling and installing LCM protocol stack, adding LCM dependent library and building model; Step two, LCM communication interface design between ROS and Linux: including designing data structure file.lcm, publishing / subscribing topic, writing publishing / subscribing model encapsulating LCM topic; Step three, Simulink model building and deployment: when building Simulink model, data messages under ROS function package are acquired, and messages of ROS are transmitted through topic; when deploying Simulink model, model is converted into RTW intermediate file to form complete C language project,.mk file is generated and compilation process is completed, and executable file is generated and deployed to ROS system; Step four, real-time simulation and monitoring: running function package and model program involved in LCM communication; Step five, iterative optimization and verification: designing LCM communication type, real-time monitoring data and verifying Simulink model iterative optimization.

[0005] Preferably, in step one, LCM protocol stack is compiled and installed on ROS system, and LCM dependent library is added into Linux environment and development host Simulink environment, and in Simulink environment, model is built in a model-based development manner, simulation parameters and interface design are performed.

[0006] Preferably, in step two, data structure file.lcm is designed according to required transmission data size type, library file for LCM communication is generated, in ROS end, according to the data structure, publishing / subscribing topic of message in the ros function package to be transmitted / received is performed, in Simulink end, according to the data structure, publishing / subscribing model encapsulating LCM topic is written using C language for Simulink mode to process data.

[0007] Preferably, in step three, when building Simulink model, LCM module designed in step two is used to acquire data messages under ROS function package for model use, and messages needed by model to act on ROS are transmitted through topic; When deploying Simulink model, through rapid control prototyping technology, model is converted into RTW intermediate file in Simulink using RTW, RTW file is automatically converted into C code and header file through openTLC system target file, complete C language project is formed,.mk file is automatically generated through TMF template binding file, cross compiler is called to complete compilation process, executable file is generated, and ROS system is deployed based on TCP / IP.

[0008] Preferably, the fourth step of running the function package and model program involved in LCM communication can directly observe the ROS topic message publishing and subscribing situation at the terminal; the Simulink end can detect the model running state and LCM communication data in real time through external mode.

[0009] Preferably, the fifth step of designing LCM communication types based on the above steps for different needs, real-time monitoring data, realizing joint simulation between Simulink and ROS, and directly verifying Simulink model iteration optimization.

[0010] Key Term Explanation 1. ROS (Robot Operating System, ROS) is an open-source robot development framework that provides a series of tools, libraries and conventions to simplify the construction of complex robot systems.

[0011] 2. LCM (Lightweight Communications and Marshalling, LCM) is a high-performance communication framework designed for real-time systems, widely used in robotics, autonomous driving, drones and other fields. Its core goal is to provide low-latency, high-throughput cross-process / cross-platform communication, while simplifying data serialization and transmission.

[0012] 3. RCP (Rapid Control Prototyping, RCP) Fast control prototype is an engineering technology for control system development, mainly applied in the fields of automobiles, industrial automation, aerospace, etc. Its core goal is to quickly build and test control algorithm prototypes, shorten the cycle from design to actual deployment, and reduce development risks.

[0013] 4. MBD (Model-Based Design, Model-Based Design) is a method of system design and verification through mathematical models, commonly used in tools such as Simulink, supporting a complete development process from simulation to code generation.

[0014] 5. RTW (Real-Time Workshop, Real-Time Workshop) is a tool chain module in MATLAB / Simulink, used to automatically convert models into real-time executable code.

[0015] 6. TLC (Target Language Compiler, Target Language Compiler) Part of Simulink code generation tool, responsible for converting intermediate files into code for target platforms (such as C / C++).

[0016] 7.TMF (Template Make File, Template Make File) Template file used to generate compilation scripts (such as Makefile), supporting automated compilation process.

[0017] Compared with the prior art, the application provides a ROS joint simulation inter-thread efficient communication method, which has the following beneficial effects: The application provides a ROS and Simulink inter-thread communication and joint simulation framework based on LCM, which realizes the dual improvement of communication real-time performance and multi-thread running efficiency; designs an efficient LCM message conversion interface under ROS, significantly reduces communication delay; and provides a real-time communication mechanism between ROS and Simulink, ensuring real-time data interaction and synchronous operation. BRIEF DESCRIPTION OF DRAWINGS

[0018] Figure 1 The communication method of the application is a step block diagram. DETAILED DESCRIPTION

[0019] The technical solutions in the embodiments of the application will be clearly and completely described below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, not all.

[0020] Referring to Figure 1 The application provides a ROS joint simulation inter-thread efficient communication method, characterized by comprising the following steps: Step 1, LCM communication protocol stack deployment 1.1 Compile and install the LCM protocol stack on the ROS system; 1.2 Add the LCM dependent library into the linux environment and the development host Simulink environment; 1.3 Use the Simulink environment to build a model in a model-based development (MBD) manner, simulate parameters, and design interfaces; Step 2, LCM communication interface design between ROS and Linux 2.1 According to the required data size type, design a data structure file.lcm to generate a library file that can be used for LCM communication; 2.2 At the ROS end, according to the above-defined data structure, publish / subscribe to the corresponding topic of the message at the ros function package that needs to be transmitted / received; 2.3 In Simulink, the C language can be used to write the publish / subscribe model encapsulating the LCM topic according to the data structure defined above, which can be used for Simulink mode processing data; Step three, Simulink model building and deployment 3.1 When building a Simulink model, the LCM module designed in step two can be used to obtain the required data messages under the ROS function package for the model, and the messages required by the model to act on ROS are transmitted through the topic; 3.2 Through the rapid control prototype technology, the model is converted into an RTW intermediate file in Simulink, and the RTW file is automatically converted into C code and header files through the open TLC (Target Language Compiler) system target file, forming a complete C language project, and the.mk file is automatically generated through the TMF (Template Make File) template linking file, and the cross compiler is called to complete the compilation process, and the executable file is generated and deployed to the ROS system based on TCP / IP; Step four, real-time simulation and monitoring 4.1 The function package and model program involved in LCM communication are run, and the ROS topic message publishing and subscribing situation can be directly observed on the terminal; 4.2 The Simulink end can detect the model running state and LCM communication data in real time through external patterns; Step five, iterative optimization and verification Based on the above steps, the LCM communication type is designed for different needs, the data is monitored in real time, the joint simulation between Simulink and ROS is realized, and the iterative optimization of the Simulink model can be directly verified.

[0021] To solve the problems of the prior art, the present application gradually explores the introduction of other communication middleware, among which LCM (Lightweight Communication and Marshalling Protocol) gradually attracts attention due to its low delay, high real-time performance and high throughput. LCM protocol is based on UDP multicast communication and can efficiently process real-time data streams, especially suitable for application scenarios with high real-time requirements in the field of robots. It provides a publish / subscribe message passing model and automatic marshalling / de-marshalling code generation with various programming language application bindings. Therefore, based on the LCM protocol, the present application proposes a new joint simulation framework of ROS and Simulink, which effectively improves the communication efficiency and real-time performance of the simulation model.

[0022] The application proposes a robot simulation communication architecture combining an RCP tool chain, a Simulink MBD model development method and an LCM communication protocol, and realizes high real-time multithreading communication in a ROS and Simulink dual-process environment.

[0023] The above examples are only used to illustrate the technical solutions of the present application, but not limit it; although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that the technical solutions recorded in the foregoing examples can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for efficient communication between threads in conjunction with ROS simulation, characterized in that, The method comprises the following steps: Step one, LCM communication protocol stack deployment: including compiling and installing LCM protocol stack, adding LCM dependent library and building a model; Step two, LCM communication interface design between ROS and Linux: including designing data structure body file.lcm, publishing / subscribing topics, and writing a publishing / subscribing model encapsulating LCM topics; Step three, Simulink model building and deployment: when building a Simulink model, data messages under a ROS function package are acquired, and the messages of ROS are transmitted through topics; when deploying the Simulink model, the model is converted into an RTW intermediate file to form a complete C language project, an.mk file is generated and the compiling process is completed, and an executable file is generated and deployed to a ROS system; Step four, real-time simulation and monitoring: running function packages and model programs involved in LCM communication; Step five, iterative optimization and verification: designing LCM communication types, monitoring data in real time, and verifying Simulink model iterative optimization.

2. The method for efficient communication between threads in conjunction with ROS simulation according to claim 1, wherein, In step one, the LCM protocol stack is compiled and installed on the ROS system, and the LCM dependent library is added to the Linux environment and the host Simulink environment; in the Simulink environment, a model is built in a model-based development manner, and simulation parameters and interface design are performed.

3. The method according to claim 1, wherein, In step two, a data structure body file.lcm is designed according to the required data size type, a library file for LCM communication is generated, a topic is published / subscribed in a ros function package where a message needs to be transmitted / received, and a publishing / subscribing model encapsulating LCM topics is written in C language according to the data structure body, for Simulink mode data processing.

4. The method for efficient communication between threads in conjunction with ROS simulation according to claim 1, wherein, In step three, when building a Simulink model, the LCM module designed in step two is used to acquire data messages under a ROS function package for model use, and messages needed to act on ROS are transmitted through topics; When deploying the Simulink model, the model is converted into an RTW intermediate file through RTW in Simulink by using the rapid control prototyping technology, the RTW file is automatically converted into C code and header files through an TLC system target file, a complete C language project is formed, an.mk file is automatically generated through a TMF template, a cross compiler is called to complete the compiling process, an executable file is generated, and the executable file is deployed to the ROS system based on TCP / IP.

5. The method for efficient communication between threads in conjunction with ROS simulation according to claim 1, wherein, In step four, function packages and model programs involved in LCM communication are run, and the ROS topic message publishing and subscribing situation can be directly observed at a terminal; the model running state and LCM communication data can be detected in real time at the Simulink end through an external mode.

6. The method for efficient communication between threads in conjunction with ROS simulation according to claim 1, wherein, In step five, LCM communication types are designed according to different requirements based on the above steps, data is monitored in real time, joint simulation between Simulink and ROS is realized, and Simulink model iterative optimization can be directly verified.