Wednesday, 21 October 2009

E-Pucks in Player/Stage: Building a Stage model

My latest project using Player/Stage is to implement flocking on my university's swarm of epucks. To do this I'm first going to build a simulation of the flocking in Player/Stage, with the simulation I can check that my code works and that the flocking is performed reasonably well. Then I will transfer the code onto the epucks, which means the epucks will need calibration so that they work together in a way which is (ideally!) close to what the simulation showed they'd do.

The first thing I'm going to do is build a Stage model of an epuck which I can use for my simulation. This will be based partially on what Player/Stage drivers are written for the epucks, so far only the Position2d, IR, Camera and Blobfinder drivers are available for use. This means I don't need to add any other devices to my model.


This is Walter(1), he serves as a testing platform for all my code. This is what an e-puck looks like, and what we are trying to create a model of:
Walter the epuck

Walter the epuck

(The front side of the epuck is the end where the sticker is)

Now, happily, someone somewhere has actually already written a stage model for the epuck which I've uploaded here, I won't include a code listings because it's quite long and complicated. This is how it renders an epuck:
old rendering of the epuck model

You might think that the work is done but no, I like code to be nice and I like it to make sense; this model description is neither. First we'll start on the ranger sensors. Their yaw values are all over the place, 342.8, 314.2, 270, 208.5, 151.5, 90, 405.8 and 377.2. I'll change these to be sensible values between -180 and 180. It's important to note the index that each ranger is given, the counting starts at 0 being the front right IR (that's the black blob above the clear LED in the second photo) and increasing around clockwise (looking down on the robot).
spose[0] [0.030 -0.010 -15] #fr right
spose[1] [0.022 -0.025 -45] #fr right 2
spose[2] [0.0 -0.031 -90] # right
spose[3] [-0.03 -0.015 -150] #back right
spose[4] [-0.03 0.015 150] #back left
spose[5] [0.0 0.031 90] #left
spose[6] [0.022 0.025 45] #fr left 2
spose[7] [0.03 0.01 15] #fr left

Next I got rid of all the complicated polygon specifications which make the epuck look nice. That includes the "turret" which is the Y shaped thing on top of their model, the wheels (the thick black lines on the model) and I changed the shape of the robot. In the original model the epuck is an 18 cornered polygon, I replaced this with a bitmap called "circle.png" which is just a black circle on a white background. This one in fact:


The final step is to fix their blobfinder code. In the original epuck model they do a weird thing where they define the epuck camera and blobfinder inside the position description. I completely re-wrote this so that it makes sense:

# epuck blobfinder
define epuck_cam ptz
(
blobfinder
(
# number of colours to look for
channels_count 1

# which colours to look for
channels ["red"]

# camera parameters
image [640 480] #resolution
range_max 5.00
ptz [0 0 0]
)
size [0.001 0.001]
)

I'm using Stage 2.1.1 on my computer, so the blobfinder has to be described within a ptz model. I will only use the blobfinder to look for red becuase the epucks have red LEDs around them, so looking for red will mean the epucks can detect each other. The camera on the epuck is fixed in position so it can't pan, tilt or zoom hence ptz [0 0 0]. The size of the camera is set to be 0.1mm x 0.1mm so that it doesn't show up on the stage simulation, the default camera size for the ptz model is much bigger than the epuck so the size parameter MUST be set.

That's basically it then for the model making! The final version of the epuck Stage model can be downloaded here: Epuck Stage model. The model doesn't look as impressive, but it is much easier to understand now. Enjoy!


(1) Why is he called Walter you ask? The answer is because Walter the Wobot is just about the cutest robot ever. Cwipes!

6 comments:

  1. Hey thank you.
    I was looking for an epuck model for player and this one works good!

    nice job

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. HI! i want to say that your blog is very nice and understandable, i am working with e-pucks for my master thesis and your blog is very helpful and nice to read, good luck with your work!

    ReplyDelete
    Replies
    1. Hello, i m begining my master thesis too that works about e-pucks, let me some help with example for control this e-puck model on stage ???
      I need learn about e-puck, player and stage. Can you send me some basics samples ??

      Delete
    2. my email edneydasilvasouza@gmail.com

      Delete
  4. Very nice job, congratulation.
    Can you send some example for basics controls this e-puck model on player, stage ??
    How can i use this model in stage ???
    my email edneydasilvasouza@gmail.com

    ReplyDelete