Control Flow: Original Plan


This page describes our first plan for control flow. The problem we encountered is also described, and it prompted us to redesign the control flow. Click here to see Final Plan for control flow.

At the highest level, we found it necessary to split the problem into two separate modes, hallway mode and room mode, for the very practical reason that a single cricket does not have enough sensor or motor ports to perform all of the required functions. Thus we had two crickets, a hallway cricket and a room cricket. The hallway cricket had primary control while the robot was in a hallway. When the robot came to a doorway (indicated by a white line on the floor), the room cricket took primary control. If the room cricket determined that there was no candle in the room, it returned control to the hallway cricket. The crickets used IR signals to pass control back and forth.

 

Hallway Mode

The function of the hallway cricket was to navigate through the maze. By reading the sensor values and controlling the wheel motors, it was able to direct the robot to follow a wall and make turns. Connected to it were the two wheel motors, the two left-side bathroom sensors, one right-side bathroom sensor and the front bathroom sensor. Additionally, it had two IR sensors, one of which was used in the shaft-encoding. The other IR sensor was used to sense when the robot crossed a white line. The white line signified that the robot had either entered a room or had come within 12 inches of the candle.

The robot started by following the wall, with the hallway cricket in control. When it sensed a break in the wall, indicating a doorway or another branch of the hall, it determined which of these was the case. It then took appropriate action (turning or going forward). If, after executing this action, it encountered a room (indicated by a white line on the floor across the doorway), it passed control to the other cricket. If it did not encounter a room, or when the other cricket returned control, it continued to follow the wall.

 

Room Mode

The function of the room cricket was to find and extinguish the candle once the robot was in a room. Connected to it were two candle sensors and the motor for the pushing mechanism. The two candle sensors were placed to the right and left of the shaving cream can, facing forward. By reading sensor values and signaling the hallway cricket to control the wheels, the room cricket directed the robot toward the candle and then extinguished the flame. The hallway cricket continued to check the bottom IR sensor for a white line (indicating that the robot was within 12" of the candle) and signaled the room cricket when it crossed that line.

When control was first passed to the room cricket, it determined whether or not there was a candle in that room by evaluating the readings of the candle sensors. If there was no candle, it backed the robot out of the room and passed control back to the hallway cricket. If there was a candle, the room cricket directed the robot toward the candle by sending signals to the hallway cricket to manipulate the wheels. It determined the desired direction by comparing the values of the two candle sensors. The robot zig-zagged toward the candle, keeping the sensor readings relatively equal.

Once within range of the candle, the room cricket turned its motor on to start the pushing mechanism and dispense the shaving cream. It ran for certain amount of time, determined by experimentation to be sufficient for extinguishing the flame. It then reversed the direction of the motor to retract the gear rack and again ran the motor for a specified time. The robot had now completed its task.

 

The Problem with Plan A

We encountered one serious problem with our original control flow plan: having the hallway cricket continually check the bottom IR sensor for white lines slowed the code down so much that it no longer ran properly. Essentially, the cricket checked the bottom IR sensor as every other step, doubling the number of steps required to get through any given procedure. (This problem is the result of the particular way in which CricketLogo simulates concurrency. If you're interested, follow this link to read more about this and other features of CricketLogo.) At this slow rate, the cricket simply couldn't get through everything in time to react promptly to changes in its environment. For example, if it were no longer parallel to the wall, by the time it recognized that and started to correct it, it had already run into the wall. So we developed our Final Plan for the control flow, adding a third cricket to manage the flow and check the bottom IR sensor.

 

 

Robot Home  Introduction  Final Robot  Structural Design  Navigational Systems  Misadventures