Our final project of this semester is the "It's Alive" Robot Programming Project. For several weeks, our Engineering Projects class has been learning the basics of Arduino coding. The goal of the "It's Alive" robot programming project is to successfully code a robot to autonomously navigate a maze. The robots are built from kits and use ultrasonic sensors to detect walls. When a wall is detected, the sensor should turn, sense if there are walls to the right or left of it, then turn the robot accordingly to continue through the maze.
After building three-wheeled "shield" robots from Parallax kits, we began working our way through the programming process. Through a series of small activities, we built a foundation of functions to write the maze code. Functions abbreviate code so that a variable can be put in place of the full code. The functions can be used many times, reducing the total amount of code needed to be written. This technique is used to "clean up" code and make it easier to adjust without having to repeatedly write the same sections of code. The final version of the code can be found here.
The Parallax robot uses servo motors to turn its two wheels. They are independent and need to be coded individually. Unfortunately, these servo motors drive at different speeds depending on the manufacturer and there is no universal code for something like a "stop" command. However, through trial and error, we tuned the motors to the exact calibration we needed.
During the course of this project, I faced many hurtles. One of the most significant was the use of our original sensors, which were infrared (IR). The code was difficult to find on the Arduino website and programming the robots to read the sensors input and then react to it was a challenge. Once ready for testing, we found that the infrared sensors were extremely sensitive and were incompatible with the maze we were trying to navigate. After this discovery, we abandoned the IR-sensors and continued down the programming path with the ping sensors. I found the code for these new sensors very easy to write and finished it quickly. However, the robot would not preform the way it was programmed to.
Turning right and turning left were easy to adjust by simply changing the delay set in the turn function. The servo used to turn the ping sensor was also simple to code, using a measure in degrees from 0 to 180 to set the desired angle. There were two main issues with the "It's Alive" programming challenge that were very hard to fix and affected the performance of my robot in every trial. The first was the table on which we tested the robots. The surface was wood and was commonly covered with dust or particulate that obstructed the turns made by the wheels. The rubber grip around the wheels would slip in the dust and cause a turn that was inconsistent and not a complete 90 degrees. This hindered the entire test because once a turn was made that was not the right angle, the robot would run into a wall and could not complete the maze. To solve this, we attempted to cover the table with paper and it did improve some of the function but did not eradicate the problem. The second main issue I had was with the ping sensors. Although they worked better than the IR sensors, they would occasionally not read the walls in front of them and the robot would run into them. I believe this is because the sensors worked best when they were facing a wall completely perpendicular to them and due to a poor turn or a tilted wall, the sensors would not read correctly.
Overarching Questions:
How do we program computers to make decisions and to execute tasks?
Using a processor, like the Arduino, we are able to write code in a language that a computer can read and then execute the tasks it is told to do. The processors run on code written in the Arduino application in a language called C++. By utilizing reference banks of code from the Arduino website, we can program computers to do the tasks we wish.
What makes “good code” and why is it important that we have good code?
Good code can be defined by three qualities; easy to read, easy to edit, and simple. It is very important to have these three qualities so that when others look at your code it is not hard to pick up where you left off. Code is often written by many people working on the same project due to the massive number of commands needed to run a sophisticated computer. The Toyota Prius has over 100 millions lines of code, all of which were not written by one person. Writing good code is an important skill to practice, especially if you wish to continue coding for a living.
Overall, I really enjoyed this project. My previous coding experience was very short and I quickly forgot what I had learned. This project, on the other hand, allowed me to explore the coding language more in depth and I felt as though I really absorbed a lot of knowledge. As a teacher, I would improve this project by using a maze that was easier to navigate and on a surface that was not as slippery as the table we used. I would also have the students plug in the rechargeable batteries they used after every class so that we do not have trouble with a lack of energy again. Informally, I learned through this project that trial and error is sometimes the best way to tweak code and that the cleaner your code is, the easier it is to fix and improve. I hope to use the skills I learned again next year in Projects round 2.