Our software consisted of 3 main pieces that ran as separate threads: a VPS data collection subsystem, a navigation subsystem, and a high-level control/strategy subsystem.
A full copy of our C code is available here.
VPS Data Collection
The VPS data collection was a simple but very important section of code. As the name implies, it calls the copy_objects() method, retrieving the most recent location and field data. This code then stores location and heading of the robot in a pointer to a struct. All other threads use this pointer to access the location and heading information.
The navigation subsystem contains all methods needed for navigating the field. The navigation code possesses little intelligence. It can be told a destination point through the method setTarget(). Upon receiving a target location, the navigation code will turn the robot to face the target point, and proceed to drive straight toward that point, regardless of any obstacles in the way. The navigation code does contain a PID method which utilizes the gyro sensor to correct for drift as the robot drives straight.
High-level Control and Strategy
This code is the "captain" of the robot. It determines target destinations, avoids obstacles, and breaks down complex movements into series of simple movements. The strategy code determines which territories are currently captured, if there are resources to be mined, and if there are resources in the hopper that need to be dumped. The control code feeds the navigation system targets and calls exceptions in cases where the robot is stuck or has failed a task too many times. The control code also tells the navigation code to activate the roller mechanism, mine resources, or dump the hopper when necessary.