Player/Stage Manual

Stage 3.2.X changes

The Stage models from my manual were written using Stage 2.1.1, since then Stage has been updated a few times and there have been significant changes to the way that models are created.
Here I'll go through the code that was developed in the manual and I'll make the changes necessary for running the world using the Stage 3.2.X.

The .cfg File

This is the old configuration file I won't bother reprinting the entire thing here.
This file begins with the following code to make Player use Stage instead of trying to connect to real robot devices:

    driver
    (		
	    name "stage"
	    plugin "libstageplugin"

	    provides ["simulation:0"]

	    # load the named file into the simulator
	    worldfile "robots_and_junk.world"
    )
			    
The only thing that needs changing here is the line plugin "libstageplugin" to plugin "stageplugin". That is, delete the "lib" from the front. If you don't do this Player will tell you that it can't find the stage library and nothing will happen.

The .world File

This is the old .world file.
This is the old bigbob.inc file.
If you try running Player with the revised .cfg file you'll probably encounter the following message:
err: Loading size. Need a vector of length 3: found 2.
In the latest version of Stage they upgraded the syntax that describes shapes and things to support 3D models. This included changing the size parameter, so size [x y] doesn't work any more, and the command is now size [x y z] values are still measured in metres. The error it gave means that it is looking for a height, which has not been declared.
In my file I make the world height and map height to be 3 (so changed size [15 15] to size [15 15 3]) which is a somewhat arbitary choice for a height. I also added a height to the orange and carton models in the .world file. The height also needs to be specified in the bigbob.inc file, although for some reason I'd already given that a height of 1 metre, the laser models also needs to be modified because that uses the size parameter too, the ranger model uses ssize which does not need to be 3 dimensional.

Once these corrections have been made, Player gives the following error:
err: Loading pose. Need a vector of length 4: found 3.
The move from 2D models to 3D models means that when you declare the model's pose you also need to tell Stage what height the robot is at. The pose [x y yaw] parameter has been changed to pose [x y z yaw], so a value for z needs to be added. For non-flying robots (like the bigbob example) this will be 0.
In the .world file I set the z pose of all objects in the world to be 0. In bigbob.inc the laser's pose needed to be set as it uses the pose parameter, again the ranger model doesn't need altering because it uses spose instead of pose. Also, the origin parameter in the bigbob position model needs changing, for some reason this will cause the above "pose" error, even though it's the origin parameter. I don't know why. Anyway, I changed origin [0.125 0 0] to origin [0.125 0 0 0] and that stopped the pose error.

Next Player gave me these errors:
err: Model type ptz not found in model typetable
err: Unknown model type ptz in world file.

Evidently the ptz model has been removed completely from Stage. This requires a complete rewrite of the blobfinder code, to update it to use the later syntax. Basically this means getting rid of the ptz stuff and renaming channels to colors. This is the old blobfinder code:

    # bigbob's blobfinder
    define bigbobs_eyes ptz
    (
          blobfinder
          (
                # number of colours to look for
                channels_count 2
	
                # which colours to look for
                channels ["orange" "DarkBlue"]
	
                # camera parameters
                image [160 120]		#resolution
                range_max 5.00
                ptz [0 0 60]
          )
    )
    

Which is replaced with the following code:

    # bigbob's blobfinder
    define bigbobs_eyes blobfinder
    (
	    # number of colours to look for
	    colors_count 2

	    # which colours to look for
	    colors ["orange" "DarkBlue"]

	    # camera parameters
	    image [160 120]		#resolution
    )
    

Running Player on the world now will actually produce a simulation, although it's a bit useless:
bigbob simulation during upgrade to 3.2.0
To fix this the old map.inc is first replaced by the newest map.inc. The map model has been renamed to floorplan in this newest map.inc so the .world file is changed accordingly. The resulting world still looks like the above picture though. This is due to changes in the window model. Our code currently looks like this:

    # size of the whole simulation
    size [15 15 3]


    # configure the GUI window
    window
    ( 
	    size [ 700.000 700.000] 
	    scale 0.025
    )
    
