Abstract
In the wave of modern industrial automation and humanoid robotics technology, an efficient, reliable, and coordinated communication system is as crucial as a biological nervous system. This article will delve into how to construct the ‘cerebellum’ and ‘brain’ of intelligent robots through the collaboration of EtherCAT (Real-time Industrial Ethernet) and ROS2 (Robot Operating System with DDS as middleware).

Figure 1. Image source from the internet
The Cornerstone of EtherCAT Real-time Control
Introduction to EtherCAT
EtherCAT stands for Ethernet for Control Automation Technology. It was developed by Beckhoff Automation in Germany and introduced to the market in 2003, subsequently becoming part of the international standards IEC 61158 and IEC 61784-2. “High performance, low cost, easy to use, and flexible topology” perfectly summarizes its core advantages.
Differences from Traditional Ethernet Protocols
The power of EtherCAT comes from its revolutionary data processing mechanism. It operates fundamentally differently from traditional industrial Ethernet protocols, which function like a “postal truck”: the data frame sent by the master (controller) must be received in its entirety by each slave (servo drives, I/O modules, etc.) -> read the instructions for itself -> write the data to be sent -> and then forward the entire frame to the next slave. This method creates cumulative delays, slowing down as the number of nodes increases.
In contrast, EtherCAT operates more like a “high-speed train”: the data frame sent by the master also passes through each slave in sequence. The key difference is that each slave has a dedicated EtherCAT Slave Controller (ESC) chip. When the data frame passes through the ESC at the physical layer, the slave can read the instruction data sent to it in an instant (in nanoseconds) and simultaneously insert its data (such as sensor values) into the reserved position in the frame. This entire process generates almost no delay. The following diagram illustrates this process:

EtherCAT Communication Mechanism Diagram, EtherCAT’s “Fast Frame” Greatly Enhances Efficiency
For humanoid robots, EtherCAT acts as the peripheral nervous system, connecting every joint, sensing every sensor, and executing every precise instruction issued by the brain.
-
Master-slave architecture: one master (cerebellum) controls multiple slaves (limbs).
-
The lightning journey of data frames: the master sends a data frame (a train) that passes through each slave in sequence.
-
Real-time read and write: each slave acts like a high-speed platform, reading its command at the moment the data frame passes (usually <1μs) and inserting its status data without needing to store and forward the entire frame.
-
Efficient return: after traversing all slaves, the frame returns to the master, completing an efficient, synchronized loop communication.

EtherCAT Data Frame “On-the-fly Processing” Diagram

Operating Principle of EtherCAT
One EtherCAT data frame is sufficient to complete the sending and receiving of control data for all nodes. This high-performance operating mode overcomes various issues faced by traditional methods! The EtherCAT master sends a message that passes through all nodes. EtherCAT slave devices dynamically read the data addressed to that node at high speed (on the fly) and insert data while the data frame continues to transmit. Thus, the transmission delay of the data frame only depends on the hardware transmission delay. When the last node on a segment or branch detects an open port (no next slave), it uses the full-duplex feature of Ethernet technology to return the message to the master. The maximum effective data utilization rate of EtherCAT messages reaches over 90%, and due to the use of full-duplex characteristics, the effective data utilization rate theoretically exceeds 100 MBit/s. The EtherCAT master is the only node in the segment that can actively send EtherCAT data frames; other nodes only transmit data frames. This design avoids unpredictable delays, ensuring the real-time performance of EtherCAT. The EtherCAT master uses a standard Ethernet Media Access Controller (MAC), requiring no additional communication processor. Therefore, any hardware platform with an Ethernet interface can implement an EtherCAT master, regardless of the real-time operating system or application software used. EtherCAT slave devices use EtherCAT Slave Controllers (ESC) to dynamically process EtherCAT data frames in hardware at high speed (on the fly), making network performance predictable and independent of the specific implementation of slave devices. This data frame processing mechanism gives EtherCAT unparalleled advantages:
-
Extremely high bandwidth utilization: >90%, with almost no protocol overhead.
-
Extremely low latency and high synchronization accuracy: using distributed clock (DC) technology, achieving nanosecond-level synchronization, ensuring that hundreds of joints start simultaneously and in sync.
-
Flexible topology: linear, tree, star, simplifying field wiring.
-
Cost-effective: slaves only require a dedicated ESC chip, without the need for a powerful CPU.
Therefore, EtherCAT perfectly meets the extreme real-time and determinism requirements of tasks at the robot’s lower levels, such as joint torque control and high-precision sensor data acquisition. It serves as the “fast reflex arc” for robots interacting with the physical world.

Different Device Protocols Can Coexist in the Same System
SOEM is the Open-source Key to the EtherCAT World
The powerful EtherCAT technology was initially monopolized by commercial protocol stacks, leading to high development costs. The emergence of SOEM has democratized this technology. SOEM (Simple Open EtherCAT Master Library) is a free software developed by rt-labs AB, Sweden, implementing an EtherCAT master. SOEM is a lightweight, open-source, and cross-platform EtherCAT master protocol stack. Its significance lies in:
-
Zero-cost entry: developers do not need to pay expensive licensing fees.
-
Code transparency and customizability: fully open-source C code allows developers to deeply understand the principles and modify and optimize according to specific needs.
-
Wide hardware compatibility: can run on standard Ethernet cards (requiring support for low-level RAW Socket access) or various embedded platforms.
Using SOEM to develop a master is like training oneself to become the conductor of an EtherCAT orchestra, with the development process and functions illustrated in the following diagram:

1. Initialization and scanning: ec_init -> ec_config_init. The conductor takes the stage, scans the network, and identifies all musicians (slaves).
2. Topology mapping and configuration: parse ESI (slave description file), understand each musician’s skills (supported PDO/SDO). Configure parameters through SDO communication, assigning scores (configuring PDO mapping).
3. Synchronization: enable distributed clock (DC) to ensure all musicians’ metronomes are fully synchronized, which is key to playing harmonious pieces.
4. Enter real-time operational state: ec_state_check -> switch to OP state. The baton is raised, ready to start.
5. Real-time loop: in a strict periodic loop, call ec_send_processdata and ec_receive_processdata. The baton is waved down, issuing commands and receiving feedback on time.
6. Error handling: continuously monitor ec_slave[0].state and ec_group[currentgroup].docheckstate to ensure that any musician’s error does not cause the entire performance to collapse.
SOEM allows researchers, students, and engineers to access top-tier real-time industrial communication technology at minimal cost, greatly accelerating innovation and prototyping.
ROS2/DDS—The ‘Brain’ and Intelligent Hub of Humanoid Robots
If EtherCAT is responsible for the instinctive “reflexes” at the lower level, then ROS2 and its adopted DDS protocol constitute the robot’s advanced “central nervous system,” responsible for perception, cognition, decision-making, and complex coordination.
The first generation of ROS (ROS1) used a custom TCP/UDP communication mechanism, which had inherent flaws such as centralization, poor real-time performance, and inadequate network robustness. ROS2 made revolutionary changes: it is built directly on DDS. DDS is a data distribution service standard established by the Object Management Group (OMG), initially applied in military, aerospace, finance, and other fields with high demands for real-time performance and reliability. It is a data-centric publish-subscribe model.

Architecture Diagram (No Master Node in ROS2)
DDS constructs the concept of a “global data space.” Participants do not need to know of each other’s existence; they only need to care about the data they require. DDS adopts a data-centric publish-subscribe model:
-
Publish/Subscribe model: nodes can publish data on a certain “topic” or subscribe to topics they are interested in.
-
Automatic discovery: DDS has a powerful discovery mechanism built-in, allowing nodes to automatically find each other when joining or leaving the network, without a central node coordinating.
-
Rich QoS policies: can precisely control communication behavior (reliability, persistence, deadlines, etc.)
-
Decentralized architecture: no single point of failure, making the system more robust.

