A Foraging Java Animat
by Luka Milovanov and Seppo Virtanen
The Java source of the animat: World.java
Background
The above Java animat is based on the subsumption architecture for
robotics introduced by Rodney Brooks. The animat has turtle geometry, i.e. it has two wheels the speeds of which are individually controlled.
The mission of the Animat is to explore its world and stay alive. The
animat must go to its home base to recharge its batteries every 60
seconds. If 60 seconds have elapsed since the last recharge and the
animat has not returned to the home base, it will stop functioning. The
animat pays the recharging of its batteries with pellets that it
collects as it wanders around its world. The animat is not allowed to
touch the boundaries of its world.
The animat has no prior knowledge of the world it lives in. All
decisions it makes are based on input from its sensors: two laser range
sensors (error margin 10%) in the front, a homing beacon (an angle to
the home base, error margin 10%), a clock and a recharging station
detector (indicates, whether the animat has reached its home base).
Based on the sensory input, the animat acts based on the behaviors
programmed into it. The laser sensors detect the home base as an
obstacle, but are not able to determine that the obstacle is in fact the
home base.
The animat could theoretically live forever in this world, because every time the animat picks up a pellet another pellet appears at a random location in the world. The animat can carry multiple pellets at a time.
Behaviors
The animat's behaviors, from highest priority behavior to the lowest
priority one are displayed in the below picture as a subsumption
diagram. The longer the box, the stronger the behavior.
Behavior descriptions:
- Recharge: Recharge the animat's batteries so that it can continue its exploration.
- Pay for recharge: Prior to recharging its batteries, the animat must pay for recharging by leaving one pellet to the station.
- Go home: When the animat's internal clock signals that the
animat has only 35 % left of the 60 seconds it has for exploring, the
Go home behavior is activated. If the animat is carrying a pellet, this
behavior turns the animat towards the homing beacon and starts moving
the animat towards the home base. The homing beacon is monitored all
the time and the direction of motion is adjusted accordingly. If there
is no pellet on board, then the search for one continues. This
behavior is also triggered if the animat
has been in the same place for a long enough time. This has been done to
eliminate the possibility of getting stuck somewhere.
- Wander: This behavior increases the animat's speed of
movement with one unit, if the
animat is not carrying a pellet and there is not much time left before a
mandatory recharge.
- Avoid obstacles: The animat is not allowed to touch any other
obstacles but pellets. Therefore, the avoid obstacles behavior has a high
priority. This behavior is activated if the sensor input is such that the
animat decides it is not approaching a pellet but some other obstacle.
This behavior causes the animat to change its direction of movement to
such that the animat will not hit the obstacle.
- Pick up a pellet: When the animat reaches a pellet, the pellet
is picked up.
- Find a pellet: This is the animat's basic behavior. The
animat wanders around its world and uses its laser sensors to find
pellets. If the difference between the sensor readings is big enough,
the animat expects to have found a pellet. When a pellet is found, the animat
starts moving towards it. While moving, the animat monitors its sensors to
determine, whether the detected obstacle really is a pellet.
When sensors activate a behavior that has higher priority than the one that is currently running, the higher-priority behavior subsumes (overrides) the lower-priority behavior.
To drive the animat, there are motion directives like e.g. move forward,
turn left and turn right. These are invoked from within the above behaviors.
The Real World
If the real world resembled the environment in which this robot lives, then the robot would have every chance of surviving. Of course, after a while, the robot would need maintenance for its mechanical units, for example something like an oil change. Also, in the real world one can count on having a mechanical failure sooner or later. For example, one of the robot's sensors might break down, or perhaps some equipment at the recharging station might break down.
Besides the mechanical problems, there are many other things that might go wrong. The recharging station might not be open 24 hours a day every day, which would create a need for a power save mode (the robot would be idle and in a low power mode when the recharging station is closed). Also, the station could start demanding more than one pellet for every recharge, in which case the robot might run out of pellets and power.
If the world were larger, the robot would be limited in its operations in at least two ways: it could not go any further than 30 seconds from the recharging station, because otherwise it would run out of power. Also, the range of the homing beacon would be limited in the real world, so the robot would not know in which direction the recharging station is if the robot was too far away from it.
© Luka
Milovanov and
Seppo Virtanen
1999.
This page has been viewed times since April 7th 1999.