In Stage 3.2.0 it is no longer necessary to declare the size of the simulation outside the window, it's done instead using the scale parameter of the window. The window scale used to be calculated by doing map_size/window_size, now it is window_size/map_size. Since we want our window to be 700px by 700px and our map to be 15m by 15m this is 700/15, which works out as 46.6 reuccuring. This needs to be rounded down to fit in the window properly, after a little trial and error I found a scale of 40 worked ok, although sometimes it doesn't render the box surrounding the map, scrolling up and then down on the Stage window solves that problem or alternatively reducing the scale to 35.
The Stage simulation now looks like this:
Window has been fixed on stage to now render everything properly.

Next the polygons parameter has been replaced with block. usage is similar though, let's look at the bigbob postion model that used polygons:

	    polygons 3
	    polygon[0].points 6
	    polygon[0].point[0] [0 0]
	    polygon[0].point[1] [0 1]
	    polygon[0].point[2] [0.75 1]
	    polygon[0].point[3] [1 0.75]
	    polygon[0].point[4] [1 0.25]
	    polygon[0].point[5] [0.75 0]
      
	    polygon[1].points 4
	    polygon[1].point[0] [1 0.75]
	    polygon[1].point[1] [1.25 0.75]
	    polygon[1].point[2] [1.25 0.625]
	    polygon[1].point[3] [1 0.625]
      
	    polygon[2].points 4
	    polygon[2].point[0] [1 0.375]
	    polygon[2].point[1] [1.25 0.375]
	    polygon[2].point[2] [1.25 0.25]
	    polygon[2].point[3] [1 0.25]
    

This becomes the following code using blocks. The change is only really the syntax, it's very similar.

    block
    (
	    points 6
	    point[0] [0 0]
	    point[1] [0 1]
	    point[2] [0.75 1]
	    point[3] [1 0.75]
	    point[4] [1 0.25]
	    point[5] [0.75 0]
    )

    block
    (
	    points 4
	    point[0] [1 0.75]
	    point[1] [1.25 0.75]
	    point[2] [1.25 0.625]
	    point[3] [1 0.625]
    )

    block
    (
	    points 4
	    point[0] [1 0.375]
	    point[1] [1.25 0.375]
	    point[2] [1.25 0.25]
	    point[3] [1 0.25]
    )
    

The same was done for the carton model, the simulation now looks like this:
Changed robot to use blocks

The problem with this model is now that the bigbob robot is hollow! If we look at the simulation using Stage 3.2.X's perspective mode (press R) it looks like this:
robot is hollow :(

Trying to work out how this code differs from the supplied example code that works is SADNESS. To save you the trouble of asking the Player/Stage mailing list the same question I did I can tell you the problem is that the points need to be declared anti-clockwise! I can't take credit for finding that out though. Finally with the blocks you have to declare where the block is in the z plane. This is done with z [height_from height_to], so if I wanted my block to be from the floor to 1m in height I'd do z [0 1], if I wanted it to be from 50cm off the ground to 1m then I'd use z [0.5 1].
Let's say that Bigbob is 1m tall (which was established earlier when I set the size) and the teeth to be 50cm tall and on the ground. Implementing these changes gives block code like so:

    block
    (
	    points 6
	    point[5] [0 0]
	    point[4] [0 1]
	    point[3] [0.75 1]
	    point[2] [1 0.75]
	    point[1] [1 0.25]
	    point[0] [0.75 0]
	    z [0 1]
    )

    block
    (
	    points 4
	    point[3] [1 0.75]
	    point[2] [1.25 0.75]
	    point[1] [1.25 0.625]
	    point[0] [1 0.625]
	    z [0 0.5]
    )

    block
    (
	    points 4
	    point[3] [1 0.375]
	    point[2] [1.25 0.375]
	    point[1] [1.25 0.25]
	    point[0] [1 0.25]
	    z [0 0.5]
    )
    

You may note I've been somewhat lazy in converting the coordinates from clockwise to anti-clockwise. It still works fine though and the finished world looks like this:
The finished Stage model

This completed code can be downloaded from this link:
Player/Stage 3.2.X Bigbob example code