DragonBot Spring 2021

DragonBot Descoped Mission Game Software

Author/s: Charlie Alfaro

Table of Contents

Introduction (Switching the mission)

When performing the execution mission, the game software engineer was not able to incorporate a path finding function for the rapid solving of the maze, which, was one of the requirements for the missions. As the mission was complex it would have taken too much time for the robot to achieve it manually or at least without a path finding function. Thus, the team agreed on doing a new and simplistic mission, which would not include a mapping nor a calibration phase, but would be exploring the maze, finding a key, and exiting the maze.

Key Finding main function

For the main function, there were many factors to consider, which turned out into functions.

This figure shows the main function for finding the key, this function would run while an exit was not found, yet, before finding an exit the robot still would need to recover a key, thus, an if condition would determine if the robot found the key and it would toggle an LED light as well as assigning a number to a variable that would verify a key found and exit that statement. After the key was recovered, the robot would continue to explore the maze and look at each of the rooms and if there were not a valid exit, it would continue to explore (Note: Given that the path finding algorithm could not be implemented for any of the missions, the robot would explore randomly the maze).

Exit logistics

As we can suspect, there should be functions determining the conditions for exiting the maze, for instance, we know we cannot exit while the robot is exploring the maze, however, at some point, it is in fact going to encounter an exit.

 

This function shows the possible exit the robot might face, using bitwise Boolean operators the robot would determine if the room were an exit, if it were, it would see if it were facing it, if this is true it would turn around, otherwise, it would continue exploring.

Let us take an example of an exit to confirm the Boolean condition.

If the column is zero, it means that exit rooms have an opening to the west, thus if we OR the room with 0x0D value and it returns again 0x0D, it means the wall to the west is open and therefore is an exit.

For instance

N            E             W           S

1             1             0             1

0b0000 0001 || 0b0000 1101 = 0b0000 1101

0x01||0x0D = 0x0D

thus, confirming the initial theory.

A similar logic then is used to detect if the other rooms are exits and avoid them if the key is not found.

Moreover, when finding the key, the robot would need to exit the maze, however, given that the game master provides the exit, the game software would specify the room containing the exit.

By simply looking at the column and row assigned by the game master the robot returns a Boolean confirming a current exit and thus, exits the maze.

Moving inside the maze

For this new mission, the team could have a pre encoded maze within the file, this pre encoded maze would be used to store the room information and location of the key and exits, that information would then be showed using the serial print monitor. (Note: that function was never developed due to time and sensor constrains preceding the DEMO due date), yet a robot to locate itself within the maze was developed.


This function updates the position of the robot within the maze as it moves, it gets a Boolean value to determine if it has moved, then, looks at a global variable that constitutes its direction, and based on that updates the column or row it has moved to.

The figure shows the core function for the robot mobility, the robot would look at its sensors and prioritize left entrances to move, if not it would go forward, then right and lastly, without any other alternative it would turn around. After walking it is crucial that the robot returns a Boolean value, since that would update the other functions such as location, direction, and next steps to follow, in other words, the robot would tell the software that it has in fact moved.

Updating directions

Due to limitations on the compass, the project manager produced a manual solution to determine the direction the robot is facing.

As we can observe in this figure, the function is called whenever there is a turning, which translates in a direction change. Then depending on which direction, the robot turned, a global variable was updated with the current direction. Defining North as 0, East = 1, South =2 and West =3. Also, defining the turns as Right = 0, Left = 1 and Turn around = 2.

Conclusion

Due to constrains in time and copper sensor reading the team was not able to test out the Descoped mission code, however, if the readings and other hardware issues were functioning properly, this is the code that would have completed the descoped mission in exchange of the original mission.