Code

Team 13 started off knowing absolutely no C before IAP, even though two of its members had significant experience with other programming languages. After the competition, they felt very comfortable with C. Team 13 found that there were two especially interesting things in C—function pointers and p-threading—which were both easy to learn and simple to understand conceptually through experience working on a 6.270 robot.

Downloads: Code-related advice to future 6.270 contestants:
  • Write the lower level code first—without it, all your higher level code is useless.
  • Use your gyro. Seriously. This is the best tool you're given for measuring the angle your robot is at. If you try to do it based on a shaft encoder, you will get a lot of error because that is an "internal" way to measure your robot's angle, while the gyro uses "external" sensory input. Additionally, the gyro does not drift by too significant an amount during the 90 second round (and you can account for it drifting in your code).
  • Print statements are really useful for debugging, but be careful where you put them as they stop a lot of the other processes going on. For example, we initially ran into a lot of issues with our robot turning because this slowed the process down too much, causing the gyro reading to be a significant fraction of a second behind.
  • Use a PID controller for driving straight. There's a structure for one already built into JoyOS. Shaft encoding, especially with high resolution data (from breakbeam sensors high in the gear box), goes well with this to drive straight forward or backward. (Also, when calibrating this, 95% of your calibration can be done on the lab floor; only the final stages need to be done on the game board. Don't waste other team's precious board time by doing all of your calibration there.)
  • Learn about function pointers. One of the more useful things to do is use them to update the enabled variable for the PID controller.