Hardware - chopshop-166/chopshoplib GitHub Wiki

The motors, pneumatics, and sensors packages include wrapper classes for the common WPIlib classes. The main reason for this is that there is no common interface for most of the WPIlib types, that provides both functionality and Sendable behavior. This situation gets even more difficult when third-party libraries get included.

In addition to WPIlib, chopshoplib also wraps CTRE and REV Robotics motor controllers and sensors. It also provides Mock objects for most hardware that it wraps.

Smart Motor Controller

SmartMotorController is the base of the hierarchy for motors. It combines the functionality of MotorController with Sendable, but also provides an accessor for an encoder to be attached to it. By itself, the class can wrap around any class that matches both MotorController and Sendable, and optionally take an encoder to tie in. The same class also supports groups of controllers, with a single optional encoder for measuring the group. If no parameters are passed in, it acts like a Mock on its own.

SmartMotorController provides a validate function and an errored inverse for use in BooleanSuppliers. You can add a validator via the addValidator function, which is intended for use within the RobotMap instances. This way they can be customized based on the actual type of the controller.

Though it provides PID related classes, these do not do anything in the base class itself. The simplest function takes a PIDControlType to specify what control type is being used. Derived types can overload that function to support native types for specific use cases (Smart Motion).

SwPIDMotorController is a SmartMotorController that also ties in a PIDController. This is intended for situations when you don't have a motor controller that has PID on-board.

Modifiers

Modifiers and Modifier Groups are used to limit or filter values (usually speeds from -1.0 to 1.0). The Modifier interface provides a handful of static accessors for common modifiers. ModifierGroup provides a way to wrap several in sequence. Since both are instances of DoubleUnaryOperator, and ModifierGroup takes DoubleUnaryOperator for its operations, they can be composed easily.