Codesys Ros2 ★ Premium & Official
Integrating (an industrial PLC programming environment) with
(Robot Operating System 2) bridges the gap between high-level robotic intelligence and low-level industrial control. This combination allows you to use ROS 2 for path planning or AI, while CODESYS handles real-time safety, motor control, and factory-floor protocols like EtherCAT or PROFINET. 🛠️ Methods to Connect CODESYS and ROS 2
There is no single "native" button to sync these two systems; instead, you must use a communication bridge or shared memory. 1. The "Robin" Library (GitHub)
project is a dedicated bridge designed specifically for ROS and CODESYS. How it works
: It provides a CODESYS library that allows you to use a "Robin" function block within your PLC logic to exchange data. codesys ros2
: You install the library, add it to your project, and import the example PLCopenXML project to get started. 2. OPC UA (Open Platform Communications)
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)
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.
The CODESYS application (often running on a SoftPLC) maps this shared memory to its global variables. Create a new ROS 2 package and add
This allows for sub-millisecond communication between the motion planner (ROS) and the motor controller (PLC). 🏗️ Implementation Workflow
You must create a standard package that handles the "outside" communication. Create Package ros2 pkg create --build-type ament_python
: Create a node to send sensor data (e.g., LiDAR) or receive motor commands. Bridge Node
: This node will take ROS messages and convert them to the protocol CODESYS understands (MQTT, OPC UA, or Shared Memory). In CODESYS ScalABLE40/robin: The ROS-CODESYS Bridge - GitHub Feature Name: CODESYS ROS 2 Connector
This is a comprehensive guide to bridging the gap between industrial PLCs (CODESYS) and the robotics world (ROS 2).
3. The Deep Integration: DDS on the PLC
The most exciting development for high-performance applications is the implementation of DDS directly onto the controller. Since ROS2 uses DDS as its middleware, a PLC that speaks DDS can essentially act as a native ROS2 node.
Some advanced industrial controllers running CODESYS on Linux (like Raspberry Pi with CODESYS Control or industrial edge PCs) allow for custom C++ libraries or specific DDS implementations. This allows the PLC to publish ROS2 topics directly (e.g., /joint_states or /cmd_vel) without a translation layer.
Step 3: Create a ROS 2 Package
- Create a new ROS 2 package and add the
ros2-Industrialdependency. - Use the ROS 2 package to communicate with the CoDeSys controller.
4. Toolchain Complexity
- You now need to manage two development environments: CODESYS IDE (Windows-only) and ROS 2 (Linux/macOS/Windows WSL2).
- CI/CD pipelines become hybrid: Build PLC projects with
CODESYS.Automationcommand-line tools, and ROS 2 packages withcolcon.
3. ROS 2 Action Server / Client in IEC 61131‑3
- Pre‑built function blocks:
ROS2_ActionClient_SendGoal,ROS2_ActionServer_Execute,ROS2_GetResult. - Allows a PLC to command a ROS 2 navigation stack (“move to pose”) or a ROS 2 manipulator (“pick object”) and wait for completion/failure – fully non‑blocking with state machines.
2. Real‑time DDS Integration
- Direct integration with Eclipse Cyclone DDS or Fast DDS inside the CODESYS runtime.
- Zero‑copy shared memory for large data (e.g., camera frames, point clouds) when CODESYS and ROS 2 nodes run on the same machine (e.g., PLCnext, BeagleBone, Raspberry Pi).
- Deterministic cycle‑synchronous data exchange down to 1 ms.