Software

Source Code

Overview of Software Organization

Dalek's software contains many functions, sorted into a hierarchy of c code files, from basic motor operation to complex strategy. This hierarchy is shown in the diagram below. Every level of the hierarchy depends on functions from lower levels, and supports functions on higher levels.

To minimize the chance that Dalek gets trapped in an infinite loop, only functions in the top two levels are allowed unbounded loops. (An example of an unbounded loop: keep going forward until Dalek gets to point (x,y). If we never get to the point, Dalek is trapped in the loop forever.)

Navigation

To get from point to point on the playing field, Dalek depends on the VPS camera feed and an internal gyroscope. The camera gives Dalek’s current position on the field, and the gyroscope gives its heading. To ensure smooth navigation, Dalek uses proportional drive. That is, its forward speed is proportional to its distance from the goal, and its turning speed is proportional to its heading error.

Point to point navigation is designed to avoid the hole in the middle of the field. All points on the field are classified into six territories. In each territory, there is a designated “midpoint”. If Dalek wants to travel between two distant territories, it goes to the midpoint of each intermediate territory, to avoid the central hole, as shown below.

Collision Detection

Dalek can quickly realize that it has collided with a wall or another robot, and respond accordingly. It will assume that it has collided under two conditions: if it doesn’t reach a goal point in 4 seconds, or if it doesn’t move 0.5 inches in 0.5 seconds. In either case, Dalek will first back up for a half second, to clear away from the obstacle. It will then try driving to the current territory’s midpoint. If it can reach the midpoint, it will drive on towards its original goal. If it is blocked again, it will try driving to adjacent midpoints before continuing to its goal.

Levers, Rollers, and Dumping

Dalek is programmed with the coordinates of all levers, rollers, and possible dump sites. These coordinates were determined through trial and error. To ensure that Dalek drives straight into rollers and the dump site, Dalek first visits the midpoint of the roller or dump site that it wants to use, then turns to face the target, then drives to the target. To use the lever, Dalek firsts visits a special “lever parallel point” before turning and driving into the lever.

Using the wireless feed, Dalek can determine whether it was successful in using the rollers or lever. If it detects a miss, it will try up to two more times before giving up and moving on to the next territory.

Overall Strategy

In general, Dalek travels to a territory, captures it using the rollers, picks up balls, and moves on to another, dumping every three territories. After dealing with each territory, Dalek uses several criteria to pick its next target. It looks for the territory with the most balls left, followed by the closest territory, followed by territories that it already controls. To reduce the possibility of robot-on-robot collision, it will avoid territories containing the opponent robot.

Dalek has a special mode for the last 20 seconds of each match. After finishing operations in a territory and detecting less than 20 seconds of game time, Dalek will first dump its balls. It will then attempt to capture all territories on the field. In the event that it owns all territories, it will resume gathering balls.