Codesys Ros2 May 2026

Integrating CODESYS with ROS 2 (Robot Operating System 2) creates a powerful "Brain-Muscle" architecture for industrial automation. While ROS 2 excels at high-level "thinking" tasks like AI-driven path planning and 3D perception, CODESYS provides the deterministic "muscle" needed for real-time hardware control and safety-critical execution. Why Pair CODESYS with ROS 2?

Combining these two frameworks allows developers to bridge the gap between flexible open-source robotics and stable industrial standards:

Deterministic Control: CODESYS handles low-level hardware (e.g., EtherCAT, CANopen) with millisecond precision, which is often difficult to achieve reliably in a pure ROS 2 environment.

Advanced Capabilities: ROS 2 provides access to millions of lines of open-source code for complex tasks like SLAM (Simultaneous Localization and Mapping) and computer vision.

Reduced Vendor Lock-in: By using standardized interfaces like OPC UA or shared memory, you can swap hardware components without rewriting your entire high-level logic. Common Integration Methods codesys ros2

There isn't a single "official" driver, but several proven architectural patterns exist: ScalABLE40/robin: The ROS-CODESYS Bridge - GitHub

Integrating CODESYS with ROS 2 allows you to combine the deterministic hardware control of industrial PLCs with the advanced motion planning and perception capabilities of the Robot Operating System. 🚀 Direct Integration Methods

Shared Memory Bridge (Recommended for High Speed): Use the ROBIN project (ScalABLE40/robin) for high-performance data exchange on the same hardware (e.g., Raspberry Pi, Beaglebone).

OPC UA Bridge: Set up an OPC UA Server in CODESYS and use a ROS 2 node as an OPC UA Client with libraries like asyncua (Python) or open62541 (C++). Integrating CODESYS with ROS 2 (Robot Operating System

MQTT Messaging: Use the CODESYS MQTT library to publish PLC variables to a broker and subscribe to them via a ros2_mqtt bridge for non-real-time tasks.

Micro-ROS Agent: 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?

What is CoDeSys?

CoDeSys is a popular software tool for programming and configuring industrial controllers, such as programmable logic controllers (PLCs). It provides a comprehensive development environment for creating and testing control applications.

8. Limitations and Future Work

Current limitations:

Future directions:

🎁 Deliverables for End Users

  1. CODESYS Library: ROS2_Connector.library – function blocks, data types, visualization templates.
  2. ROS 2 Package: codesys_bridge – contains launch files, example .msg definitions, and a diagnostic node.
  3. Tutorials:
    • “Publish encoder ticks from PLC to ROS 2”
    • “Control a PLC conveyor via ROS 2 action”
    • “Live joint state broadcaster from CODESYS softmotion”

Step 1: Library Setup

  1. Open your CODESYS project.
  2. Open the Library Repository.
  3. Install the SysSock, SysSockets, and SL Iot MQTT Client libraries if not already present.

🔧 Key Capabilities

5.3 Determinism Impact

Inserting the CODESYS→ROS2 publisher at 1kHz increased the maximum PLC cycle time from 1.02ms to 1.19ms (17% increase). The worst-case occurred during DDS discovery heartbeats (every 3s). Using rclcpp::Publisher::publish() with pre-allocated messages eliminated dynamic memory inside the RT task.

Why Combine Them?

Why not just write everything in C++ (ROS2) or everything in Structured Text (CODESYS)?

  1. Reliability: PLC code is inherently safer. The cyclic execution model is easier to validate for functional safety standards (like ISO 13849) than a multi-threaded C++ application.
  2. Abstraction: A robotics engineer shouldn't need to know how to configure the specific registers of a motor drive. They just want to tell the robot to move. CODESYS provides a hardware abstraction layer that standardizes the hardware for the ROS2 stack.
  3. Maintainability: Factory technicians know how to troubleshoot PLCs. They can connect to the CODESYS web visualization to diagnose a hardware fault without needing to dig through complex ROS launch files.

1. One‑Click ROS 2 Interface Generation