Player/Stage overview
Player 2.1 C++ Reference
Useful notes on Stage
Building Player/Stage from source (versions 2.1.3/2.1.1, respectively)(RECOMMENDED!)
- In Ubuntu, install the build-essential package that includes compilers and libraries.
- Get the source files from sourceforge (http://sourceforge.net/project/showfiles.php?group_id=42445)
- Use Synaptic Package Manager and ensure you have libgtk2.0-dev and libltdl-dev
- To enable multithreading and signaling, use Synaptic to install libboost-1.40-all-dev. For python bindings, install swig.
- Unpack the source archives, and within each directory, run the following commands:
./configure
make
sudo make install
- After both have installed:
sudo ldconfig
By default, Player/Stage will be installed to /usr/local/share/player or /usr/local/share/stage. Test the install by running >player /usr/local/share/stage/worlds/simple.cfg (which starts up player with stage simulation), and then >/usr/local/share/player/examples/libplayerc++/laserobstacleavoid (a player client program, the 'brain' of the robot).
Now you need to make sure you can build player client programs:
- First, check the /usr/lib/pkgconfig directory to see if playercore.pc exists. If it does not, return to the player source directory, go into the libplayercore directory, and copy all the .pc files into the /usr/lib/pkgconfig directory.
- Check the PKG_CONFIG_PATH variable to make sure it points to the /usr/lib/pkgconfig directory. Check using
echo $PKG_CONFIG_PATH and set it (if necessary) with export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/pkgconfig (works for bash, if you have another shell, you're on your own).
- Go to the /usr/local/share/player/examples/libplayerc++ directory and run
sudo g++ -o laserobstacleavoid `pkg-config --cflags playerc++` laserobstacleavoid.cc `pkg-config --libs playerc++`
If you can build a basic client program and run it, you're pretty much good to go. I think there are more intricacies to building a shared driver object, but it would be best to look at the player/stage on-line manuals for that.
Testing your install
Assuming you've already managed to compile/install Player and stage (or found a system with them already installed), here's how you get the simple robot running around the simple little world.
- Find where Stage installed its .world and .cfg files (default: /usr/local/share/stage/worlds )
- Give yourself write permission for simple.world
- Find the line "gui_disable 1" in simple.world, change it to "gui_disable 0"
- Command line: "player simple.cfg" You should now have a window with a world and a stationary robot.
- To manually control the robot, run "playerv" from another terminal.
- If you want to run the sample code they provide for you, you're going to have to hunt it down.
- Find the directory you unzipped the player installer into (should be named "player-2.1.2" or some such, depending on version)
- From there, go to "examples/libplayerc++"
- While you have the stage world running, and do not have playerv running, run ./laserobstacleavoid
Quick trick for compiling
Command to compile:
g++ -o outfile `pkg-config --cflags playerc++` infile.cc `pkg-config --libs playerc++`
If this is annoying to remember, or copy/paste every time, you can use a little bash script to do it for you:
#!/bin/bash
g++ -o $1 `pkg-config --cflags playerc++` $1.cc `pkg-config --libs playerc++`