Living on Mars will be difficult for many reasons—the cold, the lack of oxygen, dust storms, the limited resources, among others. The humans that settle on Mars will have to contend with those known challenges, as well as with plenty of unforeseen challenges. Mars is a wild place. Settlers will have to be creative, resourceful, and hard working.
Take, for instance, retrieving ice from one of the poles. Robots sent to gather ice will have to climb over mountains and through valleys, avoid steep drops and unstable sand. In the previous activity, we plotted a simple route for Codey Rocky to collect ice. But in the real world, an ice-gathering robot will have to be smart enough to do some navigating on its own. Codey Rocky will have to be able to recognize obstacles in its way and figure out how to get around them by itself.
Codey Rocky has some sensors to help it “see” the world around it. Codey has an accelerometer to tell it which way is up (and down!), a light sensor to see when it is dark, and a sound sensor to listen for loud noises. Likewise, Rocky has a “proximity” sensor that detects when it is close to another object and a color sensor to recognize the color of nearby objects. We can use these sensors in our code to help Codey Rocky navigate its surroundings more intelligently.
- Write obstacle-avoidance code that uses Rocky’s proximity sensor.
- Practice troubleshooting when problems arise.
- Use an “if-then-else” control structure to direct the execution of code.