Ros2 - Codesys
For microcontrollers or lightweight PLCs, run a micro-ROS node directly on the target hardware to communicate with the ROS 2 Global Data Space. 🛠️ Strategic Setup: Why use both?
Then Mira, the automation engineer, had an idea that would change the plant’s heartbeat. She imagined CODESYS not as a siloed PLC runtime but as a bridge: controllers still enforcing safety interlocks and hard real-time motion, while ROS 2 orchestrated high-level behaviors, vision-guided corrections, and fleet coordination. She sketched a layered architecture on a napkin: CODESYS managing deterministic I/O and motion via its runtime, ROS 2 nodes running on edge computers for perception and planning, and a middleware translator whispering between them. The translator would expose ROS 2 topics as CODESYS variables and map CODESYS events into ROS 2 services—two ecosystems speaking through a well-defined protocol.
ROS2 runs on a standard Linux kernel, which introduces microsecond-level timing variations (jitter). If your ROS2 node crashes or suffers from a network delay, the CODESYS PLC must be programmed to handle this safely.
For years, these two ecosystems existed in isolation. Bridging them required complex, custom-built communication bridges that introduced latency and vulnerabilities. Today, integrating —the leading hardware-independent IEC 61131-3 development system—with ROS 2 has emerged as a premier architecture for next-generation smart factories. Why Connect CODESYS with ROS 2? codesys ros2
On the surface, CODESYS and ROS 2 seem designed for different domains. CODESYS is built for industrial automation: controlling conveyors, managing safety systems, and driving motors with microsecond precision. ROS 2 is built for robotics: sensor fusion, motion planning, perception, and complex algorithmic control. However, modern smart factories demand both. A robotic workcell might rely on a CODESYS‑based PLC to handle safety interlocks and axis control, while a ROS 2 node performs vision‑based grasping or dynamic path planning.
A simple example in CODESYS for publishing a Twist message via a ROS bridge looks like:
OPC Unified Architecture (OPC UA) is a platform‑independent, secure communication standard widely adopted in industrial automation. CODESYS includes built‑in support for an OPC UA server, which can expose any of its process variables as OPC UA nodes. On the ROS 2 side, a node can act as an OPC UA client using libraries such as open62541 (C/C++) or asyncua (Python) to read and write those variables. For microcontrollers or lightweight PLCs, run a micro-ROS
Are you planning to use a as your industrial gateway, or are you working with a specific PLC hardware like Beckhoff or Wago? What is a ROS2 Topic? - ROS2 Tutorial 6
The most industrial method involves OPC UA (Open Platform Communications Unified Architecture). CODESYS has built-in OPC UA servers. ROS2 nodes can act as OPC UA clients to read and write variables directly to the PLC.
ROS 2 brings advanced, data-heavy capabilities to the table. It handles complex algorithmic tasks that are impossible or highly impractical to program inside a standard PLC: Processing 3D LiDAR and camera data. She imagined CODESYS not as a siloed PLC
: PLCs excel at real-time, deterministic control. They manage microsecond-level I/O loops, execute safety functions, and communicate via robust industrial protocols like EtherCAT, PROFINET, and EtherNet/IP. However, they lack the computational flexibility needed for complex tasks like autonomous navigation, dynamic path planning, or machine learning.
Standard Wi-Fi or Ethernet can introduce unpredictable latency. For critical mobile applications, leverage robust communication protocols, minimize the payload sizes sent across the bridge, and utilize Quality of Service (QoS) settings within ROS 2 to prioritize critical control topics. Conclusion