Data Publishing and Subscription in ROS2
Rich QoS policies are the soul of DDS. Developers can configure quality of service policies to precisely control communication behavior, such as:
-
Reliability: choose BEST_EFFORT (best effort, suitable for continuous sensor data) or RELIABLE (ensures delivery, suitable for critical commands).
-
History & Depth: set the depth of cached historical data.
-
Deadline: specify the maximum time interval for data updates.
-
Lifespan: set the validity period of the data.
-
Durability: the TRANSIENT_LOCAL policy allows new subscribers to receive the last published message.
Integration and Collaboration—Building a Complete Robot Nervous System
An advanced robotic system is not achieved by a single technology but is the perfect combination of the cerebellum and brain. They work together at different levels to form a complete robotic communication architecture, as shown in the following diagram:

Decision and Perception Layer (Brain – ROS2)
As the “brain” of the robot, this layer is responsible for high-level cognitive functions:
-
Multi-sensor fusion processing: integrating diverse data from vision, LiDAR, IMU, torque sensors, etc., achieving efficient data distribution through DDS topics and service mechanisms.
-
Complex environment perception and modeling: real-time construction of 3D environmental maps, identifying and tracking dynamic obstacles.
-
Intelligent decision-making and planning: generating motion trajectories based on machine learning algorithms, considering full-body dynamics constraints and balance control.
-
Human-machine interaction processing: handling natural language commands, gesture recognition, and emotional interaction.
-
Task-level coordination: managing task priorities, handling exceptions, and recovery strategies.

Real-time Control Layer (Spinal Cord – ROS2 + Master)
This layer acts as a bridge between the “brain” and “cerebellum,” achieving critical central coordination functions:
-
Hard real-time assurance: typically runs on a Linux PREEMPT_RRT real-time kernel, ensuring microsecond-level timing precision for control loops.
-
Control algorithm execution: implementing advanced control strategies, such as:
* Whole-body impedance control: coordinating torque outputs of multiple joints.
* Zero Moment Point (ZMP) control: maintaining stability during bipedal walking.
* Adaptive control: adjusting control parameters in real-time based on load changes.
-
Status monitoring and safety management: real-time monitoring of system status, implementing hardware limits, overcurrent protection, and other safety functions.
-
Data collection and preprocessing: filtering and preprocessing low-level sensor data to reduce the computational burden on higher layers.

Physical Layer (Peripheral Nervous System – EtherCAT)
As the “cerebellum” and reflex arc of the robot, it provides extreme real-time performance, sending joint target positions, velocities, or torques calculated by the ROS2 control layer to servo drives, and reading real data from motor encoders and force sensors:
-
Nanosecond-level synchronized control: achieving precise coordinated motion of multiple joints through distributed clock technology.
-
High bandwidth data acquisition: synchronously collecting encoder, torque sensor, and temperature data from all joints.
-
Deterministic response: ensuring response time determinism under worst-case scenarios, meeting safety-critical requirements.
-
Hot-swappable and redundant design: supporting hot-swapping of modules and link redundancy, enhancing system reliability.

Conclusion
The collaboration of EtherCAT and ROS2/DDS represents the highest level of robotic system architecture, each playing its unique advantages to jointly construct a complete technology stack.
-
EtherCAT provides extreme performance connecting the physical world, with nanosecond-level synchronization and deterministic response ensuring the precision and real-time nature of lower-level control. Open-source solutions like SOEM significantly lower the barrier to using this advanced technology, promoting its popularization and innovation.
-
ROS2 and DDS provide the software framework and communication foundation for building complex distributed systems, with a rich ecosystem and powerful toolchain greatly accelerating the development process. The data-centric architecture and rich QoS policies of DDS provide flexible and reliable communication guarantees for the robot’s “brain.”
Most importantly, the collaboration between the two is not a simple overlay but a deep integration. Through carefully designed architecture and optimization strategies, they achieve seamless connections from high-level intelligent decision-making to low-level precise control, providing a solid technical foundation for developing robot systems with human-like flexibility and intelligence.

Humanoid Intelligence Research Institute
WeChat ID丨Agent_Humanoid
Scan to follow
