Since CODESYS (IEC 61131-3) and ROS 2 (DDS-based) don't speak the same native language, you need a "translator." There are three primary ways to build this bridge: 1. The MQTT / OPC UA Gateway The most common "low-code" approach. CODESYS acts as an OPC UA Server . A ROS 2 node acts as an OPC UA Client
On a modern i7 with Preempt-RT Linux, you can achieve 2-5 ms end-to-end (PLC input → ROS 2 processing → PLC output). This is suitable for mobile robots, but not for sub-millisecond servo drives (which should stay internal to CODESYS soft motion).
documentation is a great way to see how ROS "talks" to external controllers. Final Thoughts codesys ros2
Integrating the two enables a division of labor: ROS 2 acts as the "brain," analyzing the environment and making high-level decisions, while CODESYS acts as the "nervous system," executing those decisions safely, precisely, and in real time. Key Architecture Patterns for CODESYS-ROS 2 Integration
Finally, one or more ROS 2 nodes are written to handle the communication. Using standard ROS 2 tools, the process typically involves: Since CODESYS (IEC 61131-3) and ROS 2 (DDS-based)
ROS 2 handles the complex navigation and obstacle avoidance, while CODESYS manages the physical drive train and safety interlocks.
+-----------------------------------------------------------+ | ROS 2 NETWORK | | [Nav2 / MoveIt] <---> [ROS 2 Node] <---> [DDS / UDP] | +-----------------------------------------------------------+ | (Communication Bridge) | +-----------------------------------------------------------+ | CODESYS RUNTIME | | [Fieldbus Master] <---> [IEC 61131-3 Logic] <---> [IO] | +-----------------------------------------------------------+ 1. Shared Memory (Ultra-High Speed, Co-located) A ROS 2 node acts as an OPC
Before any code is written, a common "language" must be defined. This data contract specifies what information will be shared, its format, and the direction of data flow. For example, a simple joint control system might define: