The ROS2 Nav2 stack calculates a velocity command ( Twist message). It publishes this to a topic /cmd_vel . Through a DDS bridge or Gateway, this data arrives in the CODESYS controller as a structure containing linear and angular velocities. The CODESYS logic then checks if the velocity is within safe limits, applies ramping (smooth acceleration), and sends the command to the motor drives.
To appreciate the value of their integration, it is essential to understand the distinct strengths each platform brings to industrial environments. CODESYS (PLC) ROS2 (Robotics Framework) Deterministic machine control, safety, I/O handling Advanced robotics, navigation, computer vision Execution Real-time, cyclic, predictable ( Asynchronous, event-driven, pub/sub architecture Programming IEC 61131-3 (ST, LD, CFC, FBD, IL) C++ and Python Hardware Industrial PLCs, IPCs, embedded controllers Edge computers, GPUs, single-board computers Why Integrate CODESYS with ROS2?
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
Integrating CODESYS and ROS 2 lets you combine robust industrial control with advanced robotics functionality. The right architecture depends on safety needs, timing constraints, and hardware capabilities — but common themes are clear separation of safety-critical PLC logic from ROS-based autonomy, robust bridging with heartbeats/watchdogs, and careful latency testing. Implement incrementally: begin with telemetry and monitoring, then add constrained command interfaces with strict fail-safes.
Integrating these two ecosystems allows developers to combine the "hard" real-time reliability of a PLC with the cutting-edge libraries of the robotics world. Here is an in-depth look at why this integration matters and how to achieve it. Why Integrate CODESYS with ROS2? The ROS2 Nav2 stack calculates a velocity command
There are three primary methods to connect CODESYS to a ROS 2 ecosystem: A. Shared Memory (High-Speed/Real-Time)
3. Implementing the CODESYS ROS2 Bridge: A Step-by-Step Overview The CODESYS logic then checks if the velocity
For legacy systems or those where CAN bus is the primary communication medium, the ros_canopen package provides a standard ROS/ROS2 interface. This method relies on the CODESYS device implementing a CANopen protocol stack. The ros_canopen package handles the intricacies of CAN communication on the ROS side, such as sending Process Data Objects (PDOs) and Service Data Objects (SDOs). This approach is best suited for transmitting relatively small amounts of data at lower frequencies but benefits from a well-established ROS ecosystem.
Let’s look at a practical workflow for connecting a CODESYS-controlled robotic arm or AMR base to a ROS 2 navigation stack using an OPC UA bridge. Step 1: Configure the CODESYS OPC UA Server Open your CODESYS project. Add a object to your application tree.
The integration of CoDeSys and ROS 2 offers several benefits, including:
Use CODESYS for safety-critical logic and motor torque loops while ROS2 handles high-level mission planning.