Light Lover
The goal of this program is to write a simple program loop
that causes the robot to seek out light. Eventually, a program can be
written in which the info about the light is recorded and thus can
be used when making "decisions" about an action to take. This program
records light levels from two different light meters. It then
compares the light levels and moves in the direction of greater
light. The program is very simple:
Repeat forever
-check sensors
-Set x to Light1
-Set y to Light 3
-If x>y go left 1 sec (direction of Light1)
-if not
-if x<y go right 1 sec
(direction of LIght3)
-if not (i.e. x=y) go forward 1 sec
The effect is that the robot creeps toward the
brightest light, moving side to side. If a brighter light is noticed
though, the robot will move away from the light it was following and
will begin to follow the new, more intense light. As a result, it is
possible for the robot to follow a flashlight around a room. Although
the program seems relatively simple, complex behavior emerges. The
robot is continually moving as it processes the constant sensor info.
This program can also be seen as the set of behavior that avoids the
dark. Light can represent food, and/or dark can represent a hazardous
area.
Each increment of a one second movement is like the
robot taking one step. If there is more light on the left side, the
robot will move towards the left for more than one step until light
levels are equivalent with or less than the right side.
By combining this program with a habit
feature, one that allows the robot to adjust to the light levels for
instance, the robot can then encounter a certain light level for a
period of time, adjust to the light, as our eyes do, and seek out
light that is brighter. This way it can react to a changing
environment. It will not follow any bright light, but will instead try
to find light of a certain intensity.
|