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

Bug Fixes #46

Merged
merged 60 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
ae4c452
fix build and add code for swerve simulation
CoolSpy3 Dec 31, 2022
38a6789
workaround for webots velocity encoder mismatch
CoolSpy3 Jan 5, 2023
1591de8
remove unnecessary position field
CoolSpy3 Jan 5, 2023
6e6fc97
fix jointParameters assignment
CoolSpy3 Jan 5, 2023
f3d5ef6
remove unused import
CoolSpy3 Jan 6, 2023
2f4d78c
fix usage of motor multiplier in Webots workaround
CoolSpy3 Feb 5, 2023
7d939d8
better MockedSparkEncoder implementation
CoolSpy3 Feb 13, 2023
00c879e
remove gyro 360 yaw limit
CoolSpy3 Feb 13, 2023
727b8ca
add deepbluesim to launch.json
CoolSpy3 Feb 13, 2023
c309812
bump gradle, WPIWebSockets, and WPILib
CoolSpy3 Aug 4, 2023
06cc8e6
fix system test
CoolSpy3 Aug 4, 2023
5b73f8e
remove debugging comments
CoolSpy3 Aug 4, 2023
2630287
bug fixes
CoolSpy3 Aug 4, 2023
cb40aa2
remove patched workaround
CoolSpy3 Aug 4, 2023
0168987
cleanup
CoolSpy3 Aug 4, 2023
593f64b
bump WPIWebSockets
CoolSpy3 Aug 4, 2023
67a8bf4
add identity value to halsim extension reduction
CoolSpy3 Aug 4, 2023
9395f4a
fix gradle task name in workflow
CoolSpy3 Aug 4, 2023
1b89bf0
update ci workflow
CoolSpy3 Aug 5, 2023
a6ee1d1
use pr version of webots gradle plugin
CoolSpy3 Aug 5, 2023
e8dbb65
bump WPIWebSockets
CoolSpy3 Aug 5, 2023
fe1eecc
move pluginManagement to settings.gradle
CoolSpy3 Aug 5, 2023
b3f097e
fix system test
CoolSpy3 Aug 5, 2023
490d89e
don't spam log file
CoolSpy3 Aug 5, 2023
466846c
more version bumps
CoolSpy3 Aug 5, 2023
4e670e6
[debug] log LD_LIBRARY_PATH
CoolSpy3 Aug 5, 2023
bc688dd
move debug location
CoolSpy3 Aug 5, 2023
cd143ef
use quotation marks
CoolSpy3 Aug 5, 2023
2946df9
remove LD_LIBRARY_PATH log
CoolSpy3 Aug 5, 2023
9f4f2d3
remove pluginManagement block
CoolSpy3 Aug 5, 2023
eb21ee0
fix #24 and #25, and start #26
CoolSpy3 Aug 9, 2023
a320081
bump WPIWebSockets
CoolSpy3 Aug 15, 2023
624dfb6
bump WPIWebSockets
CoolSpy3 Aug 15, 2023
1bd888e
implement name-mangling and device linking
CoolSpy3 Aug 15, 2023
646b712
update system test
CoolSpy3 Aug 15, 2023
a355d0c
update build/ci toolchain
CoolSpy3 Aug 15, 2023
41f89e3
implement pwm
CoolSpy3 Aug 15, 2023
7993981
update systemTest library path
CoolSpy3 Aug 15, 2023
414af0a
fix units
CoolSpy3 Aug 15, 2023
def238d
update upload-artifact
CoolSpy3 Aug 15, 2023
0ea8bf7
(TMP) wait 1hr for webots to start
CoolSpy3 Aug 15, 2023
4b49dfe
wait 15 mins for webots to start
CoolSpy3 Aug 15, 2023
eec0aa2
add newlines at end of files
CoolSpy3 May 3, 2024
98e57ca
bump WPIWebSockets
CoolSpy3 May 3, 2024
e6abe6b
Prevent robot code from outrunning simulator.
brettle May 4, 2024
4a05889
bump WPIWebSockets
CoolSpy3 May 4, 2024
1b75f5b
Prevent sim from starting until robot is ready.
brettle May 5, 2024
3ce638b
Keep robot and sim in sync during simulation.
brettle May 7, 2024
442cac9
Cleaned up and removed debug output.
brettle May 7, 2024
97760d0
Separate time sync code from robot test code.
brettle May 7, 2024
d102372
Fix test and sim time sync.
brettle May 7, 2024
6c16dd4
Automatically pause simulator if it's been idle for 1-2 seconds.
brettle May 7, 2024
64d45a9
fix installDeepBlueSim .wbproj access denied error on Windows
CoolSpy3 May 15, 2024
4f5f4a3
cleanup and minor fixes
CoolSpy3 May 15, 2024
88ed7d0
add missing Files.exists check
CoolSpy3 May 15, 2024
e9dcb67
revert parts of 4f5f4a34eac491921412a410de25a720b2062d15
CoolSpy3 May 15, 2024
283053f
Remember user changes to simulation speed.
brettle May 16, 2024
7bc9197
clarify usage of -getPeriod() in SystemTestRobot
CoolSpy3 May 16, 2024
0676f13
Support running without time synchronization.
brettle May 16, 2024
a11cdea
Document TimeSynchronizer.
brettle May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/run-system-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runs:
run: |
# This is also a test that our plugin installs DeepBlueSim if one of WPILib's simulate
# tasks is executed.
./gradlew :example:externalSimulate --info --stacktrace
./gradlew :example:simulateExternalJavaRelease --info --stacktrace
shell: bash

