Codesys Ros2 -

Integrating CODESYS with ROS 2 bridges the gap between high-reliability industrial automation (PLCs) and advanced robotic software. While CODESYS manages deterministic real-time tasks like motor control and safety, ROS 2 provides high-level capabilities like SLAM, AI, and path planning. Integration Strategies

There is no single "native" ROS 2 driver for CODESYS, but several established methods exist: micro-ROS - Putting ROS 2 onto Microcontrollers - FIWARE


Step 1: Install CoDeSys and ROS 2

Bridging the Gap: Running ROS 2 on Industrial PLCs with CODESYS

For years, there has been a quiet war in the automation world: The deterministic, rugged world of PLCs (IEC 61131-3) vs. the flexible, modular world of robotics (ROS 2).

If you build mobile robots, autonomous guided vehicles (AGVs), or industrial manipulators, you’ve likely faced this painful choice. Do you use a standard PLC for safety and I/O but struggle with complex navigation? Or do you use ROS 2 for perception and planning but struggle with real-time fieldbus control? codesys ros2

Thanks to the CODESYS ROS 2 SLAM, you no longer have to choose.

Step 4: Run

Round-trip latency: On a modern i7 with Preempt-RT Linux, you can achieve 2-5 ms end-to-end (PLC input → ROS 2 processing → PLC output). This is suitable for mobile robots, but not for sub-millisecond servo drives (which should stay internal to CODESYS soft motion).


4.4 Example: Joint Position Publisher

Structured Text code inside a 1ms CODESYS task: Integrating CODESYS with ROS 2 bridges the gap

PROGRAM PRG_JointPublisher
VAR
    ros_pub : FB_ROS2_Publisher;
    joint_pos : ARRAY[0..5] OF LREAL := [0.0, -0.5, 0.5, 0.0, 0.0, 0.0];
    trigger : R_TRIG;
    cycle : UINT := 0;
END_VAR

trigger(CLK:= TRUE); IF trigger.Q THEN ros_pub(execute:= TRUE, topic_name:= '/joint_states', data:= joint_pos); END_IF ros_pub(busy=>);

Bridging the Gap: Integrating CODESYS with ROS2 for Next-Generation Automation

For decades, the worlds of industrial automation and mobile robotics have run on parallel, yet distinctly separate, tracks. Step 1: Install CoDeSys and ROS 2

On one side, we have CODESYS, the gold standard for industrial programmable logic controllers (PLCs). It is reliable, deterministic, and governed by strict IEC 61131-3 standards. It is the language of the factory floor—handling sensors, actuators, and safety logic with millisecond precision.

On the other side, we have ROS2 (Robot Operating System). This is the dominant framework for robotics research and development. It handles complex motion planning, computer vision, SLAM (Simultaneous Localization and Mapping), and high-level decision-making.

Historically, getting these two to talk required custom middleware, messy socket programming, or expensive hardware gateways. However, as Industry 4.0 advances, the demand for "Industrial ROS" has led to a convergence. Today, integrating CODESYS with ROS2 is not just possible—it is becoming a best practice for building robust, scalable robotic systems.

Option A: ROS 2 + OPC UA