Skip to content

Core concepts

Wasabi Fan edited this page Nov 28, 2015 · 1 revision

This library interacts with your code in multiple ways when fully implemented in a robot app. Primarily, robot code interfaces with hardware through an intermediate layer of wrapper classes that we have defined. As long as the provided interfaces are used in all parts of the code, the robot program should be completely independent of the HAL; this enables unit testing of end-to-end seasonal code to make sure that it performs as expected.

We wrap both the hardware interface classes (such as speed controllers, actuators, etc.) and the program structure classes (Scheduler/Command) to allow for additional control over robot code execution without the need to modify WPILib. This means that, when implementing new commands and subsystems, you must be mindful of some key differences between using raw WPILib and using our library.

Use the "X" interfaces to interact with hardware and program flow

We signify the core classes that you should use by prefixing their names with an "X". Some examples include the XScheduler, XSpeedController, and XEncoder. These are all interfaces which expose the methods that you'd expect to see on the similarly-named WPILib class, but they are implemented by multiple underlying components depending on the environment in which the code is running and the specifics of the class.

Access common control classes using injection

Instead of using new to create instances of most objects, you should use an interface called "injection". By creating objects in this way, you're guaranteed to get an implementation of our interfaces that matches your environment. Otherwise, you would need to instantiate a concrete implementation of the class, breaking your code's testability.

Learn more about this here.

Implement commands to take advantage of library constructs

We have a special pattern that should be used to define commands to make sure that you can take advantage of all of the library's features. TODO: Elaborate w/ link.

Output telemetry data using property interface

TODO

Create logger instances in every class

TODO

TODO: Add additional items if necessary and link to templates