The define
statement can be used to define new types of entities.
For example, the world file from the previous section can be re-written
in a more concise form as follows:
# This world file creates two robots with lasers. # It uses the 'define' construct to define a new type of entity. environment ( file "cave.pnm" scale 0.03 ) define myrobot position ( player() laser() ) myrobot ( name "robot1" port 6665 pose [1 1 0] ) myrobot ( name "robot2" port 6666 pose [2 1 0] )New entities are defined using
define newentity oldentity (...)
.
For example, the line:define myrobot position ( player() laser() )defines a new
myrobot
entity type composed of the
primitive position
, player
and laser
entities.
This entity may be instantiated using the standard syntax:myrobot ( name "robot1" port 6665 pose [1 1 0] )This entry creates a position device named
robot1
that has
both player
and laser
devices attached.