Method for realizing real-time communication between Micro-ROS and ROS Hub containers on single controller
By encapsulating the peripheral control interface as a static link library on the host machine and utilizing the Xrce-DDS protocol, Micro-ROS applications can directly access host resources, solving the communication bottleneck and development complexity problems in embedded systems. This enables efficient and real-time communication between Micro-ROS and ROS Humble containers, making it suitable for autonomous driving and industrial control equipment.
Patent Information
- Application Number
- CN202510564158.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-09-19
AI Technical Summary
In embedded autonomous driving systems, the communication between Micro-ROS and ROS Humble containers suffers from problems such as resource waste, poor real-time performance, and complex development. In particular, the lack of direct control channels and high coupling when accessing host peripheral resources results in poor communication reliability, making it difficult to implement in industrial scenarios.
By encapsulating the peripheral control interface as a C language static link library on the host machine and linking the library in the Micro-ROS application, the peripheral interface function is directly called for access. At the same time, the Xrce-DDS protocol is used to achieve real-time communication with the ROS Humble container, avoiding kernel rewriting and driver migration.
It achieves low-latency, high-compatibility and high-reliability communication, simplifies the development process, reduces system coupling, improves development efficiency and system performance, and is suitable for resource-constrained embedded platforms.
Smart Images

Figure CN120669986A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of embedded autonomous driving systems, robot development, and more particularly to a method and system for implementing real-time communication between Micro-ROS and ROS Humble containers on a single controller. Background Art
[0002] The Robot Operating System (ROS) is currently the mainstream robotics software framework. ROS 2Humble offers advantages such as distributed computing and high real-time support. However, a complete ROS Humble deployment typically relies on Ubuntu and Docker containers, resulting in high system resource usage and long startup times. This makes it difficult to achieve real-time performance requirements, especially on embedded or edge computing devices.
[0003] The traditional solution is to use Micro-ROS instead of ROS node deployment, running on a lightweight RTOS (such as Zephyr or FreeRTOS) to reduce resource load. However, when the Micro-ROS program needs to access host peripheral resources (such as CAN, RS485, SPI, etc.), there are serious bottlenecks: The first is the interface compatibility issue. There is a lack of direct control channel between Micro-ROS and the Ubuntu kernel. Second, the system call coupling is high. Traditional driver migration requires rewriting peripheral drivers under Micro-ROS, which increases development difficulty. Third, the communication links are complex and often require forwarding at an intermediate layer, which brings the risk of delay and packet loss.
[0004] In addition, some solutions attempt to circumvent the problem by running Micro-ROS and ROS nodes simultaneously in containers. However, problems such as conflicting access to peripheral resources, poor communication reliability, and lack of abnormal recovery mechanisms have not been effectively resolved, and lack the feasibility of implementation in industrial scenarios.
[0005] Therefore, there is an urgent need for a technical path that does not require modifying the system kernel or rewriting peripheral drivers, and can directly access host resources through Micro-ROS and communicate with ROS Humble containers in real time to adapt to application scenarios on resource-constrained platforms.
[0006] Therefore, the existing technology has yet to be improved. Summary of the Invention
[0007] In view of the above-mentioned deficiencies in the prior art, the present invention proposes a method for realizing real-time communication between Micro-ROS and ROSHumble containers on a single controller, aiming to overcome the problems of resource waste, poor real-time performance, and complex development in the prior art, so that the Micro-ROS program can directly control the peripheral resources of the host machine, thereby improving the overall system performance and development efficiency.
[0008] The technical solutions of the present invention are as follows: The present invention provides a method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller, the method comprising the following steps: S1. Encapsulate the host machine's peripheral control interface into a C language static link library and compile it in the host machine system; S2. In the Micro-ROS application running the Zephyr system, link the static link library; S3, through the Micro-ROS application program directly calls the peripheral interface function in the static link library to access and control the peripheral resources of the host machine; S4. Real-time communication between the Micro-ROS application and the ROS 2 nodes in the ROS Humble container is achieved through the Xrce-DDS protocol.
[0009] In one embodiment, the static link library includes at least one of the following control interface functions: CAN bus interface function, RS485 serial port interface function, I2C bus interface function or SPI interface function.
[0010] In one embodiment, the static link library is compiled into a linkable format that conforms to the target architecture supported by the Zephyr system, and is linked in a CMake manner during the Micro-ROS program build process.
[0011] In one embodiment, the Micro-ROS application periodically calls the interface function in the static link library to collect peripheral data during runtime, encapsulates the data into the ROS 2 standard message format, and publishes it to the ROSHumble container through Xrce-DDS.
[0012] In one embodiment, the Micro-ROS application further includes an error detection and recovery mechanism. When an abnormality in a peripheral interface is detected, the interface function is used to perform operations such as reinitialization, port restart, or switching control resources.
[0013] In one embodiment, the static link library is modular in design, and different peripheral control interface functions are encapsulated in independent modules. The Micro-ROS application can dynamically load or unload the corresponding modules as needed.
[0014] In one embodiment, the communication process is based on a publish / subscribe model for data interaction. The Micro-ROS node publishes collected data to the ROS Humble container, receives control instructions issued by the ROS Humble container, and calls the corresponding peripheral control interface to respond.
[0015] In one embodiment, the peripheral control interface function does not rely on host system calls, but operates the peripherals in user space through standard input and output or direct mapping, thereby improving real-time performance and data transmission rate.
[0016] In one embodiment, the method is applicable to a single-controller hardware platform, where the controller is an embedded processor that runs both the Ubuntu operating system and the Docker container, and whose processing architecture is ARM or RISC-V.
[0017] In one embodiment, the system can control multiple peripheral types simultaneously in actual deployment, and supports peripheral hot plug detection and interface module automatic loading or unloading mechanism, which is suitable for embedded control systems in highly dynamic device topology environments. In summary, the present invention encapsulates the peripheral control interface on the host machine and compiles it into a static link library. The Micro-ROS application directly accesses the host machine peripheral resources by linking to this library under the Zephyr system. At the same time, it uses the Xrce-DDS protocol to achieve real-time communication with the ROS Humble container, thereby constructing a lightweight communication solution with low resource usage, strong real-time performance, and high interface compatibility on a single controller platform. This method avoids the performance bottlenecks and development complexity caused by driver rewriting, kernel dependence, and intermediate bridging in traditional embedded systems. While maintaining system modularity and high portability, it achieves unified management and efficient control of multiple types of peripherals. It is particularly suitable for autonomous driving terminals, industrial control equipment, and resource-constrained edge computing platforms, and has significant technological advancement and engineering practical value.
[0018] Compared with the prior art, the present invention has the following beneficial effects: 1. Complete decoupling of peripheral control and the operating system kernel: This invention exposes the host peripheral interface to the Micro-ROS application through a static link library, eliminating the need to rewrite the driver in the Micro-ROS environment and avoiding the high coupling and high maintenance cost of traditional porting solutions.
[0019] 2. Extremely low communication latency and resource overhead: The data path design avoids middleware or daemon forwarding. Micro-ROS directly calls the interface to complete read and write operations, achieving sub-millisecond response, which is significantly better than the socket communication solution between containers.
[0020] 3. Strong portability and platform adaptability: Since the control interface is encapsulated in standard C language and linked during Micro-ROS compilation, it can be smoothly migrated to ARM architecture, RISC-V platform or bare metal system, with excellent product implementation capabilities.
[0021] 4. Highly robust communication link: Xrce-DDS achieves bidirectional synchronization with the ROS Humble container. Combined with the error recovery mechanism of the present invention, the system can automatically restore the link in scenarios such as peripheral disconnection, failure, and abnormal fluctuations, ensuring continuous availability.
[0022] 5. Rapid deployment and pluggable modules: The interface encapsulation is divided into functional modules, and the corresponding library files can be loaded on demand, achieving plug-and-play and on-demand integration, greatly improving development efficiency and subsequent maintenance convenience. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which: Figure 1 A flowchart of the method steps for implementing real-time communication between Micro-ROS and ROS Humble containers on a single controller provided by the present invention; Figure 2 This is a system block diagram of the method provided by the present invention for implementing real-time communication between Micro-ROS and ROS Humble containers on a single controller. DETAILED DESCRIPTION
[0024] To make the objectives, technical solutions, and effects of the present invention more clear and distinct, the present invention is further described in detail below. It should be understood that the specific embodiments described herein are merely for the purpose of explaining the present invention and are not intended to limit the present invention. The embodiments of the present invention are described below with reference to the accompanying drawings.
[0025] This embodiment provides a method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller. Figure 1 、 Figure 2 , the method comprises the following steps: S1. Encapsulate the host machine's peripheral control interface into a C language static link library and compile it in the host machine system; S2. In the Micro-ROS application running the Zephyr system, link the static link library; S3, through the Micro-ROS application program directly calls the peripheral interface function in the static link library to access and control the peripheral resources of the host machine; S4. Real-time communication between the Micro-ROS application and the ROS 2 nodes in the ROS Humble container is achieved through the Xrce-DDS protocol.
[0026] Specifically, in order to achieve real-time communication between the Micro-ROS program and the ROS Humble container, and at the same time allow the Micro-ROS program to directly control the peripheral resources of the host machine in a resource-constrained embedded environment, the present invention adopts a static linking method to encapsulate the peripheral control interface as a standard library file, and access it in the Micro-ROS application through a compile-time linking method to achieve transparent operation of the host machine peripherals.
[0027] In a further embodiment, the static link library is compiled into a linkable format that conforms to the target architecture supported by the Zephyr system, and is linked in a CMake manner during the Micro-ROS program build process.
[0028] The system deployment is based on a single-controller architecture. The host runs the Ubuntu operating system, and a Docker container environment is deployed on top of it. Within the container, a Zephyr-enabled Micro-ROS node runs. By encapsulating the host's CAN, RS485, and I2C hardware resources as static libraries and mapping them into the Zephyr container, Micro-ROS applications can directly access the host hardware through native calls without the need for kernel-level driver development or system call encapsulation. This simplifies the development process, reduces system coupling, and improves peripheral access efficiency.
[0029] In a further embodiment, the static link library includes at least one of the following control interface functions: CAN bus interface function, RS485 serial port interface function, I2C bus interface function or SPI interface function.
[0030] Each type of peripheral control interface is encapsulated in C language, and the interface includes standard operations such as initialization, data reading, data writing, status detection, exception handling, and resource release. Taking the CAN interface as an example, its control module contains functions such as can_init, can_send, can_receive, and can_close. These functions internally call the Ubuntu system's underlying SocketCAN driver interface to implement data interaction. All interfaces are packaged as static library files (such as libcancontrol.a) and cross-compiled into a target format recognizable by the Zephyr container. During the CMake build process of the Micro-ROS application, this static library is directly linked into the application, eliminating the need for any system middleware to be involved when calling it, reducing latency and the probability of failure in the communication path.
[0031] In a further embodiment, the Micro-ROS application periodically calls the interface function in the static link library to collect peripheral data during runtime, encapsulates the data into the ROS 2 standard message format, and publishes it to the ROSHumble container through Xrce-DDS.
[0032] Micro-ROS applications run in a task loop, encompassing tasks such as data acquisition, control command parsing, communication, and device status monitoring. In the data acquisition task, the application directly calls the read interface in the static library to obtain real-time data from devices such as CAN or RS485. This data is then encapsulated into the ROS 2 standard message format and published to subscriber nodes within the ROS Humble container via the Xrce-DDS proxy node. In the control command parsing task, the application receives control command messages issued by ROS Humble from the Xrce-DDS proxy and, based on the command content, calls the peripheral write interface to send the command to the corresponding device, achieving real-time closed-loop control.
[0033] In a further embodiment, the Micro-ROS application also includes an error detection and recovery mechanism. When an abnormality in a peripheral interface is detected, the interface function is used to perform operations such as reinitialization, restarting the port, or switching control resources.
[0034] The system features comprehensive exception handling capabilities. All peripheral control interfaces implement an error return code feedback mechanism. After calling any interface function, the Micro-ROS program immediately determines whether the return value is normal. If a peripheral interrupt, timeout, or data frame anomaly is detected, an error handling process is triggered. This process automatically restarts the peripheral port, reinitializes communication parameters, and marks the device status, reporting it to the ROS Humble node for decision support. The system also supports persistent caching of device status, allowing for rapid restoration of the previous control field status after a system restart.
[0035] In a further embodiment, the static link library is modular in design, and different peripheral control interface functions are encapsulated in independent modules. The Micro-ROS application can dynamically load or unload the corresponding modules as needed.
[0036] During runtime, the Micro-ROS program automatically loads or unloads static library modules based on the peripheral type. The system pre-sets a set of device description configuration files, which the Micro-ROS application reads during initialization and loads the required peripheral interface libraries on demand, improving memory usage efficiency. When multiple devices are running simultaneously, the control processes of each device are isolated from each other, preventing resource competition or conflicts and ensuring stable system operation.
[0037] In a further embodiment, the communication process is based on a publish / subscribe model for data interaction. The Micro-ROS node publishes collected data to the ROS Humble container, and at the same time receives control instructions issued by the ROS Humble container and calls the corresponding peripheral control interface to respond.
[0038] Data exchange utilizes the Xrce-DDS protocol, bridging Micro-ROS and ROS Humble via a proxy node. This protocol supports the stable transmission of high-frequency, low-latency data streams, supporting both subscription and publishing mechanisms and service invocation mechanisms, ensuring reliable and scalable data synchronization. In typical scenarios, this architecture can achieve data refresh rates exceeding 500Hz with sub-millisecond latency, making it suitable for applications requiring extremely high real-time performance, such as autonomous driving systems, industrial robots, and remote operation platforms.
[0039] In a further embodiment, the peripheral control interface function does not rely on host system calls, but operates the peripherals in user space through standard input and output or direct mapping, thereby improving real-time performance and data transmission rate.
[0040] Overall system deployment requires no deep modifications to the Ubuntu kernel or Docker configuration. All peripheral control interfaces rely solely on user-mode system resources, significantly improving system portability and compatibility. Developers do not need to learn complex driver development processes; they simply call functions based on encapsulated interfaces, significantly shortening the development cycle. The complete decoupling of the peripheral control layer from the communication synchronization layer makes this invention applicable not only to the current Zephyr-Micro-ROS architecture, but also to other lightweight RTOS or bare-metal platforms in the future.
[0041] In a further embodiment, the method is applicable to a single-controller hardware platform, where the controller is an embedded processor that runs the Ubuntu operating system and the Docker container simultaneously, and its processing architecture is ARM or RISC-V.
[0042] In a further embodiment, the system can control multiple peripheral types simultaneously in actual deployment, and supports peripheral hot plug detection and automatic loading or unloading mechanism of interface modules, which is suitable for embedded control systems in highly dynamic device topology environments.
[0043] The system has been deployed and verified on multiple prototype platforms, including an industrial master control chip platform using the ARM Cortex-A7, an edge processing platform based on the RISC-V architecture, and an onboard controller platform for unmanned road sweepers. In each of these platforms, the method described in the present invention achieves direct, low-latency control of host hardware by Micro-ROS and stable bidirectional communication with the ROS Humble container. The system's average CPU utilization rate is reduced by over 30%, and communication latency is reduced by over 70%. In interface abnormality reconnection tests, the recovery success rate exceeds 98%, verifying the engineering feasibility and technical advantages of the present invention's technical solution in actual industrial scenarios.
[0044] In summary, the present invention not only solves the resource bottleneck and driver migration problems of embedded systems in ROS communication, but also achieves breakthrough improvements in system architecture, interface design and operational efficiency. It has the technical value to be widely promoted and applied in high-reliability scenarios such as autonomous driving, robotics, and industrial control.
[0045] It should be understood that the application of the present invention is not limited to the above examples. For those skilled in the art, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A method for implementing real-time communication between Micro-ROS and ROS Humble containers on a single controller, characterized in that: The method comprises the following steps: S1. Encapsulate the host machine's peripheral control interface into a C language static link library and compile it in the host machine system; S2. In the Micro-ROS application running the Zephyr system, link the static link library; S3, through the Micro-ROS application program directly calls the peripheral interface function in the static link library to access and control the peripheral resources of the host machine; S4. Real-time communication between the Micro-ROS application and the ROS 2 nodes in the ROS Humble container is achieved through the Xrce-DDS protocol.
2. The method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller according to claim 1, characterized in that: The static link library includes at least one of the following control interface functions: CAN bus interface function, RS485 serial port interface function, I2C bus interface function or SPI interface function.
3. The method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller according to claim 1, characterized in that: The static link library is compiled into a linkable format that conforms to the target architecture supported by the Zephyr system, and is linked in CMake during the Micro-ROS program build process.
4. The method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller according to claim 1, characterized in that: The Micro-ROS application periodically calls the interface function in the static link library to collect peripheral data during runtime, encapsulates the data into the ROS 2 standard message format, and publishes it to the ROS Humble container through Xrce-DDS.
5. The method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller according to claim 1, characterized in that: The Micro-ROS application also includes an error detection and recovery mechanism. When an abnormality is detected in the peripheral interface, the interface function is used to perform operations such as reinitialization, restarting the port, or switching control resources.
6. The method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller according to claim 1, characterized in that: The static link library is modular in design, and different peripheral control interface functions are encapsulated in independent modules. The Micro-ROS application can dynamically load or unload the corresponding modules as needed.
7. The method for implementing real-time communication between Micro-ROS and ROS Humble containers on a single controller according to claim 1, characterized in that: The communication process is based on the publish / subscribe model for data interaction. The Micro-ROS node publishes the collected data to the ROS Humble container, receives the control instructions issued by the ROS Humble container, and calls the corresponding peripheral control interface to respond.
8. The method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller according to claim 1, characterized in that: The peripheral control interface function does not rely on host system calls, but operates the peripherals in user space through standard input and output or direct mapping, thereby improving real-time performance and data transmission rate.
9. The method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller according to claim 1, characterized in that: The method is applicable to a single-controller hardware platform, where the controller is an embedded processor that runs both the Ubuntu operating system and the Docker container, and whose processing architecture is ARM or RISC-V.
10. The method for implementing real-time communication between Micro-ROS and ROS Humble container on a single controller according to claim 1, wherein: In actual deployment, the system can control multiple peripheral types simultaneously, and supports peripheral hot-swap detection and automatic loading or unloading of interface modules. It is suitable for embedded control systems in highly dynamic device topology environments.
Citation Information
Cited By
Micro-ROS-based mobile robot embedded control system
CN120915728A