Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for simulation extensions #6729

Merged
merged 5 commits into from
Jul 16, 2024

Conversation

Gold856
Copy link
Contributor

@Gold856 Gold856 commented Jun 10, 2024

Added a README.md describing how to build a simulation extension.
Also added a README.md for the DS extension.

Replaces #6162.

@Gold856 Gold856 requested a review from a team as a code owner June 10, 2024 00:10
Several devices in the HAL have functions that allow you to feed data from an external source into the HAL. The full list can be found in the HAL subdirectory in `include/hal/simulation`. For example, the AccelerometerData header declares functions that update the X, Y, and Z axes with data. Some functions accept callbacks; the I2CData header declares functions which accept other functions with parameters that allow it to accept data. This allows the implementation of a simulation extension that interfaces with an I2C bus and connects it to the HAL, allowing the use of real I2C hardware in simulation. Note that these callbacks are called synchronously and in the same thread as the robot program; long delays in callbacks will block the main thread and can cause loop overruns.

## Building the extension
To build an extension for use in a robot project, you'll need to build with Gradle. The easiest way to get a working build.gradle file is to copy the build.gradle file from halsim_xrp. It doesn't have any tests, and it only depends on halsim_ws_core. The important line is `lib project: ':wpinet', library: 'wpinet', linkage: 'shared'`. This tells Gradle to link the extension with wpinet using shared libraries. Other libraries can be included in a similar way by referencing the Gradle subproject name. Note that you do not need to include the HAL since it is automatically included.
Copy link
Contributor Author

@Gold856 Gold856 Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shared/plugins/setupBuild.gradle allows you to include wpiutil, wpinet, and ntcore by putting it in the ext block. halsim_ds_socket does this by putting includeWpiutil = true in its ext block, but other extensions do it manually. Is the ext block preferred over manually handling dependencies?

@Gold856 Gold856 force-pushed the sim-extension-docs branch 2 times, most recently from adac6ae to cd34cad Compare June 29, 2024 18:38
@Gold856 Gold856 force-pushed the sim-extension-docs branch from cd34cad to 42ca819 Compare July 12, 2024 19:35
@PeterJohnson PeterJohnson merged commit cd6b70a into wpilibsuite:main Jul 16, 2024
33 checks passed
@Gold856 Gold856 deleted the sim-extension-docs branch July 16, 2024 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants