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. |
Using NetFT plugin with pr2_etherCAT
Description: Configuring and using NetFT plugin with pr2_etherCATKeywords: NetFT, force-torque, ethercat_hardware
Tutorial Level: INTERMEDIATE
Contents
These instructions only apply to the alpha prototypes of the Force-Torque sensors that needed an external NetFT conversion box. PR2 with the force-torque sensors integrated into the grippers should follow the WG035 instructions instead.
Introduction
NetFT plugin allows force-torque data from NetFT sensor to be used by realtime controllers at 1000Hz rate. The plugin depends on new feature of pr2_ethercat_drivers from truck. Unfortunately this feature is not yet released, so an overlay of pr2_ethercat_drivers and pr2_etherCAT need to be used.
Getting Started
The best way to get started is to first go through the tutorial on running the NetFT node.
Getting overlay (ROS diamondback only)
New in Electric For ROS Electric no overlay is needed, skip the following steps.
The loading non-EtherCAT devices as realtime_loop plugins is not supported in ROS diamondback. So an overlay for pr2_robot and pr2_ethercat_drivers is needed.
Get ROS diamondback with pr2 specific packages.
sudo apt-get install ros-unstable-pr2
Create netft.rosinstall file with following information:
- svn: {local-name: netft, uri: 'https://code.ros.org/svn/wg-ros-pkg/stacks/netft/trunk'} - svn: {local-name: pr2_ethercat_drivers, uri: 'https://code.ros.org/svn/wg-ros-pkg/stacks/pr2_ethercat_drivers/trunk'} - svn: {local-name: pr2_mechanism, uri: 'https://code.ros.org/svn/wg-ros-pkg/stacks/pr2_mechanism/trunk'} - svn: {local-name: pr2_etherCAT, uri: 'https://code.ros.org/svn/wg-ros-pkg/stacks/pr2_robot/trunk/pr2_etherCAT'} - svn: {local-name: pr2_controllers, uri: 'https://code.ros.org/svn/wg-ros-pkg/stacks/pr2_controllers/trunk'}
Then use rosinstall to create overlay in ~/netft
rosinstall ~/ros-netft /opt/ros/unstable netft.rosinstall
Source new setup script and try locating netft stack.
source ~/ros-netft/setup.sh
Make sure netft stack is found:
rosstack find netft
You should see something like
/home/username/ros-netft/netft
Also make sure new overlay of pr2_ethercat_drivers is found in right place:
svn info `rosstack find pr2_ethercat_drivers` | grep URL
You should see something like:
URL: https://code.ros.org/svn/wg-ros-pkg/stacks/pr2_ethercat_drivers/trunk
Compile:
rosmake netft pr2_etherCAT pr2_ethercat_drivers pr2_mechanism pr2_controllers
non_ethercat_devices
Since NetFT is not an EtherCAT device, you must explicitly tell pr2_etherCAT to load netft_ethercat_hardware by using rosparams. For each non-ethercat device you want to add an element to the rosparam /pr2_etherCAT/non_ethercat_devices The element name can be anything however it is best if the name is descriptive. The element should also have a number of attributes:
type : attribute is used to determine what driver plugin to load. The type for the NetFT sensor should be NetFT
address : The IP address of the board. Probably 10.68.0.60 on PR2. Or 192.168.1.1 if you are using a brand new device.
analog_in_name : name to register AnalogIn with. The same name should be use by realtime controllers requesting AnalogIn.
ros_publish_period : As well as providing data to realtime controllers, driver also publishes force/torque data to ROS. This value controls the rate data is published to ROS. Note : new data is always available to realtime controllers at realtime loop rate (1000Hz).
There is an example roslaunch file (netft_ethercat_hardware/example.launch) that you can use as a reference for setting up the correct ROS parameters.
example.launch
<launch> <group ns="pr2_etherCAT/non_ethercat_devices"> <rosparam> netft1: type: NetFT address: 192.168.1.1 analog_in_name: force_torque_1 ros_publish_period: 0.01 </rosparam> </group> </launch>
Next ROS release (currently unstable)
In the next ROS release, the type is changing from NetFT to netft_ethercat_hardware/NetFT.
<launch> <group ns="pr2_etherCAT/non_ethercat_devices"> <rosparam> netft1: type: netft_ethercat_hardware/NetFT address: 192.168.1.1 analog_in_name: force_torque_1 ros_publish_period: 0.01 </rosparam> </group> </launch>
Using older Wrench instead of WrenchStamped
In next ROS release (and unstable), the normal geometry_msgs::Wrench is being replaced by geometery_msg::WrenchStamped. However, the Wrench message type can still be used by adding publish_wrench: True to the rosparams.
<launch> <group ns="pr2_etherCAT/non_ethercat_devices"> <rosparam> netft1: type: NetFT address: 192.168.1.1 analog_in_name: force_torque_1 ros_publish_period: 0.01 publish_wrench: True </rosparam> </group> </launch>
Running NetFT plugin with PR2
For NetFT to load, you will need to have non_ethercat_devices defined before running pr2_etherCAT.
Make new file called pr2-netft.launch with the following text:
<launch> <include file="/etc/ros/diamondback/robot.launch"/> <group ns="pr2_etherCAT/non_ethercat_devices"> <rosparam> netft1: type: NetFT address: 10.68.0.60 analog_in_name: force_torque_1 ros_publish_period: 0.01 </rosparam> </group> </launch>
Launch the robot
roslaunch pr2-netft.launch
Use pr2_dashboard use view robot diagnostics. Look for "NetFT RDT Driver" entry under "Other" section.
Using data in realtime controllers
The netft_example_controllers package contains tutorials on writing and running a controller that uses data from this plugin.