Xbot 488 2015 Code Release

Our code release comes in two parts: Our 2015 code, and the library we began to construct out of it.

https://github.com/Team488/Shared contains all the code we’ve written for competition robots (and offseason projects) over the past few years, and has been updated with our 2015 code as well.

We’ve been working on factoring out useful parts of this that could be used year-over-year by ourselves and other teams - that effort is tracked by https://github.com/Team488/SeriouslyCommonLib, and an example implementation is seen here: https://github.com/Team488/FRCRobotTemplate.

One quick disclaimer for the CommonLib and RobotTemplate (which you’ll see on the repository):

This repository is still very much a work in progress! There are chunks of code and build steps missing here that would probably block you from directly integrating this into your robot.

It’s getting more complete every week, but as it stands, we recommend that you use parts of this repository rather than the whole of it - taking individual classes, or using the design as inspiration, rather than seeing it as a stable platform for robot development.

What we were focusing on:

  • Fully testable
    We have wrappers for the robot-specific classes that WPILib provies. This means that every class can be run on a development PC, using mock implementations and factories. Your tests run all the same code that gets deployed to the robot.
  • Persistent, configurable properties
    We have utilities and extra interfaces which provide an easily-accessable property framework. When you use our classes to create a property, supplying a flag makes it automatically persist in a database on the robot as well as on the Smart Dashboard. Perfect for configuration and settings.
  • Detailed logging
    Every class logs with a specific message and error level when something important happens (using log4j). You can modify the logging priority threshold for the program as a whole or for specific classes, depending on the verbosity of the desired logging.
  • Re-usable utilities
    Our math utilities, logic helpers, and various number containers (such as the XYPairfor vectors or points) contain loads of re-usable logic that’s useful throughout a robot program.
  • Robots never give up
    It’s always painful when your robot code crashes in a competition and you lose control of your robot. Although it’s always best to write safe code, our scheduler wrapper keeps commands running even after an exception is thrown.
  • Pre-written drive system
    We have written a drive system implementation and included it in the commom lib to make it as easy as possible to get started writing code with minimal effort.
  • Tilt detection
    The common lib includes drive system helpers to attempt to counteract the acceleration of a tilting robot. If it’s enabled and the robot starts to fall over, the tilt detection will kick in and attempt to right itself.
  • Enhanced autonomous capabilities
    We’re working on the infrastructure required to allow you to write JavaScript code which executes as a WPILib command. This means that you can write small snippets of code that execute synchronously from their point of view while still allowing the scheduler and other robot functionality to run as normal.

The testability has been the biggest benefit so far - given that our programming team can range between 3-8 members, there’s a lot of contention to test things on the actual machine (which may or may not be ready for weeks regardless!).

By writing test cases, we not only get to check our logic out before putting it on the robot, we also guard against breaking our own code with future changes!