- name: Start Webots
Expand Down
69 changes: 26 additions & 43 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,43 @@ on:

jobs:
build:
strategy:
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0

- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11

- name: Get Webots cache path
id: getWebotsCachePath
uses: DeepBlueRobotics/setup-webots@v1
with:
install: false

- name: Cache Webots
uses: actions/cache@v2
with:
path: ${{ steps.getWebotsCachePath.outputs.cachePath }}
key: webots-v2021a-install-${{ runner.os }}

distribution: 'temurin'
java-version: 17

- name: Setup Webots
id: setupWebots
uses: DeepBlueRobotics/setup-webots@v1
uses: DeepBlueRobotics/setup-webots@v2
with:
webotsVersion: R2023b

- name: Do the system test
uses: ./.github/actions/run-system-test

- name: Archive the example folder
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: Resulting example project for ${{ runner.os }}
path: example/

- name: Archive Webots log
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: Webots log for ${{ runner.os }}
Expand All @@ -68,38 +58,29 @@ jobs:

steps:
- name: Cancel any existing workflow runs
uses: fkirc/skip-duplicate-actions@v3.3.0
uses: fkirc/skip-duplicate-actions@v5

- name: Set up JDK 11
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11

- name: Get Webots cache path
id: getWebotsCachePath
uses: DeepBlueRobotics/setup-webots@v1
with:
install: false

- name: Cache Webots
uses: actions/cache@v2
with:
path: ${{ steps.getWebotsCachePath.outputs.cachePath }}
key: webots-v2021a-install-${{ runner.os }}
distribution: 'temurin'
java-version: 17

- name: Setup Webots
id: setupWebots
uses: DeepBlueRobotics/setup-webots@v1
uses: DeepBlueRobotics/setup-webots@versioning-and-caching
with:
webotsVersion: R2023b

- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 0

- name: Compute next semantic version
id: version
uses: paulhatch/semantic-version@v3.3.1
uses: paulhatch/semantic-version@v5
with:
branch: "master"

Expand All @@ -108,10 +89,12 @@ jobs:

- name: Tag
run: git tag ${{ steps.version.outputs.version_tag }}

- name: Push
run: git push origin ${{ steps.version.outputs.version_tag }}

- name: Publish to Gradle Plugin Portal
run: ./gradlew :plugin:publishPlugins -Pversion=${{ steps.version.outputs.version }} -Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }} --info --stacktrace

env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
run: ./gradlew :plugin:publishPlugins -Pversion=${{ steps.version.outputs.version }} -Pgradle.publish.key=$GRADLE_PUBLISH_KEY -Pgradle.publish.secret=$GRADLE_PUBLISH_SECRET --info --stacktrace
8 changes: 7 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "java",
"name": "Launch DeepBlueSim",
"request": "launch",
"mainClass": "DeepBlueSim",
"projectName": "controller"
},
{
"type": "java",
"name": "WPILibWebSocketsToWebots",
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,25 @@ advantage of the WPILib's WebSockets server desktop simulation extension.
1. In the HALSim GUI, select `Autonomous` to see the robot drive forward for 2 seconds, or
select `Teleop` and use the keyboard on joystick to drive the robot around.


## Details

### Time synchronization

By default, the robot code and Webots run at their own speeds so their clocks
will not necessarily match. This can be particularly problematic when trying to
write tests which should be as deterministic as possible. To synchronize the
clocks, the robot code can create a `SimDeviceSim` named `TimeSynchronizer` with
2 `double` values: `robotTimeSec` (output direction) and `simTimeSec` (input
direction). To start the synchronization and force Webots to reload the world
(so that it is in a known state with time = 0), the robot code should set
`robotTimeSec` to -2. The simulator will respond by setting `simTimeSec` to -2.
At that point the robot code can set `robotTimeSec` to the current robot time
and the simulator will run until it's time is greater than that. As it runs, it
will also updae `simTimeSec`. The robot code can ensure that it doesn't get
ahead of the simulator by using `SimHooks.pauseTiming()` to pause the robot code
when the robot time is ahead of the simulation time and
`SimHooks.resumeTiming()` when it is not. See the `webotsInit()` method of the
example's
[`SystemTestRobot.java`](example/src/systemTest/java/frc/robot/SystemTestRobot.java)
for an example implementation.

8 changes: 6 additions & 2 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,9 @@ imgui.ini
# End of https://www.gitignore.io/api/c++,java,linux,macos,gradle,windows,visualstudiocode

# For testing purposes, we want to ensure that this project starts without DeepBlueSim installed.
Webots/controllers/DeepBlueSim.jar
Webots/*/DBS*
Webots/*

# Ignore Simulation GUI settings
/networktables.json
/simgui.json
/simgui-*.json
2 changes: 1 addition & 1 deletion example/.wpilib/wpilib_preferences.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"enableCppIntellisense": false,
"currentLanguage": "java",
"projectYear": "2021",
"projectYear": "2023",
"teamNumber": 199
}
Loading
Loading