[Documentation] [TitleIndex] [WordIndex

(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

How to run pr2_etherCAT

Description: How to run pr2_etherCAT for non-typical setups.

Tutorial Level: INTERMEDIATE

Introduction

If you are working with a PR2 or Texai, there is already a launch file that does what you want. However, if you are working on a new type of robot or a non-standard setup, you may find this tutorial useful.

Get pr2_etherCAT

On ROS Electric, get pr2_etherCAT by installing the ros-electric-pr2-robot

On ROS Fuerte, get pr2_etherCAT by installing ros-fuerte-pr2-robot

Create Minimal URDF

pr2_etherCAT needs a description of the robot (URDF) to run properly. The URDF tutorials provide an explanation of the robot description. However, a minimal description can be used on any type of robot.

Copy the following into a file called robot.xml. The file can be put anywhere, but for simplicity put it in your home directory.

NOTE: The above description does not provide enough information to allow most controllers to execute.

Determine Ethernet interface

pr2_etherCAT needs to be given the Ethernet interface that the EtherCAT devices are connected to. In Linux, Ethernet interfaces are usually named ethX where X is a number (ie eth0). On the PR2, the EtherCAT interface is named ecat0.

First figure out what network interfaces your computer has. The -a option will show you all the interfaces, whether or not they are enabled.

This will provide a list like the following :

This above computer has two Ethernet interfaces : eth0 and eth1 and lo. lo is a virtual loop-back device, ignore it.

At this point you might be trial and error to figure which Ethernet interface to use. However, there is another trick that may help. Usually, when an Ethernet port becomes connect or disconnected, a kernel message is generated. Try disconnecting/reconnecting an Ethernet port and then look at the end of the kernal log messages to determine which port was connected/disconnected.

The above command will produce a lot of output, but you probably only care about the stuff that occurred near or at the end.

As you can see, eth1 was just disconnected and reconnected.

Run pr2_etherCAT

If it is not already running, start the ROS core in a new terminal.

pr2_etherCAT needs to be run with root permissions. Using sudo doesn't work because pr2_etherCAT can't find the necessary linked libraries. There are a couple ways to run with extra privileges:

  1. Use pr2-grant
  2. Run pr2_etherCAT as root

pr2-grant

pr2-grant is similar to sudo in that it provides special privileges to some other program. Unlike sudo, pr2-grant will not mess up the library path that ROS uses. Unfortunately, you need to compile and setup pr2-grant yourself.

Get libcap:

Checkout,compile,pr2-grant:

Install pr2-grant. pr2-grant needs to be owned by root and have the suid bit set. It is also the most convenient when put on the system path.

Running pr2-etherCAT using pr2-grant:

run as root

Running pr2_etherCAT as root is less preferable to using pr2-grant. bash as root and re-source the ROS setup script before running pr2_etherCAT.

pr2_etherCAT arguments

Here is a quick breakdown of the arguments given to pr2_etherCAT:

If the minimal robot description was used, a some warning messages will be generated.

Looking at Diagnostics

pr2_etherCAT publishes a lot of information to the diagnostic topic. Looking at the diagnostics output is an easy way so see pr2_etherCAT working. The runtime_monitior provides an easy way to watch data on the /diagnostics topic.

Get runtime_monitor package from diagnostics_monitors :

On ROS Electric:

On ROS Fuerte:

Run:

You should see a that looks something like:

In the above screen-shot there are three different diagnostics sub-topics:

All three of these topics are produced by pr2_etherCAT. When a sub-topic is selected on the left side of the window, its diagnostic output is shown on the right side.

For more information on diagnostics look at diagnostics.

Troubleshooting


2019-10-19 13:01