Player/Stage: Getting Started Guide

(Prepared by Michael Bailey)

You don’t need to install Player/Stage yourself. A shared version is available on our UTK CS Linux machines (e.g., in Hydra and Cetus). If you login remotely using ssh, make sure to enable X11 forwarding with the –X option so that the simulation window can be displayed on your screen. Depending on your system, you may need to also use the –Y option to enable trusted X11 forwarding. For example:

ssh –XY <username>@cetus15.cs.utk.edu

If you’re using a Windows machine to login remotely, you won’t be able to run the simulator unless you’ve installed an X server. For instructions on how to do this, see www.cs.utk.edu/~cs302/hints/Xhelp.html

The following instructions show you how to set up your shell environment, start the Player/Stage simulator, and run an example program.

  1. The Player binary is located in /research/playerstage/bin, so add this to your PATH environment variable.

    If you don’t know what your default shell is, try typing “echo $SHELL” in a terminal window. Depending on which shell you’re using, you will need to add one of the following lines:

    If you use the bash or zsh shell, add this to .bashrc or .zshrc in your home directory:
    export PATH=”$PATH:/research/playerstage/bin”

    If you use csh or tcsh, add this to .cshrc or .tcshrc in your home directory:
    setenv PATH $PATH:/research/playerstage/bin

    Once the correct file has been modified, you will need to logout and login again for the changes to take effect.

    Make sure that PATH has been set correctly by typing in the terminal window:
    which player

    If it returns “/research/playerstage/bin/player”, you’re path has been set correctly.

  2. When we start Player, it will try to load the Stage plugin module. We tell it where to look with the PLAYERPATH environment variable.

    For .bashrc or .zshrc:
    export PLAYERPATH=”/research/playerstage/lib”

    For .cshrc or .tcshrc:
    setenv PLAYERPATH /research/playerstage/lib

  3. If you don’t plan to use Python or Java, you can skip this step. If you plan to write your program in Python, you need to tell it where to find Player’s Python modules by modifying PYTHONPATH. If you will be using Java, the location of Player’s Java class files needs to be added to CLASSPATH.

    For .bashrc or .zshrc:
    export PYTHONPATH=”$PYTHONPATH:/research/playerstage/lib/python2.4/site-packages”
    export CLASSPATH=”$CLASSPATH:/research/playerstage/src/javaclient/classes:.”

    For .cshrc or .tcshrc:
    setenv PYTHONPATH $PYTHONPATH:/research/playerstage/lib/python2.4/site-packages
    setenv CLASSPATH $CLASSPATH:/research/playerstage/src/javaclient/classes:.

  4. Now copy the /research/playerstage/project1 directory to your home area. (The playerstage directory won’t show up in ‘ls’ or tab-completion until you type the full name in the first time.) This contains three subdirectories:

    environments: This contains the maps and configuration files for three environments (small, medium, and large).

    example: This contains an example program in each of the available languages (C, C++, Python, and Java). It’s a simple obstacle avoidance program that demonstrates how to use the Player functions that you’ll need to read sensor data and move the robot.

    skel: This contains a skeleton program for each of the four languages. It doesn’t do anything, but you can use it as a starting point for your program since it has the required include files and creates the devices that you’ll be using to control the robot.

  5. Let’s verify that we can start the Player/Stage simulator and get the Stage window to show up on the screen. Player should be run from the environments directory since it requires a configuration file on startup. So go to the environments directory and type the following command:
    player small.cfg

    This should open a Stage simulator window with a robot in the middle of the map. Later, you can test the medium or large environments by replacing “small.cfg” with “med.cfg” or “large.cfg”.

  6. At this point, the Player server running on the simulated robot is waiting for a client program to connect and begin accessing the sensor data and sending movement commands. For now, we’ll use the client program in the example/c++ directory. In another terminal window, go to this directory and run the executable:
    ./laserobstacleavoid

    If you see the robot moving through the environment, everything is set up correctly.

Look at the source code in the example directory for any language you’re interested in to see what Player functions are used to control the robot. Feel free to experiment by making changes to the program. The C and C++ versions have a makefile to recompile the binary. For Java, compile and run the program with the following commands:
javac LaserObstacleAvoid.java
java LaserObstacleAvoid

For Python, use the following command:
python laserobstacleavoid.py

When you’re ready to start writing your own client program, you can use the skeleton program for your chosen language in the skel directory as a starting point. The C and C++ versions have a sample makefile that will need to be modified if you create additional source files.