Skip to main content

Codesys Ros2 [top] Link

The CODESYS controller acts as a client that sends data to an agent running on a Linux-based gateway (or the same IPC).

To understand the value of this integration, we must look at what each platform does best.

PROGRAM Publish_Twist VAR pub : REFERENCE TO Publisher; twist : REFERENCE TO Twist; END_VAR pub := ROS.NewPublisher('cmd_vel', 'geometry_msgs/Twist'); twist := ROS.NewObject('geometry_msgs/Twist'); twist.linear_x := 0.1; twist.angular_z := 0.2; pub.Publish(twist);

You cannot "run" ROS 2 inside a standard CODESYS PLC (yet). Instead, integration relies on a . codesys ros2

Getting CODESYS (Structured Text/Ladder Logic) to talk to ROS2 (C++/Python) requires a middleware bridge. There are three primary ways to do this: 1. The Micro-ROS Approach

Before deploying physical hardware, engineers can run a virtual CODESYS PLC (SoftPLC) on a local machine and connect it to a ROS2 simulation running in Gazebo or Isaac Sim. This allows complete validation of the control logic and robotics algorithms in a risk-free virtual environment. Key Challenges and Best Practices

Highly standardized; minimal setup on the CODESYS side. The CODESYS controller acts as a client that

The integration of (a widely-used IEC 61131-3 soft PLC platform) and ROS2 (Robot Operating System 2) represents a powerful shift in industrial automation, bridging the gap between traditional deterministic PLC control and modern, intelligent robotics .

ROS2 MoveIt provides path planning, and the command is sent over the bridge to CODESYS for real-time EtherCAT execution. 5. Summary and Future Outlook

Run the system and use standard ROS 2 commands (e.g., ros2 topic echo ) to monitor data exchange. Advantages of a CODESYS-ROS 2 System Instead, integration relies on a

: Requires mapping overhead; performance depends on the OPC UA server implementation.

Since CODESYS (IEC 61131-3) and ROS 2 (DDS-based) don't speak the same native language, you need a "translator." There are three primary ways to build this bridge: 1. The MQTT / OPC UA Gateway The most common "low-code" approach. CODESYS acts as an OPC UA Server . A ROS 2 node acts as an OPC UA Client

| Feature | Handled by CODESYS (PLC side) | Handled by ROS 2 (Edge/PC side) | | :--- | :--- | :--- | | | Servo drives, hydraulic valves, temperature loops (<1ms) | High-level trajectory following (>10ms) | | Safety | Safety-rated PLC (ISO 13849) | Monitoring, but not SIL-rated logic | | I/O Handling | 24V digital, 4-20mA analog, EtherCAT slaves | Cameras, LiDARs, 3D sensors, microphones | | Algorithms | PID, motion control (CNC/Robotics) | SLAM, A*, MoveIt motion planning, YOLO vision | | Communication | Modbus TCP, Profinet, OPC UA | DDS (Fast-DDS, CycloneDDS), MQTT, WebSockets | | Deployment | Flash to non-volatile PLC memory | Docker containers, Kubernetes, snap packages |

ROS 2 (Robot Operating System 2) is an open-source software framework for building robot applications. It provides a flexible and modular architecture for developing complex robot behaviors, allowing developers to focus on high-level tasks rather than low-level details. ROS 2 is designed to be highly scalable, secure, and reliable, making it suitable for a broad range of applications, from robotics and autonomous systems to industrial automation and IoT.

For high-performance applications (200Hz to 1000Hz), shared memory is the best option if both systems run on the same hardware (like a Raspberry Pi or an IPC). Architecture A ROS 2 node writes data to a shared memory segment.