Designing Testable Robot Code

Today at the 2015 FIRST World Championship Conference, Randall Hauch and Zach Anderson presented “Designing Testable Robot Code” (see slides below or the available PDF).

In the hour-long talk, they described how Team 4931 created new hardware abstractions to decouple the subsystem and command classes from the WPILib hardware classes. Traditionally, robot code directly use the WPILib hardware classes for the robot’s actuators and sensors, but doing this makes it very difficult to unit test the subsystems. Using the abstractions makes it possible to unit test the subsystems on developer machines without having any RoboRIO or physical hardware.

Testing on the robot with the RoboRIO and associated hardware is also important, and the team created a data recorder to capture in real time the discrete and continuous inputs, control outputs, and changing command states while the robot is being operated. The data log can be transferred off robot and passed into data processing and analytics (Team 4931 used Tableau), making it very easy to quickly visualize the behavior of the robot and control system outputs.

The team also proposed creating a reusable open source project where FRC teams can collaborate on this reusable library that sits on top of the standard WPILib for Java library. Team 4931 will refactor and clean up their current code and will donate it as a starting point for the project.  Almost a dozen teams expressed interest in participating, so stay tuned over the next month or two while we kick off this new project.

Thanks to everyone who attended! And best of luck to those competing at the 2015 World Championships in St. Louis!