This project started as the remodeling and development of the mousebot and code used by a previous student for a NASA rover challenge. The basis of the competition was to create an autonomous robot that would navigate around obstacles such as rocks or trees to a beacon located relatively west of the robot. The first version of code (version A)was, thus, the student's final code used for their project. This version separated out the steps of navigation into two basic questions that the Arduino would ask itself in a continuous loop.
First the Arduino would ask itself if any of the 3 infrared sensors had readings that were too bright (or blocked) due to the bounce back of light on an object close to the robot. If sensors were determined to be blocked by the Arduino, it turned to the appropriate direction at the needed angle determined by which sensors were blocked. If the right sensor was blocked, it would turn slightly counterclockwise. However, if the right and center sensors were blocked, it would turn counterclockwise at a larger degree. Once it turned at the determined degree, it would drive forward for a portion of a second. This section of the code allowed the robot to avoid obstacles. Although the process sounds somewhat complicated, it ran very fast and occurred in a matter of seconds.
Next the Arduino asked itself if it had a signal from the beacon. If it did, it read the information sent to it and converted it into degrees using basic math steps. It then calculated how off course the robot was from the beacon assuming that the beacon was to the west (which was part of the challenge and known). The Arduino was then able to turn to correct its course using some more basic math and the known factor of its turn speed. However, if the robot wasn’t getting a signal from the beacon, the robot then proceeded to use its magnetometer to determine the direction it was facing and turn to the west.
The Arduino would then return to the first question and go back and forth between the two in a cycle that only ended once the robot reached the beacon. Although well thought out, the previous project essentially failed due to technical difficulties between the beacon and robot and their communication. However, the idea behind this code was separating out the navigation into the two main parts and two questions. Thus, the robot would both look for obstacles and turn towards the beacon and complete the objective of navigating to a beacon without running into obstacles.
The original beacon used for the NASA challenge
A section of the orginal code used by the previous student for the challenge
The original mousebot before adding sensors and rewiring it