SourceForge.net Logo

Documentation

LISPCL is a Lisp client for the Player project. It is written completeley in Lisp and doesn't make use of any C library. The implementation supports all interfaces of Player 2.x, except the deprecated ones. For the interfaces blobfinder, laser, planner, position2d, position3d, ptz, and sonar wrapper methods for sending commands and requests are provided. The other interfaces are supported by the direct usage of the methods proxy-command and proxy-request. The supported Lisp implementations are AllegroCL, CMUCL, SBCL, and CLISP. Threads are supported for AllegroCL and CMUCL.

Installation

An example for my configuration files .clinit.cl, .cmucl-init.lisp, .sbclrc, and .clisprc can be found here.

Test LISPCL

After having installed and loaded LISPCL (lispcl-test.asd) change to the package LISPCL (in-package "LISPCL") and start the Player server, e.g. player space-wanderer.cfg (see next section). The connection to the Player server can be established either with (pc-test-start) (non-threaded version) or with (pc-threaded-test-start) (threaded version). This will connect to all available interfaces provided by the Player server. In the non-threaded case you have to read new data manually by calling (read-data (pc-get)). Disconnection is achieved with (pc-test-stop). During the connection you can send commands and requests and check the received data (see section Usage for more detail). Here are some examples:

An example test session can be found here.

Examples

The examples were originally written by Radu Bogdan Rusu as Java-Client examples. These examples have been rewritten in Lisp to demonstrate LISPCL. To use these examples you have to load lispcl-test.asd (see Installation). The configuration files for player are located in the examples directory.

Space Wanderer Example

The example shows a basic Space Wanderer algorithm for a Pioneer-like mobile robot with 8 sonars.

Wall Follower example

The example shows a very simple implementation of a wall following behavior by using only the information from the left and front sonar sensors.

Blob Finder examples

A basic example on how to use the blobfinder interface together with Stage for a Pioneer-like mobile robot. The robot navigates around using the basic Space Wanderer algorithm.

Usage

For examples on how to use LISPCL in your project please look at the source code in tests-examples.lisp. Here some remarks on the implementation of LISPCL and hints for using LISPCL are provided. Code examples in this section assume that you are in the package LISPCL, otherwise add the package name to the symbols, e.g. lispcl:player-client. All constants, classes, and methods are exported. The example code snippets of this section can be found here.

Basics

LISPCL is written completeley in Lisp and doesn't make use of any C library. Particulary the C client library and the XDR conversion library provided by Player are not used. Instead the same approach as in Player is used. The file player.h is parsed and the following three files are generated:

Connecting to Player Server

A connection to the Player server is established by creating an instance of the class player-client, e.g. (setf pc (make-instance 'player-client)). The following keyword arguments are accepted:

After being connected to the Player server it is possible to change the data mode to PULL or PUSH and to add replace rules, e.g.: (set-datamode (get-player-proxy pc) *player-datamode-pull*)
(set-replace-rule (get-player-proxy pc) -1 -1 *player-msgtype-data* -1 T)

A connection to a specific interface is established by creating an instance of the according proxy class, providing the keyword arguments :player-client (the previously created instance) and :index (index of interface), e.g (make-instance 'position2d-proxy :player-client pc :index 0)

If the proxy class hasn't been saved in a local variable, it can always be retrieved with the method get-proxy, e.g. (setf p2dp (get-proxy pc *player-position2d-code* 0)).

Receiving Data

In non-threaded mode new data has to be read manually. This is done with (read-data pc). In PUSH mode only one message is read. In PULL mode a new round of data is requested and read.

In threaded mode all messages are read by the thread-fun specified when connecting to the Player server. See pc-test-read-run defined in tests-examples.lisp for more detail. In PULL mode this function assumes that the user requests the first round of data manually (request-data (get-player-proxy pc)). Afterwards new rounds of data are automatically requested.

The last received data state can be accessed with the method get-data, e.g. (get-data p2dp *player-position2d-data-state*).

The easiest way to react to new data, is to attach a data handler to each data message type. A data handler is called whenever a new data message is received.

Sending Commands and Requests

For the proxies blobfinder, laser, planner, position2d, position3d, ptz, and sonar wrapper methods for sending commands and requests are provided. For method names and arguments please refer to the source code. New wrapper methods will follow and requests for or new implementations of new methods are welcomed. Please use the mailing list or the appropriate Sourceforge tracker.

By using the methods proxy-command and proxy-request it is possible to send commands and requests to other interfaces. Please refer to the Player manual for supported commands and requests.

Disconnecting from Player Server

Disconnection is done with the method disconnect. This method accepts either the player client instance (all proxies are disconnected and then the connection to the server is closed) or a proxy instance (only the proxy is disconnected), e.g. (disconnect p2dp) or (disconnect pc).

Supported Lisp Implementations/Platforms

For other successfully tested Lisp implementations/platforms please send e-mail to the mailing list.