Difference between revisions of "Hello Robot"

Jump to: navigation , search
(Echo a ROS Topic)
(Setup ROS Environment)
 
(16 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__NOTOC__
 
 
 
<div class="title-block">
 
<div class="title-block">
 
You've set up your Robot and the Development PC. This page will show you how to communicate with the robot, moving the arms, and allowing him to say "Hello!" to your lab
 
You've set up your Robot and the Development PC. This page will show you how to communicate with the robot, moving the arms, and allowing him to say "Hello!" to your lab
 
</div>
 
</div>
 +
 +
{{TOClimit|limit=2}}
  
 
<div class="content-block">
 
<div class="content-block">
Line 14: Line 14:
 
<div class="content-block">
 
<div class="content-block">
  
== Step 1: Setup ROS Environment ==
+
== Setup ROS Environment ==
 
Upon compilation of our [http://wiki.ros.org/catkin/workspaces catkin workspace], the generated <code>devel</code> folder in the root of our catkin workspace will contain a setup script which informs the ROS environment of our compiled catkin workspace and the packages therein. The root of the catkin workspace that we created is located at <code>~/ros_ws</code>.
 
Upon compilation of our [http://wiki.ros.org/catkin/workspaces catkin workspace], the generated <code>devel</code> folder in the root of our catkin workspace will contain a setup script which informs the ROS environment of our compiled catkin workspace and the packages therein. The root of the catkin workspace that we created is located at <code>~/ros_ws</code>.
  
Line 24: Line 24:
 
If the <code>devel</code> folder is not available in the root of your catkin_ws, your catkin/ROS workspace (~/ros_ws) is not yet compiled:
 
If the <code>devel</code> folder is not available in the root of your catkin_ws, your catkin/ROS workspace (~/ros_ws) is not yet compiled:
  
ROS Indigo
+
<tabs>
 
+
<tab name="ROS Kinetic">
 +
<syntaxhighlight lang="bash" enclose="div">
 +
$ source /opt/ros/kinetic/setup.bash
 +
$ catkin_make
 +
</syntaxhighlight>
 +
</tab>
 +
<tab name="ROS Indigo">
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
 
$ source /opt/ros/indigo/setup.bash
 
$ source /opt/ros/indigo/setup.bash
 
$ catkin_make
 
$ catkin_make
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
</tab>
 +
</tabs>
  
  
 
=== Source ROS Environment Setup Script ===
 
=== Source ROS Environment Setup Script ===
  
Baxter.sh ROS Environment Setup
+
Intera.sh ROS Environment Setup
  
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
# Source baxter.sh script
+
# Source intera.sh script
$ . baxter.sh
+
$ ./intera.sh
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 46: Line 54:
 
<div class="content-block">
 
<div class="content-block">
  
== Step 2: Verify ROS Connectivity ==
+
== Verify ROS Connectivity ==
  
In this step, we will verify communication to and from Baxter and our development workstation.
+
In this step, we will verify communication to and from Sawyer and our development workstation.
  
 
=== Verify ROS Master Ping ===
 
=== Verify ROS Master Ping ===
The development workstation must be able to resolve the [http://wiki.ros.org/Master ROS Master] (running on Baxter). This is defined by the ROS_MASTER_URI which has been set. This ROS_MASTER_URI is typically the [[Robot_Hostname | ROBOT_HOSTNAME]] configured (your [[Serial_Number | robot serial number]] by default).
+
The development workstation must be able to resolve the [http://wiki.ros.org/Master ROS Master] (running on Sawyer). This is defined by the ROS_MASTER_URI which has been set. This ROS_MASTER_URI is typically the [[Robot_Hostname | ROBOT_HOSTNAME]] configured (your Sawyer Controller Box Serial Number by default).
 
   
 
   
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
Line 73: Line 81:
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
 
$ rostopic list
 
$ rostopic list
</syntaxhighlight>
 
 
=== Verify Development Workstation Ping ===
 
We have verified communication from the development pc to the robot. Now we will SSH to Baxter and verify communication from Baxter to the development PC.
 
 
Baxter must be able to resolve ROS_IP or ROS_HOSTNAME (only one should be set) which has been set.
 
 
Identify your ROS_IP or ROS_HOSTNAME set ([[Workstation_Setup#Step_4:_Configure_Baxter_Communication.2FROS_Workspace | ROS_IP was previously recommended]]):
 
 
====ROS_IP====
 
 
<syntaxhighlight lang="bash" enclose="div">
 
# Identify your ROS_IP
 
$ env | grep ROS_IP
 
</syntaxhighlight>
 
 
The result (example):
 
<code>ROS_IP=192.168.101.99</code>
 
 
<code>192.168.101.99</code> in this case is the IP address which must be resolvable to Baxter and all other ROS processes.
 
 
====ROS_HOSTNAME====
 
 
<syntaxhighlight lang="bash" enclose="div">
 
# Identify your ROS_HOSTNAME
 
$ env | grep ROS_HOSTNAME
 
</syntaxhighlight>
 
 
The result (example):
 
<code>ROS_HOSTNAME=yoda</code>
 
 
<code>yoda</code> in this case is the Hostname which must be resolvable to Baxter and all other ROS processes.
 
 
 
We will now SSH to Baxter and verify the ability to communicate with this development PC. For SSH access, please use the ROS Master (ROBOT_HOSTNAME) identified above.
 
<syntaxhighlight lang="bash" enclose="div">
 
$ ssh ruser@<our ROS Master>
 
 
# Password: rethink
 
 
# Example:
 
$ ssh ruser@011303P0017.local
 
 
# Now that we have SSH'd into the robot, verify that we are able to ping back to the development PC
 
ruser@p99 ~ $ ping <ROS_IP/ROS_HOSTNAME>
 
 
# Examples:
 
# ROS_IP
 
ruser@p99 ~ $ ping 192.168.101.99
 
# ROS_HOSTNAME
 
ruser@p99 ~ $ ping yoda
 
</syntaxhighlight>
 
 
We can now exit our SSH session on the robot:
 
<syntaxhighlight lang="bash" enclose="div">
 
ruser@p99 ~ $ exit
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
=== Echo a ROS Topic ===
 
=== Echo a ROS Topic ===
Now that we have seen the available [http://wiki.ros.org/rostopic rostopics], and have verified communication to and from Baxter and our development PC, we can connect to and echo the contents being published to a chosen topic:
+
Now that we have seen the available [http://wiki.ros.org/rostopic rostopics], and have verified communication to and from Sawyer and our development PC, we can connect to and echo the contents being published to a chosen topic:
  
 
Double check that our workspace is still configured correctly:
 
Double check that our workspace is still configured correctly:
  
====Baxter.sh ROS Environment Setup====
+
====intera.sh ROS Environment Setup====
  
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
 
$ cd ~/ros_ws
 
$ cd ~/ros_ws
$ . baxter.sh
+
$ ./intera.sh
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 149: Line 101:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Echo Baxter's [http://docs.ros.org/api/sensor_msgs/html/msg/JointState.html joint_states]
+
Echo Sawyer's [http://docs.ros.org/api/sensor_msgs/html/msg/JointState.html joint_states]
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
 
$ rostopic echo /robot/joint_states
 
$ rostopic echo /robot/joint_states
 
</syntaxhighlight>
 
</syntaxhighlight>
  
You should see a continuous stream of Baxter's joint names with measured positions, velocities and torques.
+
You should see a continuous stream of Sawyer's joint names with measured positions, velocities and torques.
  
All is well! You have successfully setup communication between your development PC and Baxter.
+
All is well! You have successfully setup communication between your development PC and Sawyer.
  
 
</div>
 
</div>
Line 162: Line 114:
 
<div class="content-block">
 
<div class="content-block">
  
== Step 3: Enable the Robot ==
+
== Enable the Robot ==
A fundamental tool for use when working with Baxter, the enable_robot tool, provided in the baxter_tools SDK package, allows for enabling/disabling/resetting/stopping the robot. Baxter must be enabled in order to actively command any of the motors.
+
A fundamental tool for use when working with Sawyer, the enable_robot tool, provided in the intera_interface SDK package, allows for enabling/disabling/resetting/stopping the robot. While Sawyer is enabled by default when it boots, it is possible to enable it from the commandline which is required after an E-STOP press.  Sawyer must be enabled in order to actively command any of the motors.
  
 
Enable the robot:
 
Enable the robot:
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
$ rosrun baxter_tools enable_robot.py -e
+
$ rosrun intera_interface enable_robot.py -e
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Baxter will now be enabled. The joints will be powered, and Baxter will hold his current joint positions with in a position control loop.
+
Sawyer will now be enabled (if it wasn't already). The joints will be powered, and Sawyer will hold his current joint positions with in a position control loop.
 
 
Grabbing Baxter's cuff:
 
  
[[File:Cuff_grasp.png]]
 
  
Enters Baxter's arms into "Zero-G" mode. The position control loop will be released with solely gravity compensation enabled. This allows for intuitive hand-over-hand guidance of the limbs throughout the workspace.
+
Enters Sawyer's arm into "Zero-G" mode. The position control loop will be released with solely gravity compensation enabled. This allows for intuitive hand-over-hand guidance of the limb throughout the workspace.
  
 
</div>
 
</div>
Line 182: Line 131:
 
<div class="content-block">
 
<div class="content-block">
  
== Step 4: Run an Example Program ==
+
== Run an Example Program ==
A number of Baxter [[Example_Programs | example programs]] are provided which use the baxter_interface package which contains Python modules for Baxter Research Robot development.
+
A number of Sawyer [[Tutorials|example programs]] are provided which use the intera_interface package which contains Python modules for Sawyer Research Robot development.
  
 
Run an example program:
 
Run an example program:
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
$ rosrun baxter_examples joint_velocity_wobbler.py
+
$ rosrun intera_examples joint_torque_springs.py
 
</syntaxhighlight>
 
</syntaxhighlight>
  
This example will simply move the arms to a neutral position, enter into velocity control mode, moving each joint through a random sinusoidal motion. More about this example on the [[Wobbler_Example | Joint Velocity Wobbler Example Page]].
+
This example will simply move the arms to a neutral position, enter into velocity control mode, moving each joint through a random sinusoidal motion. More about this example on the [[Joint Torque Springs Example | Joint Torque Springs Example Page]].
  
 
</div>
 
</div>
Line 196: Line 145:
 
<div class="content-block">
 
<div class="content-block">
  
== Step 5: Interactively Program Baxter ==
+
== Interactively Program Sawyer ==
Time to program Baxter! We will now use an interactive [https://docs.python.org/2/tutorial/interpreter.html#interactive-mode Python Shell] to programmatically move the arms.
+
Time to program Sawyer! We will now use an interactive [https://docs.python.org/2/tutorial/interpreter.html#interactive-mode Python Shell] to programmatically move the arms.
  
Make sure Baxter is enabled:
+
Make sure Sawyer is enabled:
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
$ rosrun baxter_tools enable_robot.py -e
+
$ rosrun intera_interface enable_robot.py -e
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 213: Line 162:
 
>>> import rospy
 
>>> import rospy
  
# baxter_interface - Baxter Python API
+
# intera_interface - Sawyer Python API
>>> import baxter_interface
+
>>> import intera_interface
  
 
# initialize our ROS node, registering it with the Master
 
# initialize our ROS node, registering it with the Master
>>> rospy.init_node('Hello_Baxter')
+
>>> rospy.init_node('Hello_Sawyer')
  
# create an instance of baxter_interface's Limb class
+
# create an instance of intera_interface's Limb class
>>> limb = baxter_interface.Limb('right')
+
>>> limb = intera_interface.Limb('right')
  
 
# get the right limb's current joint angles
 
# get the right limb's current joint angles
Line 226: Line 175:
  
 
# print the current joint angles
 
# print the current joint angles
 +
>>> print angles
 +
 +
# move to neutral pose
 +
>>> limb.move_to_neutral()
 +
 +
# get the right limb's current joint angles now that it is in neutral
 +
>>> angles = limb.joint_angles()
 +
 +
# print the current joint angles again
 
>>> print angles
 
>>> print angles
  
 
# reassign new joint angles (all zeros) which we will later command to the limb
 
# reassign new joint angles (all zeros) which we will later command to the limb
>>> angles['right_s0']=0.0
+
>>> angles['right_j0']=0.0
>>> angles['right_s1']=0.0
+
>>> angles['right_j1']=0.0
>>> angles['right_e0']=0.0
+
>>> angles['right_j2']=0.0
>>> angles['right_e1']=0.0
+
>>> angles['right_j3']=0.0
>>> angles['right_w0']=0.0
+
>>> angles['right_j4']=0.0
>>> angles['right_w1']=0.0
+
>>> angles['right_j5']=0.0
>>> angles['right_w2']=0.0
+
>>> angles['right_j6']=0.0
  
 
# print the joint angle command
 
# print the joint angle command
Line 243: Line 201:
 
>>> limb.move_to_joint_positions(angles)
 
>>> limb.move_to_joint_positions(angles)
  
# Baxter wants to say hello, let's wave the arm
+
# Sawyer wants to say hello, let's wave the arm
  
 
# store the first wave position  
 
# store the first wave position  
>>> wave_1 = {'right_s0': -0.459, 'right_s1': -0.202, 'right_e0': 1.807, 'right_e1': 1.714, 'right_w0': -0.906, 'right_w1': -1.545, 'right_w2': -0.276}
+
>>> wave_1 = {'right_j6': -1.5126, 'right_j5': -0.3438, 'right_j4': 1.5126, 'right_j3': -1.3833, 'right_j2': 0.03726, 'right_j1': 0.3526, 'right_j0': -0.4259}
  
 
# store the second wave position
 
# store the second wave position
>>> wave_2 = {'right_s0': -0.395, 'right_s1': -0.202, 'right_e0': 1.831, 'right_e1': 1.981, 'right_w0': -1.979, 'right_w1': -1.100, 'right_w2': -0.448}
+
>>> wave_2 = {'right_j6': -1.5101, 'right_j5': -0.3806, 'right_j4': 1.5103, 'right_j3': -1.4038, 'right_j2': -0.2609, 'right_j1': 0.3940, 'right_j0': -0.4281}
 +
 
  
 
# wave three times
 
# wave three times
 
>>> for _move in range(3):
 
>>> for _move in range(3):
 
...    limb.move_to_joint_positions(wave_1)
 
...    limb.move_to_joint_positions(wave_1)
 +
...    rospy.sleep(0.5)
 
...    limb.move_to_joint_positions(wave_2)
 
...    limb.move_to_joint_positions(wave_2)
 +
...    rospy.sleep(0.5)
  
  
Line 265: Line 226:
  
 
</div>
 
</div>
 
<div class="content-block">
 
 
== Next Steps ==
 
 
'''You've done it!''' Now that you've successfully completed the installation guide, there is much more to learn.
 

Latest revision as of 20:25, 16 October 2017

You've set up your Robot and the Development PC. This page will show you how to communicate with the robot, moving the arms, and allowing him to say "Hello!" to your lab

Required Hardware

Setup ROS Environment

Upon compilation of our catkin workspace, the generated devel folder in the root of our catkin workspace will contain a setup script which informs the ROS environment of our compiled catkin workspace and the packages therein. The root of the catkin workspace that we created is located at ~/ros_ws.

# Move to root of our catkin workspace
$ cd ~/ros_ws

If the devel folder is not available in the root of your catkin_ws, your catkin/ROS workspace (~/ros_ws) is not yet compiled:

$ source /opt/ros/kinetic/setup.bash
$ catkin_make
$ source /opt/ros/indigo/setup.bash
$ catkin_make


Source ROS Environment Setup Script

Intera.sh ROS Environment Setup

# Source intera.sh script
$ ./intera.sh


Verify ROS Connectivity

In this step, we will verify communication to and from Sawyer and our development workstation.

Verify ROS Master Ping

The development workstation must be able to resolve the ROS Master (running on Sawyer). This is defined by the ROS_MASTER_URI which has been set. This ROS_MASTER_URI is typically the ROBOT_HOSTNAME configured (your Sawyer Controller Box Serial Number by default).

# Identify the ROS Master location
$ env | grep ROS_MASTER_URI

The result (example): ROS_MASTER_URI=http://011303P0017.local:11311 011303P0017.local in this case is the location of our ROS Master. The development PC must be able to resolve and communicate with this Master.

Verify ability ping our ROS Master:

$ ping <our ROS Master>
# Example
$ ping 011303P0017.local

View Available ROS Topics

Now that we have identified our ROS Master is available on our network, lets view the available rostopics:

$ rostopic list

Echo a ROS Topic

Now that we have seen the available rostopics, and have verified communication to and from Sawyer and our development PC, we can connect to and echo the contents being published to a chosen topic:

Double check that our workspace is still configured correctly:

intera.sh ROS Environment Setup

$ cd ~/ros_ws
$ ./intera.sh

Standard bashrc ROS Environment Setup

$ cd ~/ros_ws
$ source devel/setup.bash

Echo Sawyer's joint_states

$ rostopic echo /robot/joint_states

You should see a continuous stream of Sawyer's joint names with measured positions, velocities and torques.

All is well! You have successfully setup communication between your development PC and Sawyer.

Enable the Robot

A fundamental tool for use when working with Sawyer, the enable_robot tool, provided in the intera_interface SDK package, allows for enabling/disabling/resetting/stopping the robot. While Sawyer is enabled by default when it boots, it is possible to enable it from the commandline which is required after an E-STOP press. Sawyer must be enabled in order to actively command any of the motors.

Enable the robot:

$ rosrun intera_interface enable_robot.py -e

Sawyer will now be enabled (if it wasn't already). The joints will be powered, and Sawyer will hold his current joint positions with in a position control loop.


Enters Sawyer's arm into "Zero-G" mode. The position control loop will be released with solely gravity compensation enabled. This allows for intuitive hand-over-hand guidance of the limb throughout the workspace.

Run an Example Program

A number of Sawyer example programs are provided which use the intera_interface package which contains Python modules for Sawyer Research Robot development.

Run an example program:

$ rosrun intera_examples joint_torque_springs.py

This example will simply move the arms to a neutral position, enter into velocity control mode, moving each joint through a random sinusoidal motion. More about this example on the Joint Torque Springs Example Page.

Interactively Program Sawyer

Time to program Sawyer! We will now use an interactive Python Shell to programmatically move the arms.

Make sure Sawyer is enabled:

$ rosrun intera_interface enable_robot.py -e

Start an Interactive Python Shell:

$ python

# Import the necessary Python modules

# rospy - ROS Python API
>>> import rospy

# intera_interface - Sawyer Python API
>>> import intera_interface

# initialize our ROS node, registering it with the Master
>>> rospy.init_node('Hello_Sawyer')

# create an instance of intera_interface's Limb class
>>> limb = intera_interface.Limb('right')

# get the right limb's current joint angles
>>> angles = limb.joint_angles()

# print the current joint angles
>>> print angles

# move to neutral pose
>>> limb.move_to_neutral()

# get the right limb's current joint angles now that it is in neutral
>>> angles = limb.joint_angles()

# print the current joint angles again
>>> print angles

# reassign new joint angles (all zeros) which we will later command to the limb
>>> angles['right_j0']=0.0
>>> angles['right_j1']=0.0
>>> angles['right_j2']=0.0
>>> angles['right_j3']=0.0
>>> angles['right_j4']=0.0
>>> angles['right_j5']=0.0
>>> angles['right_j6']=0.0

# print the joint angle command
>>> print angles

# move the right arm to those joint angles
>>> limb.move_to_joint_positions(angles)

# Sawyer wants to say hello, let's wave the arm

# store the first wave position 
>>> wave_1 = {'right_j6': -1.5126, 'right_j5': -0.3438, 'right_j4': 1.5126, 'right_j3': -1.3833, 'right_j2': 0.03726, 'right_j1': 0.3526, 'right_j0': -0.4259}

# store the second wave position
>>> wave_2 = {'right_j6': -1.5101, 'right_j5': -0.3806, 'right_j4': 1.5103, 'right_j3': -1.4038, 'right_j2': -0.2609, 'right_j1': 0.3940, 'right_j0': -0.4281}


# wave three times
>>> for _move in range(3):
...     limb.move_to_joint_positions(wave_1)
...     rospy.sleep(0.5)
...     limb.move_to_joint_positions(wave_2)
...     rospy.sleep(0.5)


# quit
>>> quit()


Congratulations! You have successfully completed the installation tutorials!