Codesys Ros2
capabilities of modern robotics frameworks. This setup is increasingly popular in Industry 4.0 for building flexible, robust automation systems. Core Architecture & Communication
: High-speed communication is often achieved via shared memory. A ROS 2 node reads and writes data to a specific memory location that the CODESYS runtime can also access, enabling extremely low-latency data exchange. ROBIN Project
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.
Data mapping requires precision. CODESYS uses IEC types like BOOL , INT , REAL , and LREAL , whereas ROS2 utilizes primitive IDL types within its messages ( bool , int32 , float32 , float64 ).
CODESYS provides deterministic, real-time control. It excels at tasks where timing is critical and failure is not an option: Controlling multi-axis gantry systems via EtherCAT. Managing safety-rated I/O and emergency stop circuits. codesys ros2
Ensure the OPC UA server is enabled in the PLC communication settings. Step 2: Create the ROS2 Bridge Node
Use industrial-grade hardware (PLC) while leveraging modern AI/robotic software packages.
, the leading IEC 61131-3 development environment for industrial PLCs, with ROS2 (Robot Operating System 2)
: PLCs like CODESYS are designed for 24/7 industrial reliability and handle low-level hardware communication (e.g., motor drives, sensors) more robustly than standard ROS 2 drivers. High-Level Intelligence capabilities of modern robotics frameworks
Building a CODESYS-ROS2 application typically follows this deployment pipeline: Step 1: Environment Setup
PLC-centric (CODESYS master)
: Using Modbus or OPC UA as an intermediary layer. For example, a Python script in the ROS2 workspace can act as a bridge, reading data from CODESYS via Modbus and publishing it to a ROS2 topic.
: This open-source bridge (originally for ROS but adaptable for ROS 2) maps CODESYS variables directly to ROS topics using a dedicated library and a ROS node. Industrial Protocols : Alternatives include using Modbus TCP A ROS 2 node reads and writes data
The integration of CoDeSys and ROS 2 enables developers to leverage the strengths of both technologies. By combining CoDeSys's industrial automation expertise with ROS 2's flexibility and scalability, developers can create sophisticated automation applications that benefit from:
Managing two distinct build environments (CODESYS IDE and the Linux terminal/Colcon) increases the learning curve for traditional PLC engineers. Conclusion
If you are looking to start, I can help you for specific robotics platforms, or provide examples of C++ ROS nodes that use the asyncua library to talk to CODESYS via OPC UA. Share public link
Integrating CODESYS with ROS 2 is not without pitfalls. Here are common issues and how to avoid them: