To communicate with and command Baxter, we must establish the connection between your development PC and the robot. Assuming proper network setup, the RSDK shell refers to the a configuration of your ROS environment which points your PC to the ROS Master, while registering your IP or Hostname allowing other processes to find you.
The SDK provides a convenient script, baxter.sh
, which helps foster the quickest and easiest ROS environment setup to get communicating with Baxter. This script should have been installed/configured during Getting Started - Workstation Setup Tutorial, and the Getting Started - Hello Baxter! Tutorial.
Contents
Quick Environment Setup Via Baxter.sh
$ cd ~/ros_ws
$ ./baxter.sh
Detailed Description/Setup
The current recommended environment setup: Baxter.sh ROS Environment Setup
The baxter.sh script is a convenient script allowing users to get their ROS environment setup quickly. It should allow for intuitive modification of the core components to get communicating with Baxter setup quickly. It creates a heredoc which verifies all environment variables expected are provided, with a handy sim argument for local configurations (useful for simulation), and local argument (useful when SSH'd into Baxter with no need to communicate to external, off-robot processes). This subshell created has the custom prompt modifications (with color) for quick visual checks as well.
Checkout Convenient baxter.sh script
$ cd ~/ros_ws
$ wget https://raw.github.com/RethinkRobotics/baxter/master/baxter.sh
$ chmod +x baxter.sh
Customize the baxter.sh script
Please edit the baxter.sh shell script making the necessary modifications to describe your development PC.
Using your favorite editor (gedit used for example)
$ cd ~/ros_ws
$ gedit baxter.sh
Edit the 'baxter_hostname' field
Please edit the 'baxter_hostname' field:
# Specify Baxter's hostname
**baxter_hostname="baxter_hostname.local"**
Modifying where 'baxter_hostname' is the [[Robot_Hostname hostname of your robot]
Edit 'your_ip' OR 'your_hostname' field
Please edit the 'your_ip' field (only if not using 'your_hostname'):
**your_ip="192.168.XXX.XXX"**
Modifying where 'your_ip' is the IP address of your PC.
Useful command for identifying your IP address:
$ ifconfig
# Result will be contained in the 'inet addr' field (Ubuntu) or 'inet' field (Gentoo Robot PC).
Important: Only set either ROS_IP *OR* ROS_HOSTNAME.
Setting of both ROS_IP and ROS_HOSTNAME will result in ROS_HOSTNAME taking priority, resulting in confusing environment setups. Comment out the unused method using the '#' as leading character.
Alternatively, you may choose to use the hostname of your development PC.
Please edit the 'your_hostname' field (only if not using 'your_ip'):
***your_hostname="my_computer.local***
Modifying where 'your_hostname' is the hostname of your PC.
Important: This hostname must be resolvable to Baxter. To test if your hostname is resolvable to Baxter, please visit the development PC Networking page.
Edit 'ros_version' field
Please edit the 'ros_version' field:
***ros_version="indigo"***
Modifying where 'ros_version' is the your chosen ROS release.
Save and Close baxter.sh script
Please save and close the baxter.sh script.
Initialize your SDK environment
From this point forward, your ROS environment setup should be as simple as running the baxter.sh script from the root of your Catkin workspace:
$ cd ~/ros_ws
$ ./baxter.sh
You will see that your current shell prompt will be prefixed with:
[baxter - http://<robot_hostname>:11311]username@machine$
This allows you to quickly view if your shell is configured for Baxter communication or not, and to which robot you are currently addressing (<robot_hostname>
)
It will be necessary to enable communication between the development PC and the robot and vice versa. This section largely follows ros.org's Installation and Configuration of ROS Environment page.
To do so, we will edit our ~/.bashrc script which is evoked with new shell instances.
Customize your ~/.bashrc
Please edit the ~/.bashrc to set the ROS environment variables necessary for communication with Baxter.
Using your favorite editor (gedit used for example)
$ gedit ~/.bashrc
At the bottom of your ~/.bashrc script add the following:
Source ROS setup.bash
A ROS environment script is packages will all standard ROS installation. This script will set the standard basic ROS environment variables.
Please add the following to the bottom of your ~/.bashrc script.
If using ROS Indigo:
source /opt/ros/indigo/setup.bash
If using ROS Hydro:
source /opt/ros/hydro/setup.bash
If using ROS Groovy:
source /opt/ros/groovy/setup.bash
Set ROS_MASTER_URI
ROS_MASTER_URI - Allows the development PC to locate the master. This will typically be the hostname of the robot.
Please add the following to the bottom of your ~/.bashrc script.
export ROS_MASTER_URI=http://baxter_hostname:11311
Where 'baxter_hostname' is the [[Robot_Hostname hostname of your robot]
Set ROS_IP *OR* ROS_HOSTNAME
It will be necessary for other processes to be able to communicate to and from your development PC. For this reason, setting ROS_IP or ROS_HOSTNAME advertises your node for networked communication.
Please add the ROS_IP (only if not using ROS_HOSTNAME):
export ROS_IP='192.168.XXX.XXX'
Modifying where 'your_ip' is the IP address of your PC.
Useful command for identifying your IP address:
$ ifconfig
# Result will be contained in the 'inet addr' field (Ubuntu) or 'inet' field (Gentoo Robot PC).
Important: Only set either ROS_IP *OR* ROS_HOSTNAME.
Alternatively, you may choose to use the hostname of your development PC.
Please edit the ROS_HOSTNAME field (only if not using ROS_IP):
export ROS_HOSTNAME='your_hostname'
Modifying where 'your_hostname' is the hostname of your PC.
Important: This hostname must be resolvable to Baxter. To test if your hostname is resolvable to Baxter, please visit the development PC Hostname Validation page.
Save and Close ~/.bashrc
Please save and close your ~/.bashrc
Initialize your SDK environment
From this point forward, your ROS environment setup should be preconfigured upon startup of all new terminals (shells). Important: You will still need to source your development workspace (~/ros_ws/devel/setup.bash) setup script when compiling code from source in your Catkin workspace - following our setup this will be ~/ros_ws.
Please close your current terminal, and reopen a new terminal instance.
Verify RSDK Shell
Test ability to ping robot.
Ping what you have previously set as your robot_hostname
.
$ ping <robot_hostname>
# ex.
$ ping 011304P0026.local
If unable to ping the robot visit this page.
Test ability to command the robot
1. Enable the robot
$ rosrun baxter_tools enable_robot.py -e
The robot is now active. You may now grasp Baxter's arms freely by grasping the cuffs at the hands.
2. Disable the robot
$ rosrun baxter_tools enable_robot.py -d
You should visibly see Baxter's arms gently fall and will no longer have the ability to move the arms freely.
If unsuccessful in enabling the robot, please follow the instructions below. This is typically due to a ROS_HOSTNAME being set which is not resolvable to Baxter. Please unset your ROS_HOSTNAME, instead using your ROS_IP. Make sure this is reflected permanently in your baxter.sh
script.
Timeout observed when trying to enable the robot.
Assuming that you are able to $rostopic echo /rosout
during these prerequisite instructions. This error is a sign of the inability to make commands to the robot. This is due to your ROS_HOSTNAME/ROS_IP being set incorrectly.
View the ROS_ENVIRONMENT set for your current shell.
$ env | grep ROS
Verify that ***EITHER*** the ROS_HOSTNAME or ROS_IP is set for your development workstation.
If unsuccessful and the ROS_HOSTNAME is set, please unset this variable and use ROS_IP.
$ unset ROS_HOSTNAME
$ export ROS_IP=<your_development_workstation_ip>
Note: You can always view your current development workstation IP address using
$ ifconfig
If unsuccessful and the ROS_IP is set, verify that this is describes your ip address and not the robot ip address.
# Verify ROS_HOSTNAME is unset
$ unset ROS_HOSTNAME
# Take note of your IP address
$ ifconfig
# Export this as your ROS_IP
$ export ROS_IP=<your_development_workstation_ip>