Replaces WPILib components to read data from
junction
instead of the HAL.
Replacing these classes means that user code can interact with WPILib components the same way as any other robot program. The Java export from this component is a full replacement for wpilibj
that includes our shims.
The interfaces of each shim match the origin WPILib classes, replacing only the implementations. No modification is required in user code to use the shims. Below is a list of all modified classes:
DriverStation.java
- Reads joystick data fromjunction/core
, most other functions are unmodified. This allows for synronization of data within each cycle and guarantees that data read on the robot and in the simulator are identical. Note that the methodupdateControlWordFromCache
is unavailable as the class no longer reads aControlWord
from the HAL. This method is only used byDSControlWord
by default, which remains functional.DSControlWord.java
- Reads robot state directly fromjunction/core
rather thanDriverStation
. The existing method of reading data fromDriverStation
required use of aControlWord
object, which the shimDriverStation
is unable to create. The functionality of this class is identical.RobotController.java
- Reads the FPGA timestamp fromjunction/core
, all other functions are unmodified. This means that the timestamp is constant within each cycle and can be replayed accurately even when running faster than real time.Tracer.java
- Reads the real FPGA timestamp from the HAL throughjunction/core
instead of relying on the modifiedRobotController
class. This class needs to read the true timestamp to accurately record epoch times.Watchdog.java
- Reads the real FPGA timestamp from the HAL throughjunction/core
instead of relying on the modifiedRobotController
class. This class needs to read the true timestamp to correctly detect performance issues.
The following Bazel targets are available (defined in BUILD):
wpilib
- Main Java library, depends onjunction/core
and WPILib for building. This library includes only the shim classes, not the rest of WPILib.wpilib-export
- Maven export for publishingwpilib
, used by GitHub Actions. This target includes runtime dependencies for both the originalwpilibj
and thewpilib
shim target above. By explicitly depending onwpilibj
(the original) first, thejava_export
rule replaces the duplicate class files with our shims.
To publish junction/shims/wpilib
to your local Maven repository, use the following command:
bazel run --define "maven_repo=file://$HOME/.m2/repository" //junction/wpilib:wpilib-export.publish
As with all components published to Maven, the version number can be set with a command-line flag:
bazel run --define "publishing_version=X.X.X" ...
The signature-test
rule checks that the method signatures of each class match the stock WPILib versions.