ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

ROS connection to Siemens PLC

asked 2021-08-24 07:41:53 -0500

AxelD gravatar image

Hello everybody!

I need some help. The situation: An automated guided vihicle is controlled by an Siemens PLC (ET200SP) but we want to add a LIDAR to the system for navigation. We want this LIDAR to connect to a Raspberry Pi4 8Gb that runs ROS and calculate the direction en velocity (in the future it wil be a IPC). The data dat the ROS system calculates needs to be send to the PLC in de AGV. The phisical connection between the PLC and the Raspberry Pi is estableshed via a utp cable.

Question: What protocol can I use best to send data from ROS to the PLC? What packages do I need? Or is it better to switch to ROS2? Has this been done before?

Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-08-24 08:53:25 -0500

crnewton gravatar image

You can use the interfaces available in ROS/ on the PLC. Modbus is a good option for your usecase. I had a similar setup but we choose TCP/IP and created a ROS node that would start a TCP/IP client on launch. Then the node is just sending data to PLC, and publishing received (from PLC) data on a topic.

edit flag offensive delete link more

Comments

Is it possible to send me some information about connecting ROS via TCP/IP to a PLC?

AxelD gravatar image AxelD  ( 2021-08-25 02:10:54 -0500 )edit

I'm not @crnewton, but I'm sort-of assuming he's suggesting using a custom protocol between your ROS node and your PLC. In that case, it would just come down to using standard TCP/IP sockets and coming up with a (de)serialisation scheme (ie: a protocol) which works efficiently on both the ROS-side and the PLC, and implementing it.

However, if your PLC supports something like modbus, ethernet/ip or opc-ua, you may want to look for OSS libraries which support those. For Modbus there are definitely ROS packages (bitmeal/ros-modbus-device-driver for instance). For ethernet/ip there are at least Python libraries available and opc-ua has both plain Python libraries (such as FreeOpcUa/python-opcua) and a (relatively simple) ROS wrapper.

Whether this is all worth it will depend on the type of data you want to exchange.

..

gvdhoorn gravatar image gvdhoorn  ( 2021-08-25 02:16:19 -0500 )edit

.. simple bits are almost always possible. But ROS messages typically carry higher-level abstractions, which would not be very efficient to transmit using individual bits.

For things like velocity and direction, you'll probably want to switch to (at least) integers and floats. What maps best to your PLC and application is not something we can say I believe.

re: ROS 2: I've also seen some people working on a ROS 2 <-> OPC-UA generic mapping/mapper, but I can't remember where exactly. Might be worth a look as well.


Edit: just remembered there are also things like python-snap7 and snap7. You could use those and write a simple wrapper ROS node.

gvdhoorn gravatar image gvdhoorn  ( 2021-08-25 02:20:44 -0500 )edit

The PLC does support modbus, ethernet/ip and opc-ua. I think the best connection is ethernet/ip (TCP/IP). Because if I don't need extra Python libraries, then TCP/IP is better. Do you have some information about connecting Python script via TCP/IP to a PLC?

The type of data I want to send is basic bits, bytes, words, int, reals.

Thank you!

AxelD gravatar image AxelD  ( 2021-08-25 02:49:25 -0500 )edit

EtherNet/IP != plain TCP/IP.

It's a special, software defined fieldbus.

Do you have some information about connecting Python script via TCP/IP to a PLC?

if you really want to go with plain TCP/IP, any tutorial about "networking" or "tcp sockets" would do.

Personally, I would probably use one of the mentioned libraries for fieldbuses, as it would then come down to (a variant of) figuring out which coil/register/field to write to and using the fieldbus library. Instead of starting from scratch and having to do all of that yourself.

gvdhoorn gravatar image gvdhoorn  ( 2021-08-25 02:53:37 -0500 )edit

Oh I thought they were the same. Sorry my bad! So you recommend a fieldbus to be a better solution then what I said. Then I will use opc-ua because modbus is quite old, I think.

So to get a connection working between PLC and ROS: Install ROS on raspberry PI, then install a opc-ua library for Python.

@gvdhoorn u said:

ROS 2: I've also seen some people working on a ROS 2 <-> OPC-UA generic mapping/mapper, but I can't remember where exactly. Might be worth a look as well. Edit: just remembered there are also things like python-snap7 and snap7. You could use those and write a simple wrapper ROS node."

Are u suggesting that its better to use ROS2 for this problem?

AxelD gravatar image AxelD  ( 2021-08-25 03:24:41 -0500 )edit

Are u suggesting that its better to use ROS2 for this problem?

no, not at all.

Unless your PLC is ROS 2 compatible or you find a ROS 2 package which already wraps one of your targetted fieldbuses, your question is not ROS specific, so there is no real advantage to using one or the other.

Then I will use opc-ua because modbus is quite old, I think.

You might be looking for the words established or mature. Are there advantages to OPC-UA compared to modbus? Certainly. But I don't believe the age of a technology necessarily matters here.

Note that any of the Snap7 libraries allow you to use the native (remote) interfaces of your Siemens PLC. Any other fieldbus will always be (internally) mapped to Siemens "concepts".

gvdhoorn gravatar image gvdhoorn  ( 2021-08-25 03:30:11 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-08-24 07:41:53 -0500

Seen: 1,196 times

Last updated: Aug 24 '21