Vendor-neutral, built-in security, and widely supported.
CODESYS acts as an OPC UA Server, exposing variables (such as motor velocities, joint angles, or system states). A ROS 2 node runs an OPC UA client instance (often utilizing Python libraries like asyncua or C++ libraries like open62541 ). The ROS 2 node translates OPC UA data into standard ROS 2 topics, services, or actions, and vice versa.
If you are looking to start with a specific PLC (like Beckhoff or Schneider) or need to bridge to a specific robot arm (like UR or KUKA), I can provide more tailored examples on how to structure the CODESYS function blocks.
| Method | Mean latency (μs) | Max jitter (μs) | CPU load (one core) | |--------|------------------|----------------|---------------------| | Native DDS (C++) | 85 | 210 | 12% | | CODESYS→ROS2 (lock-free) | 220 | 380 | 18% | | CODESYS→OPC UA→ROS2 | 3850 | 1200 | 25% | codesys ros2
To understand the value of this integration, it is essential to look at what makes each platform unique—and why they are fundamentally complementary. The Strengths of CODESYS
Use CODESYS for safety-critical logic and motor torque loops while ROS2 handles high-level mission planning.
For the most demanding real-time applications, such as direct, high-speed motion control loops, the overhead of network-based communication might be prohibitive. A high-performance alternative is to use POSIX shared memory, where both ROS 2 nodes and the CODESYS Control runtime system share a common memory region, enabling near-zero-latency data exchange. The CODESYS SysShm library provides functions like SysShmOpen to facilitate this, and the POSIX-based shared memory libraries enable the ROS side to interact with the same memory region seamlessly. Vendor-neutral, built-in security, and widely supported
OPC UA is the industrial standard for data exchange and is highly supported by CODESYS. CODESYS side OPC UA Server directly on the PLC. ROS 2 side : Write a ROS 2 node that acts as an OPC UA client. library for Python nodes or for C++ nodes. 3. Shared Memory (Highest Speed)
You must create a standard package that handles the "outside" communication. Create Package ros2 pkg create --build-type ament_python Write Publisher/Subscriber
But integration in production is never serene. One night, a malformed DDS packet from a development node caused stale status values to propagate into the translator. An edge node retried a fatal sequence three times. The watchdog triggered, CODESYS locked the arm, and the plant went into a protected safe state—lights pulsed, alarms whispered. Operators rushed in. In the postmortem, they found the flaw not in CODESYS nor ROS 2, but in the assumptions between them: who owns authority, what counts as truth, and which failures require graceful recovery versus immediate shutdown. The ROS 2 node translates OPC UA data
The convergence of classical Programmable Logic Controller (PLC) ecosystems and modern robotic software frameworks is a critical challenge in Industry 4.0. CODESYS, a dominant IEC 61131-3 development environment, excels at hard real-time control and fieldbus management (EtherCAT, CANopen). The Robot Operating System 2 (ROS2), built on Data Distribution Service (DDS), provides a flexible, distributed middleware for perception, planning, and collaboration. This paper proposes a formal architecture for integrating CODESYS runtime with ROS2. We analyze communication patterns, data representation mapping, real-time constraints, and security implications. A reference implementation using ROS2-native client libraries for CODESYS is presented, alongside performance benchmarks comparing native DDS versus OPC UA gateway approaches.
At the heart of CODESYS's motion capabilities is , a software library that extends the standard CODESYS runtime with powerful motion control functionality. It provides function blocks for managing single axes and coordinated multi-axis movements, electronic cams and gears, and CNC path interpolation. When integrated with ROS 2, a typical pattern is for an ROS 2 node to send high-level motion commands, such as a target pose for a pick-and-place operation. A CODESYS program then uses SoftMotion's multi-axis interpolation function blocks to compute the necessary joint trajectories and execute the motion with precise timing. This allows ROS 2 to focus on perception and planning while CODESYS handles real-time motion execution.