Home
FAQ
Player
Stage
Gazebo
Contrib
Documentation
Publications
Contributors
Users

Project
Download
Bugs/Feedback
Mailing lists

Radish

Old news
Old stuff

Player Server Manual

What is Player? Player is a robot device server. It gives you simple and complete control over the physical sensors and actuators on your mobile robot. When Player is running on your robot, your client control program connects to it via a standard TCP socket, and communication is accomplished by the sending and receiving of some of a small set of simple messages.

Player is designed to be language and platform independent. Your client program can run on any machine that has network connectivity to your robot, and it can be written in any language that can open and control a TCP socket. Client-side libraries are currently available for C, C++, Tcl, LISP, Java, and Python.

Player also makes no assumptions about how you might want to structure your robot control programs; i.e., Player is architecturally neutral.

Quick-start Guide

Starting the Player server
The Player server is run as follows:
$ player [options] <configfile>

The configuration file is a text file describing the set of devices to be instantiated; for example, if you have an ActivMedia Pioneer and a SICKLMS200 scanning laser range finder:

driver ( name "p2os_position" provides ["position:0"] ) driver ( name "sicklms200" provides ["laser:0"] port "/dev/ttyS1" )

This file instructs the server to create two devices:

  • A Pioneer P2OS driver, supporting the position interface.
  • A Sick LMS200 driver, supporting the laser interface. Client programs can subsequently connect to these devices, read data, send commands and so forth (see below).

Note the important distinction between drivers, interfaces and devices:

  • A driver supports a specific piece of hardware, such as a SICK LMS200 scanning laser range-finder.
  • An interface is a generic mechanism for getting data and/or sending commands to a piece of hardware.
  • A device describes a specific driver/interface pairing; e.g., a SICK LMS200 driver which supports the laser interface.

Devices are also given an index to facilitate unique addressing (e.g., "laser:0" or "laser:1"); this allows the server to instantiate more than one device with the same interface.

Writing a Player client
Users can write programs to communicate with the Player server. In principle, this can be done using Player's low-level network-socket-base protocol. In practice, most users will avail themselves of one of the existing client libraries; the libraries manage the network interactions, data marshalling and so on, and present a much more convenient API.

For example, the following code fragment demonstrates a simple client using the libplayerc library.

#include <stdio.h>
#include "playerc.h"

int main(int argc, const char **argv)
{
  int i;
  playerc_client_t *client;
  playerc_position_t *position;

  // Create a client object and connect to the server; the server must
  // be running on "localhost" at port 6665
  client = playerc_client_create(NULL, "localhost", 6665);
  if (playerc_client_connect(client) != 0)
  {
    fprintf(stderr, "error: %s\n", playerc_error_str());
    return -1;
  }

  // Create a position proxy (device id "position:0") and susbscribe
  // in read/write mode
  position = playerc_position_create(client, 0);
  if (playerc_position_subscribe(position, PLAYER_ALL_MODE) != 0)
  {
    fprintf(stderr, "error: %s\n", playerc_error_str());
    return -1;
  }

  // Enable the robots motors
  playerc_position_enable(position, 1);

  // Start the robot turning slowing
  playerc_position_set_cmd_vel(position, 0, 0, 0.1, 1);

  for (i = 0; i < 200; i++)
  {
    // Read data from the server and display current robot position
    playerc_client_read(client);
    printf("position : %f %f %f\n",
           position->px, position->py, position->pa);
  } 

  // Shutdown and tidy up
  playerc_position_unsubscribe(position);
  playerc_position_destroy(position);
  playerc_client_disconnect(client);
  playerc_client_destroy(client);

  return 0;
}

This example can be built using the commands:

$ gcc -c simple.c -o simple.o $ gcc -lm -lplayerc simple.o -o simple

With the server already started, you can run the example with:

$ ./simple

Assuming everything is plugged in and turned on, your robot should scoot across the room.

Client libraries also exist for C, C++, Tcl, LISP, Java, and Python.

Further information

More detailed information can be found here:
Generated on Tue May 3 14:15:32 2005 for Player by doxygen 1.3.6