Using ROS requires various environment variables to be set. The ~/.bashrc file contains shell commands that will be executed whenever a new shell is started. This can be used to set the appropriate environment variables.

Workstation

The following snippet of shellscript will set environment variables to use ROS on an ubuntu system:

if [ -r /opt/ros/diamondback/setup.bash ] ; then
    source /opt/ros/diamondback/setup.bash
fi

export ROS_PACKAGE_PATH=~/ros_workspace:$ROS_PACKAGE_PATH

This assumes that you are using the standard ROS packages for ubuntu, and that you have all your local ROS development in the ros_workspace directory. This code is slightly more complex than some other versions; it will not error if ROS is not installed.

Robot

Assuming you are running roscore on your workstation (which may or may not be a good assumption), you will need to set up environment variables on the robot to tell ROS apps started there where to find the core. The following code sets up those variables automatically so that they point back to the machine you ssh'd in from. This is only correct if a) you used ssh to connect, and b) you connected from the machine running roscore.

source /opt/ros/diamondback/setup.bash
export ROS_PACKAGE_PATH=~/ros_workspace:$ROS_PACKAGE_PATH

CLIENT_IP="${SSH_CLIENT%% *}"

export ROS_MASTER_URI="http://${CLIENT_IP}:11311/"

Since ROS_MASTER_URI is http, anybody can access it. This means that "a) anyone can read you sensors and b) anyone can write to your actuators) -- Will. Useful if everyone's testing their laser code on the robot or when the assignment is being marked!