Communicating the Entire Maze

Storing Maze Information

Figure 1: variables to encode maze info

We used dir to store the absolute direction the robot is facing. pos stores the robot’s position in x, y coordinates in the maze (Figure 1). curr_pos stores the robot’s current position in x, y coordinates in the maze. We use a 4 element array, walls, to store which walls are present at the current position. For example, if there is a wall to the East at cur_pos, walls[E] will be set to:

Figure 2: determining the absolute directions of left and right

We determine the absolute direction of left and right using an enum with the absolute directions: E = 0, S = 1, W = 2, and N = 3. For example, if right_wall = W, if the robot turned right, it would be facing West (Figure 2).

Figure 3: Right wall following (right wall sensor only)

We used right wall following to navigate the maze (Figure 3). While the robot is at an intersection, if it detects a wall to its right, the robot will turn right. It will update dir to turn right if no wall was detected to the right. Using the updated direction variable (dir), we calculate the robot’s next position in the maze. Using coordinates (0, 0) as the upper left corner of the maze, we increment/decrement the x position if dir is East/West and increment/decrement the y position if dir is South/North.

      
       Figure 4: Full Maze logic (all wall sensors: front, right, and left)

Figure 4 shows full right wall following logic after integrating the front and left wall sensors. If walls are detected from all three sensors, the robot makes a uturn. If walls are detected in the front and to the right, the robot will turn left. If a wall is detected to the right only, the robot will move forward. If no walls or walls in the front and/or left are detected, the robot will turn right.

Establishing Connection

Figure 5: radio setup

Figure 5 shows our setup code for radio communication. We took the code from the “ping out” role in GettingStarted.ino to set up the transmitter arduino (Figure 5). We used pipes 42 and 43 calculated from the formula: 2(3D + N) + X where D = 3, N = 24.

     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     Figure 6: Maze encoding

We used the 4 least significant bits to encode the ‘y’ position, the next four to encode the ‘x’ position. The next four to encode the East, South, West, North wall at position x, y in that order. A visual of the encoding is shown below. We send the value below when we detect an intersection.

    
    
    Figure 7: Decoding in Base Arduino

The base arduino receives the transmitted value via radio.read(). The value received is decoded, and the GUI is updated by printing a string: “2,3,west=false,north=true,east=false,south=false” Which is created by _print (Figure 8).

Integration

We combined the RF code with our maze following code. In order to demonstrated the RF, robot detection, and decoy disregarding, we ran the same system on the same maze 3 times, introducing each feature each time. The following is the robot broadcasting and following a maze using the right hand wall following method.

Next we had it detect an IR hat and stop.

Finally, we had the system disregard a decoy IR frequency.

For most of our lab session, maze materials were scarce. However, we were able to verify our system on a more complicated maze.