Codesys Ros2 Access
ROS2 runs complex navigation algorithms (SLAM, LiDAR integration) to steer a vehicle through a warehouse, while a CODESYS controller drives the safety laser scanners, manages battery metrics, and actuates physical payload lifts.
Setting up a CODESYS-ROS 2 system involves a few key steps, often documented in advanced robotics community forums .
Create a Global Variable List (GVL) that will act as the data interface (e.g., RobotJoints , TargetPose ).
Success bred ambition. They taught ROS 2 to understand recipes: sequences that required sub-millimeter placement and human-safe approaches. ROS 2 planned a trajectory; CODESYS executed the motor profiles with hard real-time precision. For complex inspection runs, drones fed point clouds into ROS 2, which framed possible repairs and dispatched the nearest mobile platform. CODESYS ensured every actuator stayed inside certified constraints; ROS 2 negotiated exception cases and re-planned on the fly. Together, they became more resilient than either could be alone. codesys ros2
+-------------------------------------------------------+ | Industrial PC (IPC) | | | | +---------------------+ +---------------------+ | | | CODESYS RTL | | ROS2 Node | | | | (Deterministic) | | (Asynchronous) | | | +----------+----------+ +----------+----------+ | | | | | | +------------+--------------+ | | | | | [Bridge Layer: Shared Memory / DDS / MQTT] | +-------------------------------------------------------+ 1. The Native DDS Approach (Data Distribution Service)
Requires a CODESYS library (like the Robin library ) to read/write memory directly and a dedicated ROS 2 node to read that same memory. 2. MQTT or OPC UA (Standardized & Interoperable)
OPC UA is the gold standard for industrial interoperability. Most modern CODESYS runtimes include a built-in OPC UA server. On the robotics side, developers can use Python or C++ libraries ( opcua-asyncio or open62541 ) inside a ROS2 node to act as an OPC UA client. Success bred ambition
If you are running on the same industrial PC as your ROS2 Humble or Iron distribution, shared memory is the fastest route.
Bridging a cyclic, deterministic PLC environment with an asynchronous, pub/sub robotics network requires a robust middleware layer. There are three primary patterns used to connect CODESYS to ROS2.
In this scenario, CODESYS acts as a WebSocket client. It connects to the ROS bridge server, then can publish and subscribe to ROS topics by sending appropriately formatted JSON frames. For example, to publish velocity commands on the /cmd_vel topic, CODESYS sends a message like: For complex inspection runs, drones fed point clouds
Use the RobinNode function block in your PLC program to map your GVL variables to shared memory. Phase 2: ROS 2 Configuration
Use CODESYS for high-speed, deterministic hardware interaction ( ) while ROS 2 manages higher-level planning.