DragonBot Spring 2021

DragonBot Original Mission Game Software

Author/s: Charlie Alfaro

Table of Contents

Introduction

To develop a Game software for the paper robot project there were many matters to consider from the general structure of the game software to the implementation of the code for a functional robot.

The maze system logistic

The mission specified on the rules of the games file consisted in a set to steps to be accomplished by the robot, these steps were divided in three main components, Mapping phase, Calibration Phase, and execution phase.

Understanding The Maze

For the mapping phase the robot would autonomously navigate the maze and record each piece of information, such as the room information and card information, then it would store the information in a multi-dimensional array using hexadecimal values. For this maze we had 14 different room configurations denoted with hexadecimal numbers and letters representing specific binary values, which would describe the internal set of walls and opening for the room.

NEWS

To describe the internal walls, we would use NEWS (NORTH, EAST, WEST, SOUTH) configuration. Where a 1 would represent a Wall and 0 would represent an opening. For instance

we can notice the room has a north and west wall, which, using the NEWS system would be.

N            E             W           S

1             0             1             0

By translating that number to hexadecimal, we obtain

0b1010 = 10 = 0xA

thus, the robot would understand that the room has an A configuration, meaning a north and east wall.

If we apply the logic to all the rooms in the maze, we obtain the full picture as follows.


The objects in the maze

As for now, the team was able to recognize a room using a half byte and assigning a hex value to it, however, to read the cards inside the rooms, we can make use of another half byte, which be in essence the definition of a specific card, whether is a monster, weapon, or treasure. To give an example, if we assign the hex value of 0x1 to a treasure card, we can use Boolean operations to have piece of information in a full hexadecimal byte. Using the left half byte for card information and right half byte for room information. For instance, let us get back to the 0xA room configuration and the 0x1 card information. if we assign dead half bytes to each hexadecimal value, we obtain 0x0A and 0x10. The, we do bitwise OR operation to the numbers to obtain 0x1A, which would mean that inside that room, there is a treasure.

The .h and .c files

To synchronize or coordinate each piece of hardware with the software it was necessary to produce a solution to have everything put together and work collectively, for this reason, using header files an create different functions that dealt with the different aspect of the hardware and the software was the most optimal solution to this. To implement this solution, the game software consisted of an arrangement of header files with the respective c files containing the functions. This function could be called by other engineers within the same software. This not only resolved the issue of coordination between the engineers’ software and hardware implementation, but gave the freedom to the team to vary, add or take away functions as the robot would require without adding extra files or modifying large pieces of code.


Figure showing the header file containing all the functions macro definitions for a particular C file to be used in other C files.



Figure shows a set of functions from the C file used in the main game software code.



Figure shows how the team can use functions in another C files by the defining the header files in their own code.

Calling and initializing functions

The Arduino IDE consist in two parts, one of them is the setup function, where all the hardware is initialized, and then the loop function, where the hardware and software runs in a loop. For this project, the team had to initialize their hardware on the setup function, and then, since each component would be needed to update itself as the game software would be calling the functions, then an update function was added to the setup function as follows.

Conclusion

After having our initial logistic for the general software, the team proceeded individually to create their own set of functions to be used within the game software itself as well as other files.