|
How To control a Segway RMP with Player
Credits
The original segwayrmp driver was written by
John
Sweeney, and overhauled by
Brian P. Gerkey, with
help from
Andrew Howard.
This document was written by
Brian P. Gerkey
Examples
For some videos of Player controlling a Segway RMP, look
here.
Overview
This document describes how to get your Segway RMP (Robotic Mobility
Platform) under control with the Player robot
device server. Be warned that the driver that allows this control
(segwayrmp) is brand new, is experimental, and will likely be
in a state of flux for some time to come.
- Get CAN equipment
- Build and install LAPcan drivers and CANLIB
- Connect CAN equipment
- Download CVS snapshot of Player
- Build Player with Segway RMP support
- Start Segway RMP
- Start Player
- Play!
The steps
-
The control interface to the Segway RMP is CAN (Controller Area
Network), an industrial bus standard for which you need a special card.
For redundancy and safety, the RMP uses 2 CAN channels, and you are
required to talk to both of them simultaneously. Thus, you need a
2-channel CAN card. The transceivers for these 2 channels must be
opto-isolated.
Currently, Player's segwayrmp driver only works with Kvaser, Inc's CANLIB,
which is a Linux interface library to Kvaser's CAN cards. CANLIB
should work with any of Kvaser's CAN cards, but we've only tried it
so far with the LAPcan II, which is a 2-channel
PCMCIA card. If you do buy the LAPcan II, you'll also need 2 of the
DRVcan DNopto transceiver dongles. For DARPA MARS participants,
the (discounted) cost for
the LAPcan II and 2 DNopto dongles together is about US$1000.
The underlying CAN I/O subsystem in Player's segwayrmp
driver is modular, to allow for the use of other CAN cards and/or
interface libraries. If you're interested in adding support
for a non-Kvaser card, take a look in the Player source tree at
server/drivers/mixed/rmp/canio.h, which defines the interface
that you must implement. Check
server/drivers/mixed/rmp/canio_kvaser.h and
server/drivers/mixed/rmp/canio_kvaser.cc for an example of how to
implement the interface. Post questions and comments to the
developers' list.
-
If you're using a non-Kvaser CAN card, then you'll have to do something
different (but functionally equivalent) here.
Download the Linux support package from Kvaser. Build
and install canlib (as root):
# make canlib_install
Build and install the LAPcan kernel modules (as root):
# make lapcan_install
Beware that the install script for the LAPcan modules
(installscript_lapcan.sh) is written in a Redhat-specific
manner, and may require some tweaking to run properly on your
system. In particular, if you're running Gentoo, try this modified script instead.
-
Insert your CAN card. If you're not using hotplug (which
autoloads modules for PCMCIA and USB devices), then you may have to first
load the appropriate module manually. For the LAPcan II, you need to load
lapcan_cs.o.
Connect the transceiver dongles to the card and
to the 2 DB9 ports on the underside of the black control box on the Segway
RMP.
You'll need to somehow attach your computer to the Segway. We've had some
success with putting the laptop in a laptop bag in the footspace of the RMP
and using the bag's shoulder strap to secure it to the robot. You should
put some thought into this step, because when (not if) the robot falls
over, you don't want your laptop to be destroyed.
-
There is not yet an official release of Player with the segwayrmp
driver. For now, get the latest CVS snapshot from our snapshots page.
-
Note that you need to build and run Player on the computer that is
connected to the Segway's CAN bus (i.e., the laptop that you've physically
attached to the robot)
Support for the Segway RMP is disabled by default. To enable it, run
Player's configure script like so:
$ ./configure --enable-segwayrmp --with-canlib=/usr
You might also pass other options (like --prefix or
--with-rtk); see the FAQ for more info.
To see all available options, do:
$ ./configure --help
Now build and install Player:
$ make
$ make install
-
To start your Segway, hold any one of the keys (they're all the same for the
RMP) in the ignition slot until it beeps. We've found the keys somewhat
unreliable, so try all of them, and hold each one in the slot for several
seconds in order to find one that works.
The RMP starts out in "tractor mode", wherein it does not
autobalance. You can control the RMP from software in tractor mode,
but you need to attach some kind of trailer/caster assembly. To put it
in "balance mode", hold the RMP upright and push the red button on the
handlebars once. It should beep, turn the handlebar display green with
a happy face and balance itself.
-
Start Player with the supplied configuration file. For example, if you
installed Player in /usr/local (which is the default), then do the
following:
$ /usr/local/bin/player
/usr/local/share/player/config/segwayrmp.cfg
The segwayrmp driver supports both the standard 2-D position
interface and the new 3-D position3d interface. You should use the
position3d interface if you want access to pitch and roll information
from the RMP.
There are examples of how to load the driver for each interface in
segwayrmp.cfg. You should only pick one interface; comment out the
other one. The position3d interface is brand new and not widely used
or supported. At the moment, it is only supported in the C++ client library;
use Position3DProxy. To see the 3-D info, try playerjoy with
the -3d and -v flags.
-
Now it's time to play with your robot. I highly recommend that you
first try it under manual joystick control. Included with Player is a
Linux-specific utility called playerjoy (it's installed alongside
player in bin), which is a Player client that reads
from a joystick and sends appropriate speed commands to a Player server.
It should work with pretty much any basic joystick, although I've only
tested it with analog USB joysticks.
Note that because of Player's network-centric design, you can run
playerjoy off-board, for example on a joystick-equipped desktop
machine and point it at Player running on the laptop that's attached
your robot (presumably over a wireless network). Then you can happily
control the Segway while not being physically near it. For example,
if the laptop on your RMP is called foo, then run
playerjoy like so:
$ /usr/local/bin/playerjoy -c foo:6665
You'll need the -c to cause playerjoy to continuously send
commands (instead of only sending them when the joystick moves). For safety,
the segwayrmp driver will stop the robot if no new commands have been
received in the last 400ms or so.
Your next task is to get the RMP going under autonomous control (after
all, this is robotics research). Look here
for movies of some of our early successes in autonomous control for
wall-following and obstacle traversal.
|