Difference between revisions of "Hello Robot"

Jump to: navigation , search
(Step 4: Run an Example Program)
Line 262: Line 262:
  
 
</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.
 

Revision as of 20:15, 8 November 2016


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

Step 1: 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:

ROS Indigo

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


Source ROS Environment Setup Script

Intera.sh ROS Environment Setup

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


Step 2: 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 robot 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

Verify Development Workstation Ping

We have verified communication from the development pc to the robot. Now we will SSH to Sawyer and verify communication from Sawyer to the development PC.

Sawyer 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 ( ROS_IP was previously recommended):

ROS_IP

# Identify your ROS_IP
$ env | grep ROS_IP

The result (example): ROS_IP=192.168.101.99

192.168.101.99 in this case is the IP address which must be resolvable to Sawyer and all other ROS processes.

ROS_HOSTNAME

# Identify your ROS_HOSTNAME
$ env | grep ROS_HOSTNAME

The result (example): ROS_HOSTNAME=yoda

yoda in this case is the Hostname which must be resolvable to Sawyer and all other ROS processes.


We will now SSH to Sawyer and verify the ability to communicate with this development PC. For SSH access, please use the ROS Master (ROBOT_HOSTNAME) identified above.

$ 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

We can now exit our SSH session on the robot:

ruser@p99 ~ $ exit

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.

Step 3: 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. 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. 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.

Step 4: 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_velocity_wobbler.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 Velocity Wobbler Example Page.

Step 5: 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

# 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_j0': -0.459, 'right_j1': -0.202, 'right_j2': 1.807, 'right_j3': 1.714, 'right_j4': -0.906, 'right_j5': -1.545, 'right_j6': -0.276}

# store the second wave position
>>> wave_2 = {'right_j0': -0.395, 'right_j1': -0.202, 'right_j2': 1.831, 'right_j3': 1.981, 'right_j4': -1.979, 'right_j5': -1.100, 'right_j6': -0.448}

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


# quit
>>> quit()


Congratulations! You have successfully completed the installation tutorials!