Skip to content

DeepBlueRobotics/WPIWebSockets

Repository files navigation

WPIWebSockets

This API provides a Java interface to the WPILib HALSim WebSockets API which mirrors the standard simulation API.

Building the API

To build the API, navigate to the root directory of this repository and run ./gradlew build. This will use Gradle to build the API with Java 8. Note that the simulated device files (org.carlmontrobotics.wpiws.devices.*) are auto-generated using the AsyncAPI Generator and an extended version of WPILib's machine readable WebSocket specification. The AsyncAPI template used to generate these files is located at ./asyncapi-template. These files are auto-generated during the WPIWebSockets:build task, however, they can be manually regenerated by running ./gradlew generateDeviceFiles.

Using the API

Connecting to the running HALSim client and server instances can be accomplished by using the connectHALSim and startHALSimServer methods of org.carlmontrobotics.wpiws.connection.WSConnection. Code for connecting to simulated devices can be found in the org.carlmontrobotics.wpiws.devices package. These classes can be initialized by providing the constructor with the device id with which it should associate itself. The instance will then provide getter, setter, and callback methods for all of the values exposed by the WebSocket API. (ex. new PWMSim("5").setSpeed(5), new DIOSim("0").getValue()). Note: static methods apply globaly to the device type.

For a more complete example, see DeepBlueRobotics/DeepBlueSim which uses this API to provide an interface to a Webots robot simulator.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published