(Created page with "<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 ...") |
(→Setup ROS Environment) |
||
(21 intermediate revisions by 3 users not shown) | |||
Line 2: | Line 2: | ||
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"> | ||
== Required Hardware == | == Required Hardware == | ||
Line 7: | Line 11: | ||
* 1 Development Workstation (Meeting [[System_requirements | Minimum System Requirements]]) | * 1 Development Workstation (Meeting [[System_requirements | Minimum System Requirements]]) | ||
+ | </div> | ||
<div class="content-block"> | <div class="content-block"> | ||
− | == | + | == 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 18: | Line 23: | ||
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: | ||
+ | |||
<tabs> | <tabs> | ||
− | <tab name="ROS | + | <tab name="ROS Kinetic"> |
<syntaxhighlight lang="bash" enclose="div"> | <syntaxhighlight lang="bash" enclose="div"> | ||
− | $ source /opt/ros/ | + | $ source /opt/ros/kinetic/setup.bash |
$ catkin_make | $ catkin_make | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</tab> | </tab> | ||
− | <tab name="ROS | + | <tab name="ROS Indigo"> |
<syntaxhighlight lang="bash" enclose="div"> | <syntaxhighlight lang="bash" enclose="div"> | ||
− | $ source /opt/ros/ | + | $ source /opt/ros/indigo/setup.bash |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
$ catkin_make | $ catkin_make | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</tab> | </tab> | ||
</tabs> | </tabs> | ||
+ | |||
=== Source ROS Environment Setup Script === | === Source ROS Environment Setup Script === | ||
− | + | ||
− | + | Intera.sh ROS Environment Setup | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="bash" enclose="div"> | <syntaxhighlight lang="bash" enclose="div"> | ||
− | # Source | + | # Source intera.sh script |
− | $ | + | $ ./intera.sh |
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
</div> | </div> | ||
Line 62: | Line 54: | ||
<div class="content-block"> | <div class="content-block"> | ||
− | == | + | == Verify ROS Connectivity == |
− | In this step, we will verify communication to and from | + | 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 | + | 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 91: | Line 83: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | === Echo a ROS 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: | |
− | + | ====intera.sh ROS Environment Setup==== | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="bash" enclose="div"> | <syntaxhighlight lang="bash" enclose="div"> | ||
− | + | $ cd ~/ros_ws | |
− | $ | + | $ ./intera.sh |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | $ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | === | + | ====Standard bashrc ROS Environment Setup==== |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="bash" enclose="div"> | <syntaxhighlight lang="bash" enclose="div"> | ||
$ cd ~/ros_ws | $ cd ~/ros_ws | ||
$ source devel/setup.bash | $ source devel/setup.bash | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | Echo | + | 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 | + | 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 | + | All is well! You have successfully setup communication between your development PC and Sawyer. |
</div> | </div> | ||
Line 179: | Line 114: | ||
<div class="content-block"> | <div class="content-block"> | ||
− | == | + | == Enable the Robot == |
− | A fundamental tool for use when working with | + | 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 | + | $ rosrun intera_interface enable_robot.py -e |
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | 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 | + | 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 199: | Line 131: | ||
<div class="content-block"> | <div class="content-block"> | ||
− | == | + | == Run an Example Program == |
− | A number of | + | 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 | + | $ 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 [[ | + | 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 213: | Line 145: | ||
<div class="content-block"> | <div class="content-block"> | ||
− | == | + | == Interactively Program Sawyer == |
− | Time to program | + | 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 | + | Make sure Sawyer is enabled: |
<syntaxhighlight lang="bash" enclose="div"> | <syntaxhighlight lang="bash" enclose="div"> | ||
− | $ rosrun | + | $ rosrun intera_interface enable_robot.py -e |
</syntaxhighlight> | </syntaxhighlight> | ||
Line 230: | Line 162: | ||
>>> import rospy | >>> import rospy | ||
− | # | + | # intera_interface - Sawyer Python API |
− | >>> import | + | >>> import intera_interface |
# initialize our ROS node, registering it with the Master | # initialize our ROS node, registering it with the Master | ||
− | >>> rospy.init_node(' | + | >>> rospy.init_node('Hello_Sawyer') |
− | # create an instance of | + | # create an instance of intera_interface's Limb class |
− | >>> limb = | + | >>> limb = intera_interface.Limb('right') |
# get the right limb's current joint angles | # get the right limb's current joint angles | ||
Line 243: | 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[' | + | >>> angles['right_j0']=0.0 |
− | >>> angles[' | + | >>> angles['right_j1']=0.0 |
− | >>> angles[' | + | >>> angles['right_j2']=0.0 |
− | >>> angles[' | + | >>> angles['right_j3']=0.0 |
− | >>> angles[' | + | >>> angles['right_j4']=0.0 |
− | >>> angles[' | + | >>> angles['right_j5']=0.0 |
− | >>> angles[' | + | >>> angles['right_j6']=0.0 |
# print the joint angle command | # print the joint angle command | ||
Line 260: | Line 201: | ||
>>> limb.move_to_joint_positions(angles) | >>> limb.move_to_joint_positions(angles) | ||
− | # | + | # Sawyer wants to say hello, let's wave the arm |
# store the first wave position | # store the first wave position | ||
− | >>> wave_1 = {' | + | >>> 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 = {' | + | >>> 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 282: | Line 226: | ||
</div> | </div> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
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
- 1 Sawyer Robot
- 1 Development Workstation (Meeting Minimum System Requirements)
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!