UserPreferences

PlayerStageWorldFiles


Player Stage World Files

In order to design your own world you need to do 2 things. First you need to write the robot specifications in a ".inc" file, or you can just use an already defined robot. Second you need to design the environment and include the objects that you need.

How to create a ".inc" file

A ".inc" file is a device definition for a specific robot. In the ".inc" file you specify all the properties of the robot, such as: sonar, bumper, camera. Do define the sonar you need to provide a vector with the following information [x y th]. Here is an example of a device with 16 sonar units.
define sparko_sonar sonar
(
  scount 16
  spose[0] [ 0.115 0.130 90]
  spose[1] [ 0.155 0.115 50 ]
  spose[2] [ 0.190 0.080 30 ]
  spose[3] [ 0.210 0.025 10 ]
  spose[4] [ 0.210 -0.025 -10 ]
  spose[5] [ 0.190 -0.080 -30 ]
  spose[6] [ 0.155 -0.115 -50 ]
  spose[7] [ 0.115 -0.130 -90 ]
  spose[8] [ -0.115 -0.130 -90 ]
  spose[9] [ -0.155 -0.115 -130 ]
  spose[10] [ -0.190 -0.080 -150 ]
  spose[11] [ -0.210 -0.025 -170 ]
  spose[12] [ -0.210 0.025 170 ]
  spose[13] [ -0.190 0.080 150 ]
  spose[14] [ -0.155 0.115 130 ]
  spose[15] [ -0.115 0.130 90 ]
)

Defining the bumpers works the same as the sonar. The information that you need to provide is [x y th length angle]. If the angle zero defines a straight line.

define sparko_bumpers bumper
(
  bcount 5
  bpose[0] [ -0.25  0.22  128  0.105 0.0 ]
  bpose[1] [ -0.32  0.12  161  0.105 0.0 ]
  bpose[2] [ -0.34  0.00  180  0.105 0.0 ]
  bpose[3] [ -0.32 -0.12  199  0.105 0.0 ]
  bpose[4] [ -0.25 -0.22  232  0.105 0.0 ]
)

The position type is the piece that puts everything together. There you specify the device properties.

define sparko position
(       
  size [.440 .330]
  offset [-0.04 0.0]
  sparko_sonar()
  sparko_bumpers()
  gripper( pose [0.2 0 0] consume "false")
  ptz( pose [0.1 0 0 ])
  power()
)

Putting it all together

#Desc: device definition for Sparko ( a Pioneer robot with sonars,bumpers,gripper and camera)
#Author : Ioana Butoi
#Date: 28 May 2003

#define 16 sonars
define sparko_sonar sonar
(
  scount 16
  spose[0] [ 0.115 0.130 90]
  spose[1] [ 0.155 0.115 50 ]
  spose[2] [ 0.190 0.080 30 ]
  spose[3] [ 0.210 0.025 10 ]
  spose[4] [ 0.210 -0.025 -10 ]
  spose[5] [ 0.190 -0.080 -30 ]
  spose[6] [ 0.155 -0.115 -50 ]
  spose[7] [ 0.115 -0.130 -90 ]
  spose[8] [ -0.115 -0.130 -90 ]
  spose[9] [ -0.155 -0.115 -130 ]
  spose[10] [ -0.190 -0.080 -150 ]
  spose[11] [ -0.210 -0.025 -170 ]
  spose[12] [ -0.210 0.025 170 ]
  spose[13] [ -0.190 0.080 150 ]
  spose[14] [ -0.155 0.115 130 ]
  spose[15] [ -0.115 0.130 90 ]
)

#define 5 straight bumpers on the rear edge of the robot
define sparko_bumpers bumper
(
  bcount 5
  bpose[0] [ -0.25  0.22  128  0.105 0.0 ]
  bpose[1] [ -0.32  0.12  161  0.105 0.0 ]
  bpose[2] [ -0.34  0.00  180  0.105 0.0 ]
  bpose[3] [ -0.32 -0.12  199  0.105 0.0 ]
  bpose[4] [ -0.25 -0.22  232  0.105 0.0 ]
)

# the pioneer's center of rotation is offset from its
# center of area
define sparko position
(       
  size [.440 .330]
  offset [-0.04 0.0]
  sparko_sonar()
  sparko_bumpers()
  gripper( pose [0.2 0 0] consume "false")
  ptz( pose [0.1 0 0 ])
  power()
)

How to write a world file

In world file you specify the background, the robots and the objects that you want to place in that environment. First you need to specify the dimensions of the window and the resolution.The origin is set at the center of the window. If you increase x you move the image left and if you increase y you move the image down.
# the resolution of Stage's raytrace model in meters
resolution 0.02

# GUI settings
gui
(
  size [ 600.000 350.000 ]
  origin [5.5 3 0]
  scale 0.02 # the size of each bitmap pixel in meters
)

How to create a bitmap file

You can use GIMP to create your bitmap file. Choose New from the File menu. Select the width and height of the image in pixels.You should know the resolution of your image (the size of each bitmap pixel in meters). You must select a Grayscale image. Another important things is that the background must be balck and the foreground white. After you are done save the file with the extensions ".pnm". The following image is rm230.pnm http://bubo.brynmawr.edu/~butoi/pnmfile.jpg

Next you need to include the bitmap file in your world file.

# load a bitmapped environment from a file
#
bitmap
(
  file "rm230.pnm.gz" 
  resolution 0.02
)

To include a robot in the world you first need to include the file that has the robot specifications and then to initialize it.Here sparko is of type position as defined in the .inc file.

include "sparko.inc"

# create a Sparko robot, setting its start position and Player port, 
sparko
(
  color "green"
  name "Sparko1"
  port 6665 
  pose [1 1 0]
) 
Putting it all together
# Room230 world.
# 2 sparko robots

# the resolution of Stage's raytrace model in meters
resolution 0.02

# GUI settings
gui
(
  size [ 600.000 350.000 ]
  origin [5.5 3 0]
  scale 0.02 # the size of each bitmap pixel in meters
)

# load a bitmapped environment from a file
#
bitmap
(
  file "rm230.pnm.gz" 
  resolution 0.02
)

include "sparko.inc"

# create a Sparko robot, setting its start position and Player port, 
sparko
(
  color "green"
  name "Sparko1"
  port 6665 
  pose [2.900 0.960 20.000]
) 
sparko
(
  color "red"
  name "Sparko2"
  port 6666
  pose [3.960 3.920 120.000]
)

Pyro Modules Table of Contents

Modules

  1. PyroModuleIntroduction

  2. PyroModuleObjectOverview

  3. PyroModulePythonIntro

  4. PyroModuleDirectControl

  5. PyroModuleSequencingControl

  6. PyroModuleBehaviorBasedControl

  7. PyroModuleReinforcementLearning

  8. PyroModuleNeuralNetworks

  9. PyroModuleEvolutionaryAlgorithms

  10. PyroModuleComputerVision

  11. PyroModuleMapping

  12. PyroModuleMultirobot

  13. FurtherReading

Additional Resources

  1. PyroIndex

  2. PyroAdvancedTopics

  3. PyroUserManual

  4. [WWW]Pyro Tutorial Movies

Reference: PyroSiteNotes