SerpentFramework is a small collection of Java classes meant to simplify the more repetitious parts of robot programming. It can be downloaded from the team Github. In the past, SerpentFramework has not been compiled - rather, its source files have simply been copied into robot projects. This is useful because custom behavior can more easily be defined and bugs in SerpentFramework can be fixed without attempting to reimport any dependencies.
SerpentFramework contains several types which helpful in almost every robot project. The following classes are of note:
FastRobot is derived from the WPILib RobotBase class. It is meant as a replacement for IterativeRobot, which calls robot update functions at a constant, limited rate. If the periodic robot update function takes less time than the update interval, then IterativeRobot blocks until the interval has elapsed. This wastes processing time. Instead, FastRobot is designed to call periodic update functions as fast as possible, meaning that the robot may be (very slightly) more responsive. To determine the amount of time that has elapsed during any given update call, FastRobot provides the getRobotTime and getTimeDelta methods.
ConfigurableMultiJoystick is meant to provide an easy, customizable way to use joysticks for robot operation. It allows for configurable button bindings on Shuffleboard, and uses strings to identify button actions so that actions are independent of button number. To use ConfigurableMultiJoystick, derive a subtype from it and override getDefaultButtonBindings, getDefaultAxes, and getDefaultControlParameters. processAxisInput may also be overriden to customize how axis input is taken (like whether input should be squared).
Quaternion2D is a data type meant to make working with angles easier. A quaternion is the representation of an angle using said angle's coordinates on the unit circle. For example, 45 degrees corresponds to the quaternion (0.707, 0.707). Quaternions are useful as their angles can easily be added/subtracted without worrying about how angles wrap-around at their limits (for example, 359 degrees wraps-around to 0). In the same fashion, two quaternions can be interpolated without any bound-checking. Quaternions cannot, however, store information about the number of rotations a certain angle constitutes. In the past, they have been used to calculate the angle to which the robot should turn, among other things.
SerpentSubsystem represents a WPILib subsystem that has additional functionality. SerpentSubsystems implement a custom reset method called by SerpentCommands upon their completion, in order to allow for commands to use subsystems without worrying about shutting off motors after they finish.
SerpentCommands derive from the WPILib CommandBase class. When they finish, they call the reset method on any SerpentSubsystem in their requirements list, allowing subsystem components to return to their neutral state.
LogixCommand allows for simplified, succinct definitions of asynchronous robot behavior. It can be used to describe how the robot should behave in a time-dependent fashion without extra method calls or timer variables. Logix contains decorator methods for many different control behaviors, including during (asynchronous equivalent of while), simulataneously (executes all code in the sub-block at the same time), when (asynchronously waits until the given condition is true and then executes), ifTrue (equivalent of if), otherwise (equivalent of else), then (used to end code sub-blocks like a closing curly bracket), and run (runs the given lambda expression). The following is an example of a Logix circuit: