The following instructions are based mostly on the article Segway on player 2.1.x published by SRI International’s Artificial Intelligence Center. This document is designed to be included with the player 2.1.x distribution. The latest version of player is 3.x, which claims to include a correct and robust driver for the USB based Segway RMPs.
The instructions were developed for 32- and 64-bit versions of Ubuntu 9.10, but should be fairly protable to other versions and distributions. The library versions are current as of 18-Dec-2009, but are likely to change over time. You will need to update the commands below if a newer version is released.
Step 1 – Pre-Req’s
First we need to install all the programs and libraries that are required below. The following command will install all the required packages:
sudo apt-get -y install build-essential libboost-dev libltdl7-dev swig libjpeg62-dev libxext-dev automake
The brltty package is “Access software for a blind person using a braille display”. Unfortunatly this package conflicts with a driver below, so we need to remove it.
sudo apt-get -y autoremove
Step 2 – FTD driver
Here we install the driver for the FDT chip that the Segway uses to communicate. In this step (and the remaining steps) we use a working directory “~/work/” to hold all the files that we are using. You should check the FTDI website to confirm that the latest version is “0.4.16″.
# Begin FTD driver installation
#
mkdir ~/work/
cd ~/work/
#
# Download, extract, and place the ftd library
#
# ————- 32-Bit ————-
wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16.tar.gz
tar xzvf libftd2xx0.4.16.tar.gz
sudo cp ./libftd2xx0.4.16/libftd2xx.so.0.4.16 /usr/local/lib
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 /usr/local/lib/libftd2xx.so
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 /usr/lib/libftd2xx.so
sudo cp ./libftd2xx0.4.16/ftd2xx.h /usr/include
sudo cp ./libftd2xx0.4.16/WinTypes.h /usr/include
sudo chmod go+r /usr/include/ftd2xx.h /usr/include/WinTypes.h
sudo chmod a-x /usr/include/ftd2xx.h /usr/include/WinTypes.h
# ————- 64-Bit ————-
wget http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx0.4.16_x86_64.tar.gz
tar xzvf libftd2xx0.4.16_x86_64.tar.gz
sudo cp ./libftd2xx0.4.16_x86_64/libftd2xx.so.0.4.16 /usr/local/lib
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 /usr/local/lib/libftd2xx.so
sudo ln -s /usr/local/lib/libftd2xx.so.0.4.16 /usr/lib/libftd2xx.so
sudo cp ./libftd2xx0.4.16_x86_64/ftd2xx.h /usr/include
sudo cp ./libftd2xx0.4.16_x86_64/WinTypes.h /usr/include
sudo chmod go+r /usr/include/ftd2xx.h /usr/include/WinTypes.h
#
# Configure the other bits of the system
#
# Recommended by the FTDI documentation. It is not clear that this step
# is actually required.
sudo sh -c “echo ‘none /proc/bus/usb usbfs defaults,mode=0666 0 0′ >> /etc/fstab”
sudo mount -a
# Add an entry to the udev rules to ensure that devices use the same name/id
# between reboots
sudo sh -c “echo ‘# For FTDI FT232 & FT245 USB devices with Vendor ID = 0×0403, Product ID = 0xe729′ >> /etc/udev/rules.d/99-usbftdi.rules”
sudo sh -c “echo ‘SYSFS{idProduct}==\”e729\”, SYSFS{idVendor}==\”0403\”, RUN+=\”/sbin/modprobe -q ftdi-sio product=0xe729 vendor=0×0403\”‘ >> /etc/udev/rules.d/99-usbftdi.rules”
sudo restart udev
#
# Update the links and caches to pick up the new libraries.
# You’ll need to log out and then log back in to make sure these
# changes are accepted.
#
sudo ldconfig
logout
#
# Test the FTD driver
#
# Unplug in the segway and run the following command.
# It should result in _NO_ output
dmesg | grep FTDI
# Plug in the segway and run the same command.
# This time you should get some output.
dmesg | grep FTDI
Step 3 – CAN driver install
The installation of the CAN driver is much more straightforward.
Unfortunately, you must fill out a form before downloading the driver distribution, so this step can’t be completely automated. To get the distribution, visit the KVASER website. It can be found by following this path:
- Support
- Download
- Beta Releases
- All Beta Releases
- Linux driver and SDKv4.75 BETA
Using a browser, download linuxcan_beta.tar.gz to ~/Downloads/
The instructions below assume that the distribution is still on version 4.75. You will need to make the appropriate updates if the version has changed.
# Begin CAN driver installation
#
cd ~/work/
#
# Extract, and place the ftd library
#
mv ~/Downloads/linuxcan_beta.tar.gz linuxcan-beta-4.75.tgz
tar xzvf linuxcan-beta-4.75.tgz
pushd linuxcan_v4/
sudo make install
popd
This is the one “hack” of the install. For some reason, the typedefs in the canlib.h header conflict with those in the FTD headers. Really this is a conflict in the packages that ought to be resolved by one of the two authors, but for now we have to resolve the problem ourselves.
Edit /usr/include/canlib.h and comment out the definitions for DWORD, HANDLE, BOOL. Use the “//” comment style and leave yourself a comment in the source code describing why you’ve done this.
#
# Update the links and caches to pick up the new libraries.
# You’ll need to log out and then log back in to make sure these
# changes are accepted.
#
sudo ldconfig
logout
At this point, there is no way to test that this installation has gone correctly.
Step 4 – Try Player for Roomba
This might be a bit of a reach, but I will assume that if you’re working with a Segway RMP, you probably already have access to one of the other robots supported by the Player project. In this step, we want to confirm that the player server is working correctly without the influence of the RMP code or libraries.
For the purposes of the example here, I will further assume that you have access to a Roomba Create. If not, update the “–enable-roomba” bit with the name of your robot’s driver.
In the following script, I am using player version 2.1.3, but this script has also been used with version 2.1.2. Just update the version numbers in the script to use the other version.
# Download, extract, build, and install the player server
#
cd ~/work/
wget http://downloads.sourceforge.net/playerstage/player-2.1.3.tar.gz
tar xzf player-2.1.3.tar.gz
pushd player-2.1.3
./configure \
–disable-alldrivers \
–enable-roomba
make
sudo make install
popd
#
# Update the links and caches to pick up the new libraries.
# You’ll need to log out and then log back in to make sure these
# changes are accepted.
#
sudo ldconfig
logout
#
# Create a configuration file for the roomba
#
echo “driver
(
name \”roomba\”
provides [\"position2d:0\"]
port \”/dev/ttyUSB0\”
safe 1
alwayson 1
)” > ~/work/roomba.cfg
Start the player server in one console…
player roomba.cfg
… and start the joystick controller in another console.
playerjoy localhost:6665
Step 5 – Try the Segway
Assuming that you’ve gotten this far and everything is working, it’s time to try the Segway
First, connect your USB based Segway RMP and turn it on (green button). Then turn it on (yellow button).
# These steps have been cited by “the internet” as potentially required.
# The don’t hurt anything in the case that they are not required, so we
# do them anyway, just to be safe.
#
sudo modprobe usbserial
sudo modprobe ftdi_sio
If my patch has not yet been included in the player distribution (these instructions are not in /server/drivers/mixed/rmp/README), then you need to download and apply my patch. Use the following script to do so:
# ————- player 2.1.2 ————-
wget http://XXX/SegwayRmpUsb_for_player-2.1.2.patch
cd player-2.1.2
patch -p1 < ../SegwayRmpUsb_for_player-2.1.2.patch
# ------------- player 2.1.3 -------------
wget http://XXX/SegwayRmpUsb_for_player-2.1.3.patch
cd player-2.1.3
patch -p1 < ../SegwayRmpUsb_for_player-2.1.3.patch
Now it’s time to build the driver. We need to let the build know that the ftd and canbus driver libraries should be included, so we set the LIBS environment variable. Other then that, it’s a standard build.
(It seems that sometimes I need to enclose the value for LIBS in quotes: export LIBS="-lftd2xx -lcanbus". I don’t know why or when this needs to be done.)
pushd player-2.1.3
LIBS=-lftd2xx -lcanbus
./configure \
–disable-alldrivers \
–enable-roomba \
–enable-segwayrmp
make
sudo make install
popd
#
# Update the links and caches to pick up the new libraries.
# You’ll need to log out and then log back in to make sure these
# changes are accepted.
#
sudo ldconfig
logout
#
# Create a configuration file for the roomba
#
echo “driver
(
name \”segwayrmp\”
provides [\"position2d:0\" \"position3d:0\" \"power:0\"]
canio \”rmpusb\”
max_xspeed 3.0
max_yawspeed 60
alwayson 1
)” > ~/work/segway.cfg
Now the moment of truth. I’ve tried to augment the driver to print some useful information when it starts up. If the player server doesn’t start, take a look at the output for debugging hints.
Start the player server in one console…
sudo player segway.cfg
… and start the joystick controller in another console.
playerjoy localhost:6665
Step 6 – Extra Credit
If you have an actual joystick, this is the time to pull it out. Once you connect the joystick, you’ll need to calibrate it like this:
Then you can fire up a player client to use the joystick rather then the keyboard:
Tags: Player, Segway RMP, USB Segway RMP
Thank you for helping Segway RMP users. We know about SRI’s webpage regarding this topic and we appreciate that you are adding to it and spreading the information.
Best regards,
Segway RMP Team