Copyright (c) 2025, b-robotized. All rights reserved. Author: Nikola Banovic
This package provides a ros2_control
SystemInterface for communicating with Beckhoff TwinCAT PLCs. It acts as a transport layer, allowing ros2_control
controllers to read from and write to PLC variables (e.g., joint states, GPIOs, sensor values) over the network.
The core of this hardware interface is in using ADS Sum-Commands. This allows us to read/write multiple PLC variables in a single network transaction, bringing the total network transactions per update loop to only 2 (one read and one write).
This package is built upon the official beckhoff/ADS
library, which handles the low-level ADS protocol communication.
ros2_control
Integration: Seamlessly integrate your PLC application with theros2_control
framework.- Efficient Communication: Utilizes ADS Sum-Commands to bundle multiple variable requests, ensuring high-performance communication suitable for real-time control loops.
- URDF-Based Configuration: All hardware connections and variable mappings are configured directly within your robot's URDF file.
- ROS 2 (Jazzy Jalisco or newer recommended)
- ads_vendor package
Configuration is managed entirely within the <ros2_control>
tag of your robot's URDF file. You must specify the PLC connection parameters and map each hardware interface (state or command) to a specific variable on the PLC.
These parameters define the connection to the target PLC.
Parameter | Type | Description |
---|---|---|
plc_ip_address |
string |
The IP address of the Beckhoff PLC. |
plc_ams_net_id |
string |
The AMS NetID of the target PLC (e.g., "192.168.1.1.1.1"). |
local_ams_net_id |
string |
The AMS NetID of the computer running ROS. |
plc_ams_port |
string |
The AMS Port of the PLC runtime (e.g., "851"). |
For each <state_interface>
and <command_interface>
, you must provide parameters that link it to a PLC variable.
Parameter | Type | Description |
---|---|---|
PLC_symbol |
string |
The full symbolic name of the variable in the PLC (e.g., "MAIN.Joint_Pos_State"). |
PLC_type |
string |
The data type of the PLC variable (e.g., "LREAL", "BOOL", "DINT"). Case-insensitive. |
n_elements |
integer |
(Optional) The number of elements if the symbol is an array. Defaults to 1. |
index |
integer |
(Optional) The index within the PLC array that this interface corresponds to. Defaults to 0. |
initial_value |
double |
(Optional, Command Only) The initial value for a command interface before the first command is received. |
The following PLC data types are supported and are automatically converted to and from double
values.
LREAL
,REAL
BOOL
DINT
,UDINT
INT
,UINT
SINT
,USINT
BYTE
In this accompanying package is an example of how to configure the hardware interface in a URDF file for a 6-axis robot and a digital output.
Feel free to contribute on any of these!
The ADS protocol supports asynchronous callbacks, where the PLC can push a variable update to the client ("notifications"). We plan to add a mechanism to register for these notifications directly from the URDF. This will allow state interfaces for rarely updated variables to be updated via callbacks instead of being polled in every read()
cycle, further optimizing the main control loop.
We plan to add support for reading PLC STRING
variables. As ros2_control
state interfaces are numeric, this would likely be exposed through a separate mechanism, such as publishing to a ROS topic, for monitoring purposes.
We may investigate adding support for reading and writing to user-defined structures (DUTs) on the PLC. This would allow for more complex data to be exchanged in a single, structured block. However, this is a complex feature and is considered a low-priority research item.
This ads_vendor package was created by B-Robotized GmbH and is provided under the Apache 2.0 License.
The vendored Beckhoff ADS library is subject to its own license, which can be found in its repository.