Intro
Today was spent building a robot.
The Hardware
So my friends Louis and Ike are in a class called Aerospace Engineering, taught by one of my favorite physics and engineering teachers. There's a set of hardware extremities like wheels, SONAR detectors, and bumpers that do all the analog work. Most of the structuring is done on steel rods (think Sandlot-style robots), and all of it is powered by battery packs.
The Programming
The robots are programmed by a language based off C called ROBOTC. There's a good
informational video that explains how it's similar to C and its interaction with each bit of hardware.
The Problem
So David, Derek, and I were called in to help fix this robot. We sorted through the code with Ike, trying to find a logical error and went with Louis to try and test to see how the hardware was working. Actually, we're doing it right now - it's kinda scary to see what's happening. For example, if you have a statement like this
if(SensorValue[Sonar]<6)
{
sleep(500);
Motor[RightMotor] = 30;
Motor[LeftMotor] = 120;
}
else
{
go = 0;
}
which says 'if the SONAR senses something within 6cm, I'll stop for 500ms, then the right motor will turn at 1/4 the speed of the left motor to turn right; otherwise, don't go'. However, the value
SensorValue[Sonar]>6 creates an issue. The SONAR sensor reads the distance to an object, but when it tries to measure a value farther away than its range, it returns a value of
-1. This generates an error because even if there's
nothing in the way, it'll turn.