Setup Player on a Segway RMP
From Robots in everyday human environments
This guide can be used to intall Player and Stage together with the Segway RMP200 driver. The Original Segway driver in Player/Stage is old and not for the RMP200 model. The driver is based on the instructions by Régis Vincent, but has been modified for suiting the RMP200 model.
1. Download player 2.1.x and stage 2.1.1 from the website:
http://sourceforge.net/project/showfiles.php?group_id=42445 and unzip them.
2. Set the proxy for terminal (if nessecary):
export http_proxy=http://<proxyserver>:<port>
3. Install the nessecsory packages from ubuntu server:
sudo apt-get upgrade sudo apt-get update sudo apt-get install autotools-dev build-essential cpp libboost-dev libboost-thread-dev libboost-thread1.34.1 libboost-signals-dev libboost-signals1.34.1 libgnomecanvas2-0 libgtk2.0-dev libjpeg62-dev libtool swig libgnomecanvas2-dev libgsl0-dev libswscale-dev
Note that there might be new packeges available, e.g. libboost-signals1.38.1 etc. Furthermore, depending on how you configure Player, it might not be necessary to intall all packages, or some additional might be necessary.
4. Requirements for the Segway driver:
Download FTDI linux driver version 0.4.16 (minimum) : http://www.ftdichip.com/Drivers/D2XX.htm Unzip and untar the file given to a suitable directory:
gunzip libftd2xx0.4.16.tar.gz tar -xvf libftd2xx0.4.16.tar
Copy file and make symbolic links:
sudo cp libftd2xx.so.0.4.16 /usr/local/lib cd /usr/local/lib ln -s libftd2xx.so.0.4.16 libftd2xx.so cd /usr/lib ln -s /usr/local/lib/libftd2xx.so.0.4.16 libftd2xx.so
Create a rules file
cd /etc/udev/rules.d/ sudo gedit 99-usbftdi.rules
Enter the following code, then save & close the file:
For FTDI FT232 & FT245 USB devices with Vendor ID = 0x0403, Product ID = 0xe729
SYSFS{idProduct}=="e729", SYSFS{idVendor}=="0403", MODE="666", RUN+="/sbin/modprobe -q ftdi-sio product=0xe729 vendor=0x0403"
The MODE="666" is important. It changes the permissions in /dev/bus/usb such that it is possible to write to the virtual COM port if you are not root. Otherwise you need to run player as root all the time. To instantiate, first plugin the USB cord from the RMP and turn on the RMP. Then run the following command:
sudo udevcontrol reload_rules <CR> (or maybe sudo udevadm control --reload-rules for newer systems). dmesg | grep FTDI <CR>
Output should look like this, confirming that the driver was successfully loaded:
[ 15.768872] drivers/usb/serial/usb-serial.c: USB Serial support registered for FTDI USB Serial Device [ 15.768927] ftdi_sio 4-1:1.0: FTDI USB Serial Device converter detected [ 15.769177] usb 4-1: FTDI USB Serial Device converter now attached to ttyUSB0
Remove the brltty driver to access the FTDI Virtual COM port.
sudo apt-get remove brltty
Copy files from the downloaded libftd2xx0.4.16 directory and create links:
sudo mkdir /usr/local/ftdi sudo cp ftd2xx.h /usr/local/ftdi sudo cp WinTypes.h /usr/local/ftdi sudo ln -s /usr/local/ftdi/ftd2xx.h /usr/include/ftd2xx.h sudo ln -s /usr/local/ftdi/WinTypes.h /usr/include/WinTypes.h
Install kvaser canbus driver. Install the BETA version : http://www.kvaser.com/index.htm (under Support/Download - Beta section). It's version 4.72 beta. (installation is simple, make and make install)
Later, when installing player, you might encounter some errors with conflicting types. This can be handled by changing the following lines in the file linuxcan_v4/include/canlib.h
typedef unsigned int DWORD; typedef unsigned int HANDLE; typedef unsigned int BOOL;
to
typedef unsigned long DWORD; typedef void* HANDLE; typedef int BOOL;
...and then compile and install again. Or it might be possible only to change the definitions in /usr/include/canlib.h
5. Compile player with modified Segway RMP Drivers:
You can either find a compressed version of the new Segway driver here, and follow the instructions in the README file (basically run the script compile_player). Or you can manually follow the steps below:
Find the modified Segway driver files here and place them in the correct folders:
The first are for changing the position3d interface to be able to get all the state information of the RMP. The last files are the specific drivers.
<player-dir>/libplayercore/interfaces/030_positiion3d.def <player-dir>/client_libs/libplayerc/dev_position3d.c <player-dir>/client_libs/libplayerc++/playerc++.h <player-dir>/client_libs/libplayerc/playerc.h <player-dir>/client_libs/libplayerc++/position3dproxy.cc <player-dir>/server/drivers/mixed/rmp/canio.h <player-dir>/server/drivers/mixed/rmp/canio_kvaser.h <player-dir>/server/drivers/mixed/rmp/canio_rmpusb.h <player-dir>/server/drivers/mixed/rmp/segwayrmp.cc <player-dir>/server/drivers/mixed/rmp/canio_kvaser.cc <player-dir>/server/drivers/mixed/rmp/canio_rmpusb.cc <player-dir>/server/drivers/mixed/rmp/Makefile.am <player-dir>/server/drivers/mixed/rmp/Makefile.in <player-dir>/server/drivers/mixed/rmp/rmp_frame.h <player-dir>/server/drivers/mixed/rmp/segwayrmp.h
Configure player:
go to the folder /player-2.1.x
./configure --disable-alldrivers --enable-amcl --enable-mapfile --enable-wavefront --enable-nd --enable-vfh --enable-segwayrmp --enable-rtkgui
Or enable whatever other drivers you need.
Change a function name:
If you do not use --disable-alldrivers in the configure script, you might encounter a segmentation fault, when trying run player with the segway after the installation. This is because there is a function in the libftd2xx driver, which exactly matches one in Player. Somehow the linker will make sure that it is the one in Player, which is called, when it is the one in libftd2xx, which is needed. To avoid this, change the name of the function check_device in
<player-dir>/server/drivers/camera/sphere/setpwc_api.c <player-dir>/server/drivers/camera/sphere/setpwc_api.h
to something like cam_check_device
Make the Segway driver:
cd <player-dir> make
You will most likely get an error now. Edit the Makefile in server
<player-dir>/server/Makefile
Edit Makefile to add -lftd2xx next to -lcanlib (look for -lcanlib and then add -lftd2xx next to it. There should be 3 occurences)
make
Note that, if you edit the Makefile before compiling the first time, you will still encounter an error, because the compilation changes the file server/Makefile. The proper thing to do is probably to modify the configure script - you are of cause welcome to do that :-)
6. Set the Path by changing the bashrc file:
echo "" >> ~/.bashrc echo "export PATH=\"\$PATH:/usr/local/bin\"" >> ~/.bashrc echo "export PLAYERPATH=\"\$PATH:/usr/local/share/stage/worlds\"" >> ~/.bashrc echo "export LD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:/usr/local/lib\"" >> ~/.bashrc
Activate bashrc
source ~/.bashrc
7. Installing player and stage:
go to folder player-2.1.x
sudo make install
go to the folder stage-2.1.1
./configure sudo make install
8. Checking if the colour description file is at the right place:
if [ -f /usr/X11R6/lib/X11/rgb.txt ]; then echo else echo "/usr/X11R6/lib/X11/rgb.txt does not exist - creating a symbolic link" sudo ln -s /usr/lib/X11/rgb.txt /usr/X11R6/lib/X11/rgb.txt fi
9. Test:
Start PlayerStage
player /usr/local/share/stage/worlds/simple.cfg
if this error occurs:
player: error while loading shared libraries: libplayerdrivers.so.2.2: cannot open shared object file: No such file or directory
run ldconfig in the folder player-2.1.x as sudo
You should also be able to control the segway. A test config file can be found here.
Depending on how you installed the FTDI and/or kvasar drivers, you might need to run player as root if you have not granted write acces in the udev rules file (see above).
$(sudo) player segway_server.cfg
