Tuesday, 9 March 2010

Player/Stage API

Now I've finally found time to work on Player/Stage full time I've begun to make a handy API for the E-Puck robots we have here in York. The first part of this has been building a Stage model of the E-Puck and then writing an API to interact with all the device proxies.

The end goal is to have an API which can be used to communicate with simulated robots, but will also work with a real robot. The Player/Stage website is very insistent that this is possible!
Source code



The API can interact with a robot that has position2D, sonar and blobfinder devices. Those are all that are supported so far, I plan on adding some more soon. For example, I want to be able to simulate a swarm of robots that communicate with sound and wifi, so I need to somehow get the AudioProxy and WifiProxy working on Stage.
In the API code, EPuck.cc you can see how I'm made my code interact with the proxies and wrapped them in my own function names which are more suited to my needs. One thing I did was make a method called setDifferentialMotors(left, right) which takes speeds for the left and right wheels and converts them to values that can be understood by Player. The maths behind this I've discussed previously.

One major thing I've done to make the blob data more useful is to create a Blob class which contains all the data that the player_blobfinder_blob_t structure does, but instead of using uint32_t data types I mainly use int. This made it easier to work with the information but also meant that if I want to interact with blob data I don't need to include the playerc++ header.

What's in the file?


The source code file: epuckAPI.tar contains the Stage world which I made to test the API, as well as a model of an epuck and the cfg to run the simulation. The API is in EPuck.h and EPuck.cc, these contain source code that is helpful in learning how to use Player proxies. Finally there is some test code TestEpuck.cc which uses the API to command the robots and read some data.


Anyway to use the API you just #include EPuck.h at the top of your code and compile EPuck.cc along with all your other code to get a final program that (if all goes well) you can run.

3 comments:

  1. Hi Jenny !

    Probably a silly question ! ..... is your API meant to interface e-puck for a real time observation in computer ...... or is it meant for simulation ?

    ReplyDelete
  2. I'm not sure what you mean by "real-time observation in the computer".
    This code interfaces with a Stage simulation. So you'll have to write your own stage world and cfg (although there's the one I used included in the tar), and then write your own code which uses the API. Through the API you can interact with the stage simulation without needing to learn the messy Player syntax (just the messy API syntax).

    ReplyDelete
  3. Hi Jenny!

    Your work has been awesome and extremely helpful.

    I am currently working on an undergrad robotics research project, and I'm trying to see if I can control an e-puck with playerv.

    It all works fine until, under playerv devices, I subscribe to position2d and then I try to control the e-puck.

    It gives me this: playerv : error in /usr/local/player-3.0.2/utils/playerv/pv_dev_position2d.c
    libplayerc error: timed out waiting for server reply to request position2d:0:request:1

    and my lil e-puck doesn't even twitter a bit...

    I'm using player version 3.0.2, could it have to be with the version? Or do you have any recommendations on what to do?

    ReplyDelete