Write-ups of Programs Written using Lego Mindstorms Software



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.



RoboTag

The goal of this program was to have the robots communicate with eachother and then carry out a simple task based on the information shared. Using subsumption architecture, higher level behaviors subsume (replace) the lower level behaviors. This means that several behaviors run at the same time while the input from the sensors determines which behavior set controls the robot at any given time. I found this program in the book "The Unofficial Guide to LEGO Mindstorms Robots" by Jonathan Knudsen (pg179). The program was written in NQC, so I adapted it to the Mindstorm programming language.
 The lowest level behavior is the motors. If the touch sensor is activated (the robot tags another robot) the motors stop. However, if the light sensor detects dark(the edge of the playing field) the behavior set that is contains ( back up and turn to the left) will take control of the robot and it will not continue with its 'tag' behavior until this behavior set finishes. The highest level set is that of being tagged. When the robot recieves a certain IR message, all other behaviors taking place are subsumed by the command to wait for eight seconds. In this way, sensor information dictates when a set is activated, and the set priorities control whether or not the behavior set will interup or be interupted by another set.
 The communication aspect of the game depends on the sending and recieving of infrared messages. When touch sensors are activated, the robot sends out the message that it has hit something. If it has indeed hit another robot, that robot will 'hear' the message and reply to the other robot that has indeed tagged it. When the first robot hears this confirmation it is free to wander about looking for other robotsThe only flaw with this type of communication in this game is that a robot may not have hit another robot but because the robot is close by it still recieves the message that it has been tagged. This occurs because of the nature of IR light, in that it can bounce off objects and  can be redirected.

Another problem is that the robots are not directly "looking" for eachother; it is only a matter of chance that they run into each other.

Subsumption architecture appears promising in developing dynamic behavior in the robots.



Follow the Leader

One robot moves randomly around the space. Using infra red (IR) signals, this robot lets any adjacent robots know which way it is going. This program is very simple and still has a number of bugs. However, combined with the light finding progrom, cooroperative behavior may be possible.



Uniform Distribution (Dark Seeker)

Using a biological process seen in many simple organisms, this program dictates the robot to stay away from other light in an indirect way. Although this program does not accomplish the feat very quickly and the robot often stumbles into light, it is important because the programmer is not explicitly telling the robot which direction to turn. Instead, the robot has a fifty-fifity chance of going straight or tumbling (turning). If light density is increasing it has a higher chance of tumbking, where as if the light density is decreasing, the probability that the robot will tumble decreases. In general this robot stays away from light without direct instructions to turn away from the light. Depending on sensor information (light density) the robots probablity of movemnet changes.

I would like to somehow implement a learning behavior set into this program. My idea is that after some set time, the robot will periodically check if it is in strong light. If it is, it will readjust the tumble behavior so that it trumbles more when lught density is increasing, and tumbles even less than it already is when light density is decreasing. After running the program for a certain amount of time, the robot should be able to avoid light better than when it started. May even experiment with starting the robot at 50-50 and let it adjust so that eventually it will "learn" to tumble more with increasing light.