mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Compare commits
102 Commits
v2027.0.0-
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4f89c11c3 | ||
|
|
7298d9eafb | ||
|
|
7dcb70cfcd | ||
|
|
3d6df4a50e | ||
|
|
50eab65b07 | ||
|
|
f1c9d82d50 | ||
|
|
481a586009 | ||
|
|
396b553069 | ||
|
|
cfab47e871 | ||
|
|
637f006f9b | ||
|
|
608f024f82 | ||
|
|
8d2f3212e7 | ||
|
|
0b950ea6d9 | ||
|
|
ad797456f5 | ||
|
|
e92478c212 | ||
|
|
0662a78892 | ||
|
|
c35df58a81 | ||
|
|
5a7d7d50ee | ||
|
|
d6fb871a26 | ||
|
|
489b993e60 | ||
|
|
97381549e6 | ||
|
|
025732093f | ||
|
|
c647e67de0 | ||
|
|
fe499ede4c | ||
|
|
3f966aa7c6 | ||
|
|
72d85be0c2 | ||
|
|
111130d8bb | ||
|
|
0213ecf382 | ||
|
|
bdd45c7365 | ||
|
|
44501bf5eb | ||
|
|
1be5da5bde | ||
|
|
06fb36ba8e | ||
|
|
71ed28f768 | ||
|
|
edf77fa007 | ||
|
|
6e5171cd8f | ||
|
|
ddf9306264 | ||
|
|
88d8369751 | ||
|
|
96fb033deb | ||
|
|
d941be905e | ||
|
|
e085c3e8b3 | ||
|
|
98c03baf54 | ||
|
|
8353b95507 | ||
|
|
a41679854b | ||
|
|
fdc6fd9cb1 | ||
|
|
dca59147e1 | ||
|
|
a734275cc5 | ||
|
|
3f0d7bc2c4 | ||
|
|
3d982f81dd | ||
|
|
a3c18d24a7 | ||
|
|
c597116f02 | ||
|
|
9adffd356d | ||
|
|
635e971a02 | ||
|
|
40fdb779d8 | ||
|
|
e728ee27f2 | ||
|
|
50fd29e697 | ||
|
|
4fa5dacfc4 | ||
|
|
1e12408a7d | ||
|
|
14db070c2c | ||
|
|
5c3a474a58 | ||
|
|
f1d95ee5f8 | ||
|
|
7ff32d7756 | ||
|
|
aedee56e22 | ||
|
|
ac7a9524f8 | ||
|
|
b100586cab | ||
|
|
254ca64106 | ||
|
|
1392db4529 | ||
|
|
40f9a87e70 | ||
|
|
94fda36e04 | ||
|
|
f217dfe747 | ||
|
|
d86378d353 | ||
|
|
ac41523eb4 | ||
|
|
d48f1cd0e5 | ||
|
|
e88729c67e | ||
|
|
e35ca772fd | ||
|
|
fa24446ce3 | ||
|
|
67b795057b | ||
|
|
e4ae671b49 | ||
|
|
f751ca88eb | ||
|
|
6ba5734a94 | ||
|
|
68d24bb29e | ||
|
|
3f1cf3cabe | ||
|
|
b91001f504 | ||
|
|
ffd36eb091 | ||
|
|
97c0b0c40a | ||
|
|
16fcf016de | ||
|
|
878da3d54c | ||
|
|
1021ff88a9 | ||
|
|
0af65ea787 | ||
|
|
8832d6a7c2 | ||
|
|
62e0bc515c | ||
|
|
5964443038 | ||
|
|
8c5c535e1b | ||
|
|
4c07aedd91 | ||
|
|
3d4cabfbc9 | ||
|
|
63a82dccb2 | ||
|
|
b10bc0a674 | ||
|
|
e40ca392c3 | ||
|
|
f97571fb1f | ||
|
|
d23c732d79 | ||
|
|
063ac7002f | ||
|
|
e76074d381 | ||
|
|
6f88066170 |
1
.bazelrc
1
.bazelrc
@@ -68,7 +68,6 @@ build:remote_user --config=remote_cache_readonly
|
||||
build:remote_user --remote_download_toplevel
|
||||
|
||||
common:ci --color=yes
|
||||
build:ci --config=remote_cache
|
||||
build:ci --remote_download_minimal
|
||||
build:ci --progress_report_interval=60 --show_progress_rate_limit=60
|
||||
|
||||
|
||||
38
.github/actions/setup-bazel-cache/action.yml
vendored
Normal file
38
.github/actions/setup-bazel-cache/action.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
name: 'Setup Bazel Cache'
|
||||
description: 'Configures the Bazel remote cache. Prefers WPI bazel-remote (R/W), falls back to BuildBuddy, then readonly WPI cache.'
|
||||
|
||||
inputs:
|
||||
bazel_remote_username:
|
||||
description: 'WPI Bazel remote cache username'
|
||||
bazel_remote_password:
|
||||
description: 'WPI Bazel remote cache password'
|
||||
bazel_remote_url:
|
||||
description: 'WPI Bazel remote cache base URL (no credentials or protocol, e.g. gitlib-bazel.wpi.edu)'
|
||||
default: 'gitlib-bazel.wpi.edu'
|
||||
buildbuddy_token:
|
||||
description: 'BuildBuddy API token'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Resolve Bazel cache configuration
|
||||
env:
|
||||
CACHE_USER: ${{ inputs.bazel_remote_username }}
|
||||
CACHE_PASS: ${{ inputs.bazel_remote_password }}
|
||||
REMOTE_URL: ${{ inputs.bazel_remote_url }}
|
||||
BB_TOKEN: ${{ inputs.buildbuddy_token }}
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "${CACHE_USER}" ] && [ -n "${CACHE_PASS}" ]; then
|
||||
echo "WPI bazel-remote credentials detected; configuring R/W access"
|
||||
echo "build:remote_cache --remote_cache=grpcs://${CACHE_USER}:${CACHE_PASS}@${REMOTE_URL}" > bazel_auth.rc
|
||||
echo "build:ci --config=remote_cache" >> bazel_auth.rc
|
||||
elif [ -n "${BB_TOKEN}" ]; then
|
||||
echo "BuildBuddy token detected; configuring BuildBuddy cache"
|
||||
echo "build:build_buddy --remote_header=x-buildbuddy-api-key=${BB_TOKEN}" > bazel_auth.rc
|
||||
echo "build:ci --config=build_buddy" >> bazel_auth.rc
|
||||
else
|
||||
echo "No cache credentials detected; falling back to readonly WPI cache"
|
||||
echo "build:ci --config=remote_cache" > bazel_auth.rc
|
||||
echo "build:ci --config=remote_cache_readonly" >> bazel_auth.rc
|
||||
fi
|
||||
37
.github/actions/setup-bazel-remote/action.yml
vendored
37
.github/actions/setup-bazel-remote/action.yml
vendored
@@ -1,37 +0,0 @@
|
||||
name: 'Setup Bazel Remote cache'
|
||||
description: 'Sets up bazel-remote cache using basic auth from GitHub secrets'
|
||||
|
||||
inputs:
|
||||
username:
|
||||
description: 'Bazel remote cache username'
|
||||
password:
|
||||
description: 'Bazel remote cache password'
|
||||
remote_url:
|
||||
description: 'Bazel remote cache base URL (no credentials or protocol, e.g. gitlib-bazel.wpi.edu)'
|
||||
default: 'gitlib-bazel.wpi.edu'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Setup bazel-remote (skip when no creds)
|
||||
env:
|
||||
CACHE_USER: ${{ inputs.username }}
|
||||
CACHE_PASS: ${{ inputs.password }}
|
||||
REMOTE_URL: ${{ inputs.remote_url }}
|
||||
if: ${{ env.CACHE_USER == '' || env.CACHE_PASS == '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "No bazel-remote credentials detected; leaving caching as previously configured"
|
||||
echo "build:ci --config=remote_cache_readonly" >> bazel_auth.rc
|
||||
|
||||
- name: Setup bazel-remote (with creds)
|
||||
env:
|
||||
CACHE_USER: ${{ inputs.username }}
|
||||
CACHE_PASS: ${{ inputs.password }}
|
||||
REMOTE_URL: ${{ inputs.remote_url }}
|
||||
if: ${{ env.CACHE_USER != '' && env.CACHE_PASS != '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Bazel-remote credentials detected; configuring bazel_auth.rc"
|
||||
URL_WITH_CREDS="grpcs://${CACHE_USER}:${CACHE_PASS}@${REMOTE_URL}"
|
||||
echo "build:remote_cache --remote_cache=${URL_WITH_CREDS}" >> bazel_auth.rc
|
||||
38
.github/actions/setup-build-buddy/action.yml
vendored
38
.github/actions/setup-build-buddy/action.yml
vendored
@@ -1,38 +0,0 @@
|
||||
name: 'Setup BuildBuddy acache'
|
||||
description: 'Sets up the build buddy cache to be readonly / writing based on the presence of environment variables'
|
||||
|
||||
inputs:
|
||||
token:
|
||||
description: 'Build Buddy API token'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
# Sets up build buddy when no secret is found for the API key. This is most likely because this is triggered from an action from a fork instead of the main allwpilib repo.
|
||||
- name: Setup without key
|
||||
env:
|
||||
API_KEY: ${{ inputs.token }}
|
||||
if: ${{ env.API_KEY == '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "No API key secret detected, will setup readonly cache"
|
||||
echo "build:ci --config=build_buddy_readonly" > bazel_auth.rc
|
||||
|
||||
# Set up the readonly key only if this build is for a pull request. Push builds happen in the forks repository,
|
||||
# so the user should set their own buildbuddy api keys up there. Only enabling it for PR's should reduce heavy
|
||||
# and more random load on the cache.
|
||||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||
echo "Assuming this is a pull request from a fork. Setting up the readonly api key"
|
||||
echo "build:ci --remote_header=x-buildbuddy-api-key=QIOV65PTW1tVal3AJbe7" >> bazel_auth.rc
|
||||
else
|
||||
echo "Not setting up readonly key for trigger ${{ github.event_name }} since this is not a pull request, it is most likely a forks push. See the buildbuddy setup guide in README-Bazel.md to set up caching on your fork"
|
||||
fi
|
||||
|
||||
- name: Set with key
|
||||
env:
|
||||
API_KEY: ${{ inputs.token }}
|
||||
if: ${{ env.API_KEY != '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "API Key detected!"
|
||||
echo "build:build_buddy --remote_header=x-buildbuddy-api-key=${{ env.API_KEY }}" > bazel_auth.rc
|
||||
158
.github/labeler.yml
vendored
158
.github/labeler.yml
vendored
@@ -1,62 +1,96 @@
|
||||
'2027':
|
||||
- base-branch: '2027'
|
||||
'component: apriltag':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: apriltag/**
|
||||
'component: command-based':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: commandsv2/**
|
||||
'component: cscore':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: cscore/**
|
||||
'component: datalogtool':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: datalogtool/**
|
||||
'component: epilogue':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: epilogue-*/**
|
||||
'component: examples':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpilib*Examples/**
|
||||
'component: glass':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: glass/**
|
||||
'component: hal':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: hal/**
|
||||
'component: ntcore':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ntcore/**
|
||||
'component: outlineviewer':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: outlineviewer/**
|
||||
'component: sysid':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: sysid/**
|
||||
'component: wpilibc':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpilibc/**
|
||||
'component: wpilibj':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpilibj/**
|
||||
'component: wpimath':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpimath/**
|
||||
'component: wpinet':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpinet/**
|
||||
'component: wpiunits':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpiunits/**
|
||||
'component: wpiutil':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpiutil/**
|
||||
'component: wpical':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpical/**
|
||||
'component: usage reporting':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: hal/src/generate/**
|
||||
'attn: NI':
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: hal/src/generate/**
|
||||
"build":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
[
|
||||
.github/actions/**,
|
||||
.github/workflows/**,
|
||||
cmake/*,
|
||||
shared/**,
|
||||
upstream_utils/**,
|
||||
"**/*.bzl",
|
||||
"**/*.cmake",
|
||||
"**/*.gradle",
|
||||
"**/CMakeLists.txt",
|
||||
"**/BUILD.bazel",
|
||||
]
|
||||
"component: apriltag":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: apriltag/**
|
||||
"component: command-based":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: commandsv2/**
|
||||
"component: commands v3":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: commandsv3/**
|
||||
"component: cscore":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: cscore/**
|
||||
"component: datalogtool":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: tools/datalogtool/**
|
||||
"component: epilogue":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: epilogue-*/**
|
||||
"component: examples":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpilib*Examples/**
|
||||
"component: glass":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: glass/**
|
||||
"component: hal":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: hal/**
|
||||
"component: javac plugin":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: javacPlugin/**
|
||||
"component: ntcore":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: ntcore/**
|
||||
"component: outlineviewer":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: tools/outlineviewer/**
|
||||
"component: romi":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: romiVendordep/**
|
||||
"component: sysid":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: tools/sysid/**
|
||||
"component: wpiannotations":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpiannotations/**
|
||||
"component: wpilibc":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpilibc/**
|
||||
"component: wpilibj":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpilibj/**
|
||||
"component: wpimath":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpimath/**
|
||||
"component: wpinet":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpinet/**
|
||||
"component: wpiunits":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpiunits/**
|
||||
"component: wpiutil":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: wpiutil/**
|
||||
"component: wpical":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: tools/wpical/**
|
||||
"component: xrp":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: xrpVendordep/**
|
||||
"component: usage reporting":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: hal/src/generate/**
|
||||
"os: simulation":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "**/simulation/**"
|
||||
"robotpy":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "**python/**"
|
||||
"type: testing":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file: "**/test/**"
|
||||
|
||||
105
.github/workflows/bazel.yml
vendored
105
.github/workflows/bazel.yml
vendored
@@ -12,33 +12,35 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, action: "build" }
|
||||
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, action: "build" }
|
||||
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, action: "build" }
|
||||
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, action: "build" }
|
||||
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, action: "test" }
|
||||
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, action: "test" }
|
||||
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, action: "test" }
|
||||
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, action: "test" }
|
||||
- { name: "Linux System Core", classifier: "linuxsystemcore", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "build" }
|
||||
- { name: "Linux System Core Debug", classifier: "linuxsystemcoredebug", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "build" }
|
||||
- { name: "Linux System Core Static", classifier: "linuxsystemcorestatic", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "build" }
|
||||
- { name: "Linux System Core Static Debug", classifier: "linuxsystemcorestaticdebug", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "build" }
|
||||
- { name: "Linux x86-64", classifier: "linuxx86-64,headers,sources", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "test" }
|
||||
- { name: "Linux x86-64 Debug", classifier: "linuxx86-64debug", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "test" }
|
||||
- { name: "Linux x86-64 Static", classifier: "linuxx86-64static", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "test" }
|
||||
- { name: "Linux x86-64 Static Debug", classifier: "linuxx86-64staticdebug", os: ubuntu-24.04, container: wpilib/debian-base:trixie, action: "test" }
|
||||
|
||||
- { name: "macOS", classifier: "osxuniversal,osxuniversaldebug,headers,sources,osxuniversalstatic,osxuniversalstaticdebug,linuxsystemcore,linuxsystemcoredebug,linuxsystemcorestatic,linuxsystemcorestaticdebug", os: macOS-15, action: "test" }
|
||||
- { name: "macOS", classifier: "osxuniversal,osxuniversaldebug,headers,sources,osxuniversalstatic,osxuniversalstaticdebug,linuxsystemcore,linuxsystemcoredebug,linuxsystemcorestatic,linuxsystemcorestaticdebug", os: macOS-15, container: "", action: "test" }
|
||||
|
||||
- { name: "Windows x86-64", classifier: "windowsx86-64,windowsx86-64static,headers,sources", os: windows-2022, action: "test" }
|
||||
- { name: "Windows x86-64 Debug", classifier: "windowsx86-64debug,windowsx86-64staticdebug", os: windows-2022, action: "test" }
|
||||
- { name: "Windows x86-64", classifier: "windowsx86-64,windowsx86-64static,headers,sources", os: windows-2022, container: "", action: "test" }
|
||||
- { name: "Windows x86-64 Debug", classifier: "windowsx86-64debug,windowsx86-64staticdebug", os: windows-2022, container: "", action: "test" }
|
||||
|
||||
- { name: "Windows ARM64", classifier: "windowsarm64,windowsarm64static", os: windows-2022, action: "build" }
|
||||
- { name: "Windows ARM64 Debug", classifier: "windowsarm64debug,windowsarm64staticdebug", os: windows-2022, action: "build" }
|
||||
- { name: "Windows ARM64", classifier: "windowsarm64,windowsarm64static", os: windows-2022, container: "", action: "build" }
|
||||
- { name: "Windows ARM64 Debug", classifier: "windowsarm64debug,windowsarm64staticdebug", os: windows-2022, container: "", action: "build" }
|
||||
|
||||
- { name: "Windows System Core", classifier: "linuxsystemcore,linuxsystemcorestatic", os: windows-2022, action: "build" }
|
||||
- { name: "Windows System Core Debug", classifier: "linuxsystemcoredebug,linuxsystemcorestaticdebug", os: windows-2022, action: "build" }
|
||||
- { name: "Windows System Core", classifier: "linuxsystemcore,linuxsystemcorestatic", os: windows-2022, container: "", action: "build" }
|
||||
- { name: "Windows System Core Debug", classifier: "linuxsystemcoredebug,linuxsystemcorestaticdebug", os: windows-2022, container: "", action: "build" }
|
||||
|
||||
name: "${{ matrix.action == 'test' && 'Test' || 'Build' }} ${{ matrix.name }}"
|
||||
runs-on: ${{ matrix.os }}
|
||||
container: ${{ matrix.container }}
|
||||
steps:
|
||||
- name: Check disk free space pre-cleanup
|
||||
run: df -h
|
||||
|
||||
- name: Free disk space (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: false
|
||||
@@ -48,8 +50,9 @@ jobs:
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
|
||||
- name: Free disk space (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
# CodeQL: 5G
|
||||
# go: 748M
|
||||
# Android: 12G
|
||||
@@ -57,7 +60,6 @@ jobs:
|
||||
rm -rf /Users/runner/hostedtoolcache/CodeQL
|
||||
rm -rf /Users/runner/hostedtoolcache/go
|
||||
rm -rf /Users/runner/Library/Android
|
||||
if: startsWith(matrix.os, 'macOS')
|
||||
|
||||
- name: Check disk free space post-cleanup
|
||||
run: df -h
|
||||
@@ -65,17 +67,24 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
with: { fetch-depth: 0 }
|
||||
|
||||
- id: Setup_bazel_remote
|
||||
uses: ./.github/actions/setup-bazel-remote
|
||||
- id: Setup_bazel_cache
|
||||
uses: ./.github/actions/setup-bazel-cache
|
||||
with:
|
||||
username: ${{ secrets.BAZEL_CACHE_USERNAME }}
|
||||
password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
|
||||
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
|
||||
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
|
||||
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
|
||||
|
||||
- name: Install apt dependencies
|
||||
if: matrix.os == 'ubuntu-24.04'
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev libx11-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev avahi-daemon
|
||||
|
||||
- if: matrix.os == 'ubuntu-24.04'
|
||||
- name: Setup avahi-daemon
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo service dbus start
|
||||
sudo avahi-daemon -D
|
||||
|
||||
- if: runner.os == 'Linux'
|
||||
uses: bazel-contrib/setup-bazel@0.15.0
|
||||
with:
|
||||
bazelisk-cache: true
|
||||
@@ -85,12 +94,12 @@ jobs:
|
||||
- name: bazel ${{ matrix.action }}
|
||||
run: |
|
||||
ACTION='${{ matrix.action }}'
|
||||
if [[ "${ACTION}" == "build" ]]; then
|
||||
if [ "${ACTION}" = "build" ]; then
|
||||
TARGETS=:publish
|
||||
else
|
||||
TARGETS=...
|
||||
fi
|
||||
if [[ "${{ matrix.os }}" == "windows-2022" ]]; then
|
||||
if [ "${{ runner.os }}" = "Windows" ]; then
|
||||
bazel --output_user_root=C:\\bazelroot ${ACTION} ${TARGETS} --config=ci -c opt --repo_env=WPI_PUBLISH_CLASSIFIER_FILTER='${{ matrix.classifier }}'
|
||||
else
|
||||
bazel ${ACTION} ${TARGETS} --config=ci -c opt --repo_env=WPI_PUBLISH_CLASSIFIER_FILTER='${{ matrix.classifier }}'
|
||||
@@ -136,6 +145,27 @@ jobs:
|
||||
path: "*-bazel-lint-fixes.patch"
|
||||
if: ${{ failure() }}
|
||||
|
||||
mod-lock:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Check lockfile
|
||||
run: bazel mod deps --lockfile_mode=error
|
||||
|
||||
- run: bazel mod deps --lockfile_mode=update
|
||||
if: ${{ failure() }}
|
||||
|
||||
- name: Generate diff
|
||||
run: git diff HEAD > bazel-mod-lock-fixes.patch
|
||||
if: ${{ failure() }}
|
||||
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
archive: false
|
||||
path: "bazel-mod-lock-fixes.patch"
|
||||
if: ${{ failure() }}
|
||||
|
||||
non_robotpy_pregeneration:
|
||||
name: "Non-RobotPy Pregen"
|
||||
runs-on: ubuntu-24.04
|
||||
@@ -143,14 +173,15 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
with: { fetch-depth: 0 }
|
||||
|
||||
- id: Setup_bazel_remote
|
||||
uses: ./.github/actions/setup-bazel-remote
|
||||
- id: Setup_bazel_cache
|
||||
uses: ./.github/actions/setup-bazel-cache
|
||||
with:
|
||||
username: ${{ secrets.BAZEL_CACHE_USERNAME }}
|
||||
password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
|
||||
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
|
||||
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
|
||||
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
|
||||
|
||||
- name: Run Non-RobotPy pregeneration
|
||||
run: bazel run //:write_pregenerated_files
|
||||
run: bazel run --config=ci //:write_pregenerated_files
|
||||
|
||||
- name: Check Output
|
||||
run: git --no-pager diff --exit-code HEAD
|
||||
@@ -172,21 +203,23 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
with: { fetch-depth: 0 }
|
||||
|
||||
- id: Setup_build_buddy
|
||||
uses: ./.github/actions/setup-build-buddy
|
||||
- id: Setup_bazel_cache
|
||||
uses: ./.github/actions/setup-bazel-cache
|
||||
with:
|
||||
token: ${{ secrets.BUILDBUDDY_API_KEY }}
|
||||
bazel_remote_username: ${{ secrets.BAZEL_CACHE_USERNAME }}
|
||||
bazel_remote_password: ${{ secrets.BAZEL_CACHE_PASSWORD }}
|
||||
buildbuddy_token: ${{ secrets.BUILDBUDDY_API_KEY }}
|
||||
|
||||
# You should ensure the headers are correct before trying to pregen files
|
||||
- name: Test Scan Headers
|
||||
run: bazel test //... -k --test_tag_filters=robotpy_scan_headers --build_tests_only
|
||||
run: bazel test --config=ci //... -k --test_tag_filters=robotpy_scan_headers --build_tests_only
|
||||
shell: bash
|
||||
|
||||
- name: Run yaml file generation
|
||||
run: bazel run //:write_robotpy_update_yaml_files
|
||||
run: bazel run --config=ci //:write_robotpy_update_yaml_files
|
||||
|
||||
- name: Run build file generation
|
||||
run: bazel run //:write_robotpy_generated_pybind_files
|
||||
run: bazel run --config=ci //:write_robotpy_generated_pybind_files
|
||||
|
||||
- name: Check Output
|
||||
run: git --no-pager diff --exit-code HEAD
|
||||
|
||||
7
.github/workflows/cmake-android.yml
vendored
7
.github/workflows/cmake-android.yml
vendored
@@ -33,11 +33,6 @@ jobs:
|
||||
ndk-version: r27d
|
||||
add-to-path: false
|
||||
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 25
|
||||
|
||||
- name: Install sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
|
||||
@@ -45,7 +40,7 @@ jobs:
|
||||
run: sudo apt-get update && sudo apt-get install -y ninja-build
|
||||
|
||||
- name: configure
|
||||
run: cmake --preset with-sccache -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_WPILIB=OFF -DWITH_GUI=OFF -DWITH_CSCORE=OFF -DWITH_TESTS=OFF -DWITH_SIMULATION_MODULES=OFF -DWITH_JAVA=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_PLATFORM=android-24
|
||||
run: cmake --preset with-sccache -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_WPILIB=OFF -DWITH_GUI=OFF -DWITH_CSCORE=OFF -DWITH_TESTS=OFF -DWITH_SIMULATION_MODULES=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_PLATFORM=android-24
|
||||
env:
|
||||
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
|
||||
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
|
||||
|
||||
8
.github/workflows/cmake.yml
vendored
8
.github/workflows/cmake.yml
vendored
@@ -18,8 +18,8 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-24.04
|
||||
name: Linux
|
||||
container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
flags: "--preset with-java-and-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
|
||||
container: wpilib/systemcore-cross-debian:trixie
|
||||
flags: "--preset with-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
|
||||
- os: macOS-15
|
||||
name: macOS
|
||||
container: ""
|
||||
@@ -35,7 +35,7 @@ jobs:
|
||||
steps:
|
||||
- name: Install dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv-java ninja-build
|
||||
run: sudo apt-get update && sudo apt-get install -y libopencv-dev ninja-build
|
||||
|
||||
- name: Setup avahi-daemon
|
||||
if: runner.os == 'Linux'
|
||||
@@ -55,7 +55,7 @@ jobs:
|
||||
uses: lukka/get-cmake@v3.29.3
|
||||
|
||||
- name: Install sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
uses: mozilla-actions/sccache-action@v0.0.10
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
|
||||
53
.github/workflows/gradle.yml
vendored
53
.github/workflows/gradle.yml
vendored
@@ -19,13 +19,13 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
- container: wpilib/systemcore-cross-debian:trixie
|
||||
artifact-name: Systemcore
|
||||
build-options: "-Ponlylinuxsystemcore"
|
||||
- container: wpilib/aarch64-cross-ubuntu:2027-bookworm-24.04
|
||||
- container: wpilib/aarch64-cross-debian:trixie
|
||||
artifact-name: Arm64
|
||||
build-options: "-Ponlylinuxarm64"
|
||||
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
- container: wpilib/systemcore-cross-debian:trixie
|
||||
artifact-name: Linux
|
||||
build-options: "-Ponlylinuxx86-64"
|
||||
name: "Build - ${{ matrix.artifact-name }}"
|
||||
@@ -54,7 +54,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- name: Set release environment variable
|
||||
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
|
||||
if: startsWith(github.ref, 'refs/tags/v2027')
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
- name: Build with Gradle
|
||||
uses: wpilibsuite/docker-run-action@v4
|
||||
with:
|
||||
@@ -127,6 +127,7 @@ jobs:
|
||||
run: df -h
|
||||
|
||||
- name: Free disk space (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
# CodeQL: 5G
|
||||
# go: 748M
|
||||
# Android: 12G
|
||||
@@ -134,7 +135,6 @@ jobs:
|
||||
rm -rf /Users/runner/hostedtoolcache/CodeQL
|
||||
rm -rf /Users/runner/hostedtoolcache/go
|
||||
rm -rf /Users/runner/Library/Android
|
||||
if: startsWith(matrix.os, 'macOS')
|
||||
|
||||
- name: Check disk free space post-cleanup
|
||||
run: df -h
|
||||
@@ -155,16 +155,16 @@ jobs:
|
||||
keychain-password: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
|
||||
if: |
|
||||
matrix.artifact-name == 'macOS' && (github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027')))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
|
||||
- name: Set Keychain Lock Timeout
|
||||
run: security set-keychain-settings -lut 21600
|
||||
if: |
|
||||
matrix.artifact-name == 'macOS' && (github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027')))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
|
||||
- name: Set release environment variable
|
||||
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
if: startsWith(github.ref, 'refs/tags/v2027')
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew ${{ matrix.task }} --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
|
||||
env:
|
||||
@@ -174,7 +174,7 @@ jobs:
|
||||
run: ./gradlew copyAllOutputs --build-cache -PbuildServer -PskipJavaFormat -PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
|
||||
if: |
|
||||
matrix.artifact-name == 'macOS' && (github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027')))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.artifact-name }}
|
||||
@@ -195,10 +195,10 @@ jobs:
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 25
|
||||
java-version: 26
|
||||
- name: Set release environment variable
|
||||
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
|
||||
if: startsWith(github.ref, 'refs/tags/v2027')
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew docs:zipDocs --build-cache -PbuildServer -PdocWarningsAsErrors ${{ env.EXTRA_GRADLE_ARGS }}
|
||||
env:
|
||||
@@ -240,17 +240,12 @@ jobs:
|
||||
run: |
|
||||
echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
|
||||
echo "BRANCH=beta" >> $GITHUB_ENV
|
||||
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
- name: Set environment variables (Release)
|
||||
run: |
|
||||
echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
|
||||
echo "BRANCH=release" >> $GITHUB_ENV
|
||||
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, '2027')
|
||||
- name: Set environment variables (2027)
|
||||
run: |
|
||||
echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
|
||||
echo "BRANCH=2027" >> $GITHUB_ENV
|
||||
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '2027')
|
||||
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta')
|
||||
- name: Install SSH Client 🔑
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
@@ -284,7 +279,7 @@ jobs:
|
||||
- name: Free disk space
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: false
|
||||
@@ -298,47 +293,47 @@ jobs:
|
||||
- uses: actions/checkout@v6
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
with:
|
||||
repository: wpilibsuite/build-tools
|
||||
- uses: actions/download-artifact@v7
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
with:
|
||||
path: combiner/products/build/allOutputs
|
||||
- name: Flatten Artifacts
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
run: rsync -a --delete combiner/products/build/allOutputs/*/* combiner/products/build/allOutputs/
|
||||
- name: Check version number exists
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
run: |
|
||||
cat combiner/products/build/allOutputs/version.txt
|
||||
test -s combiner/products/build/allOutputs/version.txt
|
||||
- uses: actions/setup-java@v5
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 25
|
||||
- name: Combine (2027)
|
||||
- name: Combine
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
github.ref == 'refs/heads/2027'
|
||||
github.ref == 'refs/heads/main'
|
||||
run: cd combiner && ./gradlew publish -Pallwpilib -Pbuild2027
|
||||
env:
|
||||
RUN_AZURE_ARTIFACTORY_RELEASE: "TRUE"
|
||||
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
|
||||
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
|
||||
- name: Combine (2027 Release)
|
||||
- name: Combine (Release)
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
startsWith(github.ref, 'refs/tags/v2027')
|
||||
startsWith(github.ref, 'refs/tags/v')
|
||||
run: cd combiner && ./gradlew publish -Pallwpilib -PreleaseRepoPublish -Pbuild2027
|
||||
env:
|
||||
RUN_AZURE_ARTIFACTORY_RELEASE: "TRUE"
|
||||
@@ -347,7 +342,7 @@ jobs:
|
||||
- uses: actions/upload-artifact@v7
|
||||
if: |
|
||||
github.repository == 'wpilibsuite/allwpilib' &&
|
||||
(github.ref == 'refs/heads/2027' || startsWith(github.ref, 'refs/tags/v2027'))
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
with:
|
||||
name: Maven
|
||||
path: ~/releases
|
||||
|
||||
46
.github/workflows/lint-format.yml
vendored
46
.github/workflows/lint-format.yml
vendored
@@ -28,7 +28,7 @@ jobs:
|
||||
- name: Fetch all history and metadata
|
||||
run: |
|
||||
git checkout -b pr
|
||||
git branch -f 2027 origin/2027
|
||||
git branch -f main origin/main
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
@@ -36,9 +36,9 @@ jobs:
|
||||
- name: Install wpiformat
|
||||
run: |
|
||||
python -m venv ${{ runner.temp }}/wpiformat
|
||||
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2026.57
|
||||
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2026.64
|
||||
- name: Run
|
||||
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -default-branch 2027
|
||||
run: ${{ runner.temp }}/wpiformat/bin/wpiformat
|
||||
- name: Check output
|
||||
run: git --no-pager diff --exit-code HEAD
|
||||
- name: Generate diff
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
name: "clang-tidy"
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [validation]
|
||||
container: wpilib/ubuntu-base:24.04
|
||||
container: wpilib/debian-base:trixie
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
@@ -70,7 +70,7 @@ jobs:
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/allwpilib/allwpilib
|
||||
git checkout -b pr
|
||||
git branch -f 2027 origin/2027
|
||||
git branch -f main origin/main
|
||||
- name: Set up Python 3.12
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
@@ -78,23 +78,23 @@ jobs:
|
||||
- name: Install wpiformat
|
||||
run: |
|
||||
python -m venv ${{ runner.temp }}/wpiformat
|
||||
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2026.57
|
||||
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2026.64
|
||||
- name: Create compile_commands.json
|
||||
run: |
|
||||
./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
|
||||
./.github/workflows/fix_compile_commands.py build/TargetedCompileCommands/linuxx86-64release/compile_commands.json
|
||||
./.github/workflows/fix_compile_commands.py build/TargetedCompileCommands/linuxx86-64debug/compile_commands.json
|
||||
- name: List changed files
|
||||
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -default-branch 2027 -list-changed-files
|
||||
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -list-changed-files
|
||||
- name: Run clang-tidy release
|
||||
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -default-branch 2027 -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64release
|
||||
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64release
|
||||
- name: Run clang-tidy debug
|
||||
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -default-branch 2027 -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64debug
|
||||
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64debug
|
||||
javaformat:
|
||||
name: "Java format"
|
||||
runs-on: ubuntu-24.04
|
||||
needs: [validation]
|
||||
container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
container: wpilib/debian-base:trixie
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
@@ -103,7 +103,7 @@ jobs:
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/allwpilib/allwpilib
|
||||
git checkout -b pr
|
||||
git branch -f 2027 origin/2027
|
||||
git branch -f main origin/main
|
||||
- name: Run Java format
|
||||
run: ./gradlew javaFormat spotbugsMain spotbugsTest spotbugsDev
|
||||
- name: Check output
|
||||
@@ -123,3 +123,27 @@ jobs:
|
||||
echo '' >> $GITHUB_STEP_SUMMARY
|
||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||
if: ${{ failure() }}
|
||||
|
||||
check-spelling:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: misspell
|
||||
uses: reviewdog/action-misspell@v1
|
||||
with:
|
||||
reporter: "github-check"
|
||||
fail_level: "error"
|
||||
exclude: |
|
||||
**/*.svg
|
||||
**/thirdparty/**
|
||||
**/upstream_utils/**
|
||||
**/generated/**
|
||||
./wpigui/src/main/native/cpp/portable-file-dialogs.*
|
||||
./wpimath/src/main/native/include/wpi/units/base.hpp
|
||||
./wpinet/src/main/native/linux/AvahiClient.*
|
||||
./wpinet/src/main/native/cpp/http_parser.cpp
|
||||
./wpinet/src/main/native/include/wpi/net/http_parser.hpp
|
||||
./wpiutil/src/main/native/include/wpi/util/FastQueue.hpp
|
||||
./wpiutil/src/test/native/cpp/json/**
|
||||
./wpiutil/src/test/native/cpp/llvm/**
|
||||
./wpiutil/src/test/native/cpp/span/**
|
||||
|
||||
10
.github/workflows/sanitizers.yml
vendored
10
.github/workflows/sanitizers.yml
vendored
@@ -19,7 +19,7 @@ jobs:
|
||||
- name: asan
|
||||
cmake-flags: "-DCMAKE_BUILD_TYPE=Asan"
|
||||
ctest-env: ""
|
||||
ctest-flags: "-E 'wpilibc'"
|
||||
ctest-flags: ""
|
||||
- name: tsan
|
||||
cmake-flags: "-DCMAKE_BUILD_TYPE=Tsan"
|
||||
ctest-env: "TSAN_OPTIONS=second_deadlock_stack=1:suppressions=$GITHUB_WORKSPACE/tsan_suppressions.txt"
|
||||
@@ -30,18 +30,18 @@ jobs:
|
||||
ctest-flags: ""
|
||||
name: "${{ matrix.name }}"
|
||||
runs-on: ubuntu-24.04
|
||||
container: wpilib/roborio-cross-ubuntu:2025-24.04
|
||||
container: wpilib/debian-base:trixie
|
||||
steps:
|
||||
- name: Install Dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv-java clang-18 ninja-build avahi-daemon
|
||||
run: sudo apt-get update && sudo apt-get install -y libopencv-dev clang-18 ninja-build avahi-daemon
|
||||
|
||||
- name: Install sccache
|
||||
uses: mozilla-actions/sccache-action@v0.0.9
|
||||
uses: mozilla-actions/sccache-action@v0.0.10
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: configure
|
||||
run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-18 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-18 -DWITH_JAVA=OFF ${{ matrix.cmake-flags }} ..
|
||||
run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-18 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-18 ${{ matrix.cmake-flags }} ..
|
||||
env:
|
||||
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
|
||||
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
|
||||
|
||||
24
.github/workflows/sentinel-build.yml
vendored
24
.github/workflows/sentinel-build.yml
vendored
@@ -23,13 +23,13 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
- container: wpilib/systemcore-cross-debian:trixie
|
||||
artifact-name: Systemcore
|
||||
build-options: "-Ponlylinuxsystemcore"
|
||||
- container: wpilib/aarch64-cross-ubuntu:2027-bookworm-24.04
|
||||
- container: wpilib/aarch64-cross-debian:trixie
|
||||
artifact-name: Arm64
|
||||
build-options: "-Ponlylinuxarm64"
|
||||
- container: wpilib/systemcore-cross-ubuntu:2027-24.04
|
||||
- container: wpilib/systemcore-cross-debian:trixie
|
||||
artifact-name: Linux
|
||||
build-options: "-Ponlylinuxx86-64"
|
||||
name: "Build - ${{ matrix.artifact-name }}"
|
||||
@@ -54,7 +54,11 @@ jobs:
|
||||
with:
|
||||
image: ${{ matrix.container }}
|
||||
options: -v ${{ github.workspace }}:/work -w /work -e GITHUB_REF -e CI
|
||||
run: ./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
|
||||
# Start avahi-daemon and build
|
||||
run: |
|
||||
service dbus start
|
||||
avahi-daemon -D
|
||||
./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
|
||||
- name: Check free disk space
|
||||
run: df .
|
||||
- uses: actions/upload-artifact@v7
|
||||
@@ -130,12 +134,13 @@ jobs:
|
||||
if: |
|
||||
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
|
||||
- name: Check disk free space (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: wmic logicaldisk get caption, freespace
|
||||
if: matrix.os == 'windows-2022'
|
||||
- name: Check disk free space pre-cleanup (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: df -h .
|
||||
if: matrix.os == 'macOS-15'
|
||||
- name: Cleanup disk space
|
||||
if: runner.os == 'macOS'
|
||||
# CodeQL: 5G
|
||||
# go: 748M
|
||||
# Android: 12G
|
||||
@@ -143,10 +148,9 @@ jobs:
|
||||
rm -rf /Users/runner/hostedtoolcache/CodeQL
|
||||
rm -rf /Users/runner/hostedtoolcache/go
|
||||
rm -rf /Users/runner/Library/Android
|
||||
if: matrix.os == 'macOS-15'
|
||||
- name: Check disk free space post-cleanup (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: df -h .
|
||||
if: matrix.os == 'macOS-15'
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew ${{ matrix.task }} -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
|
||||
- name: Sign Libraries with Developer ID
|
||||
@@ -154,11 +158,11 @@ jobs:
|
||||
if: |
|
||||
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
|
||||
- name: Check disk free space (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
run: wmic logicaldisk get caption, freespace
|
||||
if: matrix.os == 'windows-2022'
|
||||
- name: Check disk free space (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: df -h .
|
||||
if: matrix.os == 'macOS-15'
|
||||
- uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.artifact-name }}
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -261,3 +261,8 @@ bazel_auth.rc
|
||||
|
||||
# Copybara user config
|
||||
shared/bazel/copybara/.copybara.json
|
||||
|
||||
# Nix files
|
||||
shell.nix
|
||||
flake.nix
|
||||
flake.lock
|
||||
|
||||
@@ -40,4 +40,5 @@ licenseUpdateExclude {
|
||||
wpiutil/src/main/native/cpp/Base64\.cpp$
|
||||
wpiutil/src/main/native/cpp/sha1\.cpp$
|
||||
wpiutil/src/main/native/include/wpi/util/sha1\.hpp$
|
||||
wpinet/src/main/native/linux/AvahiClient\.hpp$
|
||||
}
|
||||
|
||||
@@ -63,9 +63,7 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
# Options for building certain parts of the repo. Everything is built by default.
|
||||
option(BUILD_SHARED_LIBS "Build with shared libs (needed for JNI)" ON)
|
||||
option(WITH_JAVA "Include Java and JNI in the build" OFF)
|
||||
option(WITH_JAVA_SOURCE "Build Java source jars" ${WITH_JAVA})
|
||||
option(BUILD_SHARED_LIBS "Build with shared libs" ON)
|
||||
option(WITH_DOCS "Build Doxygen docs (needs Git for versioning)" OFF)
|
||||
cmake_dependent_option(
|
||||
DOCS_WARNINGS_AS_ERRORS
|
||||
@@ -78,13 +76,6 @@ option(WITH_CSCORE "Build cscore (needs OpenCV)" ON)
|
||||
option(WITH_NTCORE "Build ntcore" ON)
|
||||
option(WITH_WPICAL "Build wpical" OFF)
|
||||
option(WITH_WPIMATH "Build wpimath" ON)
|
||||
cmake_dependent_option(
|
||||
WITH_WPIUNITS
|
||||
"Build wpiunits"
|
||||
ON
|
||||
WITH_JAVA
|
||||
OFF
|
||||
)
|
||||
option(WITH_WPILIB "Build hal, wpilibc/j, and developerRobot (needs OpenCV)" ON)
|
||||
option(WITH_EXAMPLES "Build examples" OFF)
|
||||
option(WITH_TESTS "Build unit tests (requires internet connection)" ON)
|
||||
@@ -98,26 +89,9 @@ option(USE_SYSTEM_LIBUV "Use system libuv" OFF)
|
||||
option(USE_SYSTEM_EIGEN "Use system eigen" OFF)
|
||||
option(USE_LINKED_AVAHI "Use directly linked Avahi instead of loading at runtime" OFF)
|
||||
|
||||
# Options for location of OpenCV Java.
|
||||
set(OPENCV_JAVA_INSTALL_DIR "" CACHE PATH "Location to search for the OpenCV jar file")
|
||||
|
||||
# Options for compilation flags.
|
||||
option(NO_WERROR "Disable -Werror flag during compilation" OFF)
|
||||
|
||||
if(NOT WITH_JAVA OR NOT WITH_CSCORE)
|
||||
if(NOT "${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "")
|
||||
message(
|
||||
WARNING
|
||||
"
|
||||
WARNING: OpenCV Java dir set but java is not enabled!
|
||||
It will be ignored.
|
||||
"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
wpilib_config(OPTIONS WITH_JAVA REQUIRES BUILD_SHARED_LIBS)
|
||||
|
||||
wpilib_config(OPTIONS WITH_SIMULATION_MODULES REQUIRES BUILD_SHARED_LIBS WITH_WPILIB WITH_NTCORE)
|
||||
|
||||
wpilib_config(OPTIONS WITH_CSCORE REQUIRES WITH_NTCORE)
|
||||
@@ -126,17 +100,7 @@ wpilib_config(OPTIONS WITH_GUI REQUIRES WITH_NTCORE WITH_WPIMATH)
|
||||
|
||||
wpilib_config(OPTIONS WITH_WPILIB REQUIRES WITH_NTCORE WITH_WPIMATH)
|
||||
|
||||
wpilib_config(OPTIONS WITH_WPIMATH WITH_JAVA REQUIRES WITH_WPIUNITS)
|
||||
|
||||
set(include_dest include)
|
||||
set(java_lib_dest java)
|
||||
if(WITH_JAVA OR WITH_JAVA_SOURCE)
|
||||
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked" "-proc:full")
|
||||
find_package(Java REQUIRED COMPONENTS Development)
|
||||
if(NOT ANDROID)
|
||||
find_package(JNI REQUIRED COMPONENTS JVM)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_DOCS)
|
||||
find_package(Doxygen REQUIRED)
|
||||
@@ -283,13 +247,8 @@ endif()
|
||||
|
||||
set(FILENAME_DEP_REPLACE "get_filename_component(SELF_DIR \"$\{CMAKE_CURRENT_LIST_FILE\}\" PATH)")
|
||||
set(SELF_DIR "$\{SELF_DIR\}")
|
||||
set(WPIUNITS_DEP_REPLACE_IMPL "find_dependency(wpiunits)")
|
||||
set(WPIANNOTATIONS_DEP_REPLACE_IMPL "find_dependency(wpiannotations)")
|
||||
set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)")
|
||||
set(DATALOG_DEP_REPLACE "find_dependency(datalog)")
|
||||
if(WITH_JAVA)
|
||||
add_subdirectory(wpiannotations)
|
||||
endif()
|
||||
|
||||
add_subdirectory(wpiutil)
|
||||
|
||||
@@ -303,20 +262,10 @@ if(WITH_NTCORE)
|
||||
endif()
|
||||
|
||||
if(WITH_WPIMATH)
|
||||
if(WITH_JAVA)
|
||||
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
|
||||
add_subdirectory(wpiunits)
|
||||
endif()
|
||||
set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)")
|
||||
add_subdirectory(wpimath)
|
||||
endif()
|
||||
|
||||
if(WITH_WPIUNITS AND NOT WITH_WPIMATH)
|
||||
# In case of building wpiunits standalone
|
||||
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
|
||||
add_subdirectory(wpiunits)
|
||||
endif()
|
||||
|
||||
if(WITH_GUI)
|
||||
add_subdirectory(fields)
|
||||
add_subdirectory(thirdparty/imgui_suite)
|
||||
@@ -347,16 +296,10 @@ endif()
|
||||
|
||||
if(WITH_WPILIB)
|
||||
set(APRILTAG_DEP_REPLACE "find_dependency(apriltag)")
|
||||
set(COMMANDSV3_DEP_REPLACE "find_dependency(commandsv3)")
|
||||
set(WPILIBC_DEP_REPLACE "find_dependency(wpilibc)")
|
||||
if(WITH_JAVA)
|
||||
set(WPILIBJ_DEP_REPLACE "find_dependency(wpilibj)")
|
||||
endif()
|
||||
set(COMMAND_DEP_REPLACE "find_dependency(commandsv2)")
|
||||
add_subdirectory(apriltag)
|
||||
add_subdirectory(wpilibj)
|
||||
add_subdirectory(wpilibc)
|
||||
add_subdirectory(commandsv3) # must be after wpilibj
|
||||
add_subdirectory(commandsv2)
|
||||
add_subdirectory(romiVendordep)
|
||||
add_subdirectory(xrpVendordep)
|
||||
|
||||
@@ -24,27 +24,6 @@
|
||||
"CMAKE_C_COMPILER_LAUNCHER": "sccache",
|
||||
"CMAKE_CXX_COMPILER_LAUNCHER": "sccache"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "with-java",
|
||||
"displayName": "",
|
||||
"description": "Ninja config with Java",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "build-cmake",
|
||||
"cacheVariables": {
|
||||
"WITH_JAVA": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "with-java-and-sccache",
|
||||
"displayName": "",
|
||||
"description": "Ninja config with Java and sccache",
|
||||
"generator": "Ninja",
|
||||
"inherits": "with-sccache",
|
||||
"binaryDir": "build-cmake",
|
||||
"cacheVariables": {
|
||||
"WITH_JAVA": "ON"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ So you want to contribute your changes back to WPILib. Great! We have a few cont
|
||||
- Some features, such the addition of C++26 for WPILibC or Functional Interfaces for WPILibJ, are specific to that version of WPILib only. New language features added to C++ must be wrappable in Python for [RobotPy](https://github.com/robotpy).
|
||||
- Changes should have tests.
|
||||
- Code should be well documented.
|
||||
- This involves writing tutorials and/or usage guides for your submitted feature. These articles are then hosted on the [WPILib](https://docs.wpilib.org/) documentation website. See the [frc-docs repository](https://github.com/wpilibsuite/frc-docs) for more information.
|
||||
- This involves writing tutorials and/or usage guides for your submitted feature. These articles are then hosted on the [WPILib](https://docs.wpilib.org/) documentation website. See the [wpilib-docs repository](https://github.com/wpilibsuite/wpilib-docs) for more information.
|
||||
|
||||
## What to Contribute
|
||||
|
||||
|
||||
23
MODULE.bazel
23
MODULE.bazel
@@ -5,19 +5,14 @@ module(
|
||||
|
||||
include("//docs:doxygen.MODULE.bazel")
|
||||
|
||||
include("//shared/bazel/thirdparty/ceres:ceres.MODULE.bazel")
|
||||
|
||||
include("//shared/bazel/thirdparty/libssh:libssh.MODULE.bazel")
|
||||
|
||||
include("//shared/bazel/thirdparty/mrclib:mrclib.MODULE.bazel")
|
||||
|
||||
bazel_dep(name = "apple_support", version = "2.0.0", repo_name = "build_bazel_apple_support")
|
||||
|
||||
# TODO(austin): Upgrade when the patches land.
|
||||
# https://github.com/bazelbuild/rules_cc/pull/430
|
||||
# https://github.com/bazelbuild/rules_cc/pull/431
|
||||
# https://github.com/bazelbuild/rules_cc/pull/432
|
||||
bazel_dep(name = "rules_cc", version = "0.2.13")
|
||||
single_version_override(
|
||||
module_name = "rules_cc",
|
||||
patch_strip = 1,
|
||||
patches = ["//:shared/bazel/patches/rules_cc_windows.patch"],
|
||||
)
|
||||
|
||||
bazel_dep(name = "rules_cc", version = "0.2.17")
|
||||
bazel_dep(name = "rules_pkg", version = "1.1.0")
|
||||
bazel_dep(name = "bazel_features", version = "1.33.0")
|
||||
bazel_dep(name = "aspect_bazel_lib", version = "2.14.0")
|
||||
@@ -53,8 +48,8 @@ maven.install(
|
||||
name = "maven",
|
||||
artifacts = [
|
||||
"org.ejml:ejml-simple:0.44.0",
|
||||
"io.avaje:avaje-jsonb:3.11",
|
||||
"io.avaje:avaje-jsonb-generator:3.11",
|
||||
"io.avaje:avaje-jsonb:3.14",
|
||||
"io.avaje:avaje-jsonb-generator:3.14",
|
||||
"us.hebi.quickbuf:quickbuf-runtime:1.4",
|
||||
"com.google.code.gson:gson:2.13.1",
|
||||
"org.wpilib.thirdparty.opencv:opencv-java:2027-4.13.0-1",
|
||||
|
||||
312
MODULE.bazel.lock
generated
312
MODULE.bazel.lock
generated
@@ -117,7 +117,8 @@
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.0/MODULE.bazel": "b5c17f90458caae90d2ccd114c81970062946f49f355610ed89bebf954f5783c",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.13/MODULE.bazel": "eecdd666eda6be16a8d9dc15e44b5c75133405e820f620a234acc4b1fdc5aa37",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.14/MODULE.bazel": "353c99ed148887ee89c54a17d4100ae7e7e436593d104b668476019023b58df8",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.14/source.json": "55d0a4587c5592fad350f6e698530f4faf0e7dd15e69d43f8d87e220c78bea54",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.17/MODULE.bazel": "1849602c86cb60da8613d2de887f9566a6d354a6df6d7009f9d04a14402f9a84",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.17/source.json": "3832f45d145354049137c0090df04629d9c2b5493dc5c2bf46f1834040133a07",
|
||||
"https://bcr.bazel.build/modules/rules_cc/0.2.8/MODULE.bazel": "f1df20f0bf22c28192a794f29b501ee2018fa37a3862a1a2132ae2940a23a642",
|
||||
"https://bcr.bazel.build/modules/rules_foreign_cc/0.9.0/MODULE.bazel": "c9e8c682bf75b0e7c704166d79b599f93b72cfca5ad7477df596947891feeef6",
|
||||
"https://bcr.bazel.build/modules/rules_fuzzing/0.5.2/MODULE.bazel": "40c97d1144356f52905566c55811f13b299453a14ac7769dfba2ac38192337a8",
|
||||
@@ -204,6 +205,156 @@
|
||||
},
|
||||
"selectedYankedVersions": {},
|
||||
"moduleExtensions": {
|
||||
"@@pybind11_bazel+//:internal_configure.bzl%internal_configure_extension": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "uxP2cZuW027Q8wpZbeJeuW5MXcNBO8GcOK/LNN2sPvQ=",
|
||||
"usagesDigest": "D1r3lfzMuUBFxgG8V6o0bQTLMk3GkaGOaPzw53wrwyw=",
|
||||
"recordedFileInputs": {
|
||||
"@@pybind11_bazel+//MODULE.bazel": "e6f4c20442eaa7c90d7190d8dc539d0ab422f95c65a57cc59562170c58ae3d34"
|
||||
},
|
||||
"recordedDirentsInputs": {},
|
||||
"envVariables": {},
|
||||
"generatedRepoSpecs": {
|
||||
"pybind11": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"build_file": "@@pybind11_bazel+//:pybind11-BUILD.bazel",
|
||||
"strip_prefix": "pybind11-2.12.0",
|
||||
"urls": [
|
||||
"https://github.com/pybind/pybind11/archive/v2.12.0.zip"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"recordedRepoMappingEntries": [
|
||||
[
|
||||
"pybind11_bazel+",
|
||||
"bazel_tools",
|
||||
"bazel_tools"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"@@rules_apple+//apple:apple.bzl%provisioning_profile_repository_extension": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "JNyWptXQtF/Vu+dUIk3wLLXiS47h7sDP2eYWSsD28xU=",
|
||||
"usagesDigest": "vsJl8Rw5NL+5Ag2wdUDoTeRF/5klkXO8545Iy7U1Q08=",
|
||||
"recordedFileInputs": {},
|
||||
"recordedDirentsInputs": {},
|
||||
"envVariables": {},
|
||||
"generatedRepoSpecs": {
|
||||
"local_provisioning_profiles": {
|
||||
"repoRuleId": "@@rules_apple+//apple/internal:local_provisioning_profiles.bzl%provisioning_profile_repository",
|
||||
"attributes": {}
|
||||
}
|
||||
},
|
||||
"recordedRepoMappingEntries": [
|
||||
[
|
||||
"apple_support+",
|
||||
"bazel_skylib",
|
||||
"bazel_skylib+"
|
||||
],
|
||||
[
|
||||
"bazel_tools",
|
||||
"rules_cc",
|
||||
"rules_cc+"
|
||||
],
|
||||
[
|
||||
"rules_apple+",
|
||||
"bazel_skylib",
|
||||
"bazel_skylib+"
|
||||
],
|
||||
[
|
||||
"rules_apple+",
|
||||
"bazel_tools",
|
||||
"bazel_tools"
|
||||
],
|
||||
[
|
||||
"rules_apple+",
|
||||
"build_bazel_apple_support",
|
||||
"apple_support+"
|
||||
],
|
||||
[
|
||||
"rules_apple+",
|
||||
"build_bazel_rules_swift",
|
||||
"rules_swift+"
|
||||
],
|
||||
[
|
||||
"rules_cc+",
|
||||
"bazel_tools",
|
||||
"bazel_tools"
|
||||
],
|
||||
[
|
||||
"rules_cc+",
|
||||
"cc_compatibility_proxy",
|
||||
"rules_cc++compatibility_proxy+cc_compatibility_proxy"
|
||||
],
|
||||
[
|
||||
"rules_cc+",
|
||||
"rules_cc",
|
||||
"rules_cc+"
|
||||
],
|
||||
[
|
||||
"rules_cc++compatibility_proxy+cc_compatibility_proxy",
|
||||
"rules_cc",
|
||||
"rules_cc+"
|
||||
],
|
||||
[
|
||||
"rules_swift+",
|
||||
"bazel_skylib",
|
||||
"bazel_skylib+"
|
||||
],
|
||||
[
|
||||
"rules_swift+",
|
||||
"bazel_tools",
|
||||
"bazel_tools"
|
||||
],
|
||||
[
|
||||
"rules_swift+",
|
||||
"build_bazel_apple_support",
|
||||
"apple_support+"
|
||||
],
|
||||
[
|
||||
"rules_swift+",
|
||||
"build_bazel_rules_swift",
|
||||
"rules_swift+"
|
||||
],
|
||||
[
|
||||
"rules_swift+",
|
||||
"build_bazel_rules_swift_local_config",
|
||||
"rules_swift++non_module_deps+build_bazel_rules_swift_local_config"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"@@rules_apple+//apple:extensions.bzl%non_module_deps": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "UsflLeiazyu2v5pvibcvOeIdDV95S25rT96h4XU1nhY=",
|
||||
"usagesDigest": "M3VqFpeTCo4qmrNKGZw0dxBHvTYDrfV3cscGzlSAhQ4=",
|
||||
"recordedFileInputs": {},
|
||||
"recordedDirentsInputs": {},
|
||||
"envVariables": {},
|
||||
"generatedRepoSpecs": {
|
||||
"xctestrunner": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/google/xctestrunner/archive/b7698df3d435b6491b4b4c0f9fc7a63fbed5e3a6.tar.gz"
|
||||
],
|
||||
"strip_prefix": "xctestrunner-b7698df3d435b6491b4b4c0f9fc7a63fbed5e3a6",
|
||||
"sha256": "ae3a063c985a8633cb7eb566db21656f8db8eb9a0edb8c182312c7f0db53730d"
|
||||
}
|
||||
}
|
||||
},
|
||||
"recordedRepoMappingEntries": [
|
||||
[
|
||||
"rules_apple+",
|
||||
"bazel_tools",
|
||||
"bazel_tools"
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"@@rules_bzlmodrio_toolchains+//:extensions.bzl%sh_configure": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "q+0LgnvjpZ9Y2r2JYzNeYCKGLphbczG73lZ3rBg+XhM=",
|
||||
@@ -852,6 +1003,165 @@
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"@@rules_swift+//swift:extensions.bzl%non_module_deps": {
|
||||
"general": {
|
||||
"bzlTransitiveDigest": "WQxCEBSXJEaQYe860JXZvAQug2B6+/VbBtRIDMF0pOc=",
|
||||
"usagesDigest": "mhACFnrdMv9Wi0Mt67bxocJqviRkDSV+Ee5Mqdj5akA=",
|
||||
"recordedFileInputs": {},
|
||||
"recordedDirentsInputs": {},
|
||||
"envVariables": {},
|
||||
"generatedRepoSpecs": {
|
||||
"com_github_apple_swift_protobuf": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-protobuf/archive/1.20.2.tar.gz"
|
||||
],
|
||||
"sha256": "3fb50bd4d293337f202d917b6ada22f9548a0a0aed9d9a4d791e6fbd8a246ebb",
|
||||
"strip_prefix": "swift-protobuf-1.20.2/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_protobuf/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_grpc_grpc_swift": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/grpc/grpc-swift/archive/1.16.0.tar.gz"
|
||||
],
|
||||
"sha256": "58b60431d0064969f9679411264b82e40a217ae6bd34e17096d92cc4e47556a5",
|
||||
"strip_prefix": "grpc-swift-1.16.0/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_grpc_grpc_swift/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_docc_symbolkit": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-docc-symbolkit/archive/refs/tags/swift-5.10-RELEASE.tar.gz"
|
||||
],
|
||||
"sha256": "de1d4b6940468ddb53b89df7aa1a81323b9712775b0e33e8254fa0f6f7469a97",
|
||||
"strip_prefix": "swift-docc-symbolkit-swift-5.10-RELEASE",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_docc_symbolkit/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_nio": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-nio/archive/2.42.0.tar.gz"
|
||||
],
|
||||
"sha256": "e3304bc3fb53aea74a3e54bd005ede11f6dc357117d9b1db642d03aea87194a0",
|
||||
"strip_prefix": "swift-nio-2.42.0/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_nio_http2": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-nio-http2/archive/1.26.0.tar.gz"
|
||||
],
|
||||
"sha256": "f0edfc9d6a7be1d587e5b403f2d04264bdfae59aac1d74f7d974a9022c6d2b25",
|
||||
"strip_prefix": "swift-nio-http2-1.26.0/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_http2/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_nio_transport_services": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-nio-transport-services/archive/1.15.0.tar.gz"
|
||||
],
|
||||
"sha256": "f3498dafa633751a52b9b7f741f7ac30c42bcbeb3b9edca6d447e0da8e693262",
|
||||
"strip_prefix": "swift-nio-transport-services-1.15.0/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_transport_services/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_nio_extras": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-nio-extras/archive/1.4.0.tar.gz"
|
||||
],
|
||||
"sha256": "4684b52951d9d9937bb3e8ccd6b5daedd777021ef2519ea2f18c4c922843b52b",
|
||||
"strip_prefix": "swift-nio-extras-1.4.0/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_extras/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_log": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-log/archive/1.4.4.tar.gz"
|
||||
],
|
||||
"sha256": "48fe66426c784c0c20031f15dc17faf9f4c9037c192bfac2f643f65cb2321ba0",
|
||||
"strip_prefix": "swift-log-1.4.4/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_log/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_nio_ssl": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-nio-ssl/archive/2.23.0.tar.gz"
|
||||
],
|
||||
"sha256": "4787c63f61dd04d99e498adc3d1a628193387e41efddf8de19b8db04544d016d",
|
||||
"strip_prefix": "swift-nio-ssl-2.23.0/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_nio_ssl/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_collections": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-collections/archive/1.0.4.tar.gz"
|
||||
],
|
||||
"sha256": "d9e4c8a91c60fb9c92a04caccbb10ded42f4cb47b26a212bc6b39cc390a4b096",
|
||||
"strip_prefix": "swift-collections-1.0.4/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_collections/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"com_github_apple_swift_atomics": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"urls": [
|
||||
"https://github.com/apple/swift-atomics/archive/1.1.0.tar.gz"
|
||||
],
|
||||
"sha256": "1bee7f469f7e8dc49f11cfa4da07182fbc79eab000ec2c17bfdce468c5d276fb",
|
||||
"strip_prefix": "swift-atomics-1.1.0/",
|
||||
"build_file": "@@rules_swift+//third_party:com_github_apple_swift_atomics/BUILD.overlay"
|
||||
}
|
||||
},
|
||||
"build_bazel_rules_swift_index_import": {
|
||||
"repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive",
|
||||
"attributes": {
|
||||
"build_file": "@@rules_swift+//third_party:build_bazel_rules_swift_index_import/BUILD.overlay",
|
||||
"canonical_id": "index-import-5.8",
|
||||
"urls": [
|
||||
"https://github.com/MobileNativeFoundation/index-import/releases/download/5.8.0.1/index-import.tar.gz"
|
||||
],
|
||||
"sha256": "28c1ffa39d99e74ed70623899b207b41f79214c498c603915aef55972a851a15"
|
||||
}
|
||||
},
|
||||
"build_bazel_rules_swift_local_config": {
|
||||
"repoRuleId": "@@rules_swift+//swift/internal:swift_autoconfiguration.bzl%swift_autoconfiguration",
|
||||
"attributes": {}
|
||||
}
|
||||
},
|
||||
"recordedRepoMappingEntries": [
|
||||
[
|
||||
"rules_swift+",
|
||||
"bazel_tools",
|
||||
"bazel_tools"
|
||||
],
|
||||
[
|
||||
"rules_swift+",
|
||||
"build_bazel_rules_swift",
|
||||
"rules_swift+"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"facts": {}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
# WPILib CMake Support
|
||||
|
||||
WPILib is normally built with Gradle, however for some systems, such as Linux based coprocessors, Gradle doesn't work correctly, especially if cscore is needed, which requires OpenCV. Furthermore, the CMake build can be used for C++ development because it provides better build caching compared to Gradle. We provide the CMake build for these cases. Although macOS is supported, these docs will only go over Linux and Windows builds, but should mostly work for macOS as well. If you are stuck, you can look at the GitHub workflows for any OS to see how it works.
|
||||
WPILib is normally built with Gradle, however for some systems, such as Linux based coprocessors, Gradle doesn't work correctly, especially if cscore is needed, which requires OpenCV. Furthermore, the CMake build can be used for C++ development because it provides better build caching compared to Gradle. We provide the CMake build for these cases. Although macOS is supported, these docs will only go over Linux and Windows builds, but should mostly work for macOS as well. If you are stuck, you can look at the GitHub workflows for any OS to see how it works. The CMake build does not build Java or Python, only C++.
|
||||
|
||||
## Libraries that get built
|
||||
* apriltag
|
||||
* cameraserver
|
||||
* commandsv2
|
||||
* commandsv3
|
||||
* cscore
|
||||
* datalog
|
||||
* fields
|
||||
@@ -18,7 +17,6 @@ WPILib is normally built with Gradle, however for some systems, such as Linux ba
|
||||
* wpilib (wpilibc, wpilibj, and developerRobot)
|
||||
* wpimath
|
||||
* wpinet
|
||||
* wpiunits
|
||||
* wpiutil
|
||||
* xrpVendordep
|
||||
|
||||
@@ -30,30 +28,24 @@ WPILib is normally built with Gradle, however for some systems, such as Linux ba
|
||||
* wpical
|
||||
* halsim_gui (if simulation extensions are enabled)
|
||||
|
||||
By default, all libraries get built with a default CMake setup. The libraries are built as shared libraries, and include the JNI libraries as well as building the Java JARs. Data Log Tool is only built if libssh is available.
|
||||
By default, all libraries get built with a default CMake setup. The libraries are built as shared libraries. Data Log Tool is only built if libssh is available.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it.
|
||||
|
||||
If you want JNI and Java, you will need a JDK of at least version 25 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
|
||||
|
||||
## Build Options
|
||||
|
||||
The following build options are available:
|
||||
|
||||
* `BUILD_SHARED_LIBS` (ON Default)
|
||||
* This option will cause CMake to build static libraries instead of shared libraries. If this is off, `WITH_JAVA` must be off. Otherwise CMake will error.
|
||||
* This option will cause CMake to build static libraries instead of shared libraries.
|
||||
* `WITH_CSCORE` (ON Default)
|
||||
* This option will cause cscore to be built. Turning this off will implicitly disable cameraserver. If this is off, the OpenCV build requirement is removed.
|
||||
* `WITH_EXAMPLES` (OFF Default)
|
||||
* This option will build C++ examples.
|
||||
* `WITH_GUI` (ON Default)
|
||||
* This option will build GUI items. If this is off, and `WITH_SIMULATION_MODULES` is on, the simulation GUI will not be built.
|
||||
* `WITH_JAVA` (OFF Default)
|
||||
* This option will enable Java and JNI builds. If this is on, `BUILD_SHARED_LIBS` must be on. Otherwise CMake will error.
|
||||
* `WITH_JAVA_SOURCE` (`WITH_JAVA` Default)
|
||||
* This option will build Java source JARs for each enabled Java library. This does not require `WITH_JAVA` to be on, allowing source JARs to be built without the compiled JARs if desired.
|
||||
* `WITH_NTCORE` (ON Default)
|
||||
* This option will cause ntcore to be built. Turning this off will implicitly disable wpinet, and will cause an error if `WITH_WPILIB` is enabled.
|
||||
* `WITH_SIMULATION_MODULES` (ON Default)
|
||||
@@ -61,13 +53,9 @@ The following build options are available:
|
||||
* `WITH_TESTS` (ON Default)
|
||||
* This option will build C++ unit tests. These can be run via `ctest -C <config>`, where `<config>` is the build configuration, e.g. `Debug` or `Release`.
|
||||
* `WITH_WPILIB` (ON Default)
|
||||
* This option will build the HAL and wpilibc/j during the build. The HAL is the simulation HAL, unless the external HAL options are used. The CMake build has no capability to build for Systemcore.
|
||||
* This option will build the HAL and wpilibc during the build. The HAL is the simulation HAL, unless the external HAL options are used. The CMake build has no capability to build for Systemcore.
|
||||
* `WITH_WPIMATH` (ON Default)
|
||||
* This option will build the wpimath library. This option must be on to build wpilib.
|
||||
* `WITH_WPIUNITS` (`WITH_JAVA` Default)
|
||||
* This option will build the wpiunits library. This option must be on to build the Java wpimath library and requires `WITH_JAVA` to also be on.
|
||||
* `OPENCV_JAVA_INSTALL_DIR`
|
||||
* Set this option to the location of the archive of the OpenCV Java bindings (it should be called opencv-xxx.jar, with the x'es being version numbers). NOTE: set it to the LOCATION of the file, not the file itself!
|
||||
* `NO_WERROR` (OFF Default)
|
||||
* This option will disable the `-Werror` compilation flag for non-MSVC builds.
|
||||
* `WPILIB_TARGET_WARNINGS`
|
||||
@@ -89,7 +77,7 @@ If you want, you can also use `ccmake` in order to visually set these properties
|
||||
|
||||
## Presets
|
||||
|
||||
The WPILib CMake setup has a variety of presets for common configurations and options used. The default sets the generator to Ninja and build directory to `build-cmake`. The other presets are `with-java` (sets `WITH_JAVA=ON`), `sccache` (sets the C/C++ compiler launcher to sccache), and `with-java-sccache` (a combination of `with-java` and `sccache`).
|
||||
The WPILib CMake setup has a variety of presets for common configurations and options used. The default sets the generator to Ninja and build directory to `build-cmake`. The other preset is `sccache` (sets the C/C++ compiler launcher to sccache).
|
||||
|
||||
## Building
|
||||
|
||||
@@ -115,7 +103,7 @@ sudo cmake --build . --target install
|
||||
|
||||
On Windows, make sure the directories for the libraries you built are on PATH. For wpilib, the default install location is `C:\Program Files (x86)\allwpilib`. If you built other libraries like OpenCV from source, install them, and add the install directories to PATH. This ensures CMake can locate the libraries.
|
||||
|
||||
You will also want to add the directories where the DLLs are located (usually the `bin` subdirectory of the install directory) to PATH so they can be loaded by your program. If you are using OpenCV and Java, the `opencv_java` DLL is located in either the `lib` subdirectory if you built but didn't install OpenCV, or the `java` subdirectory if you did install OpenCV.
|
||||
You will also want to add the directories where the DLLs are located (usually the `bin` subdirectory of the install directory) to PATH so they can be loaded by your program.
|
||||
|
||||
## Using the installed libraries for C++.
|
||||
|
||||
@@ -143,40 +131,9 @@ cmake /path/to/folder/containing/CMakeLists
|
||||
|
||||
After that, run `cmake --build .`. That will create your executable. Then you should be able to run `./my_vision_app` to run your application.
|
||||
|
||||
## Using the installed libraries for Java
|
||||
|
||||
Using the built JARs is more involved than using the C++ libraries, but the additional work involves providing the paths to various libraries and JARs when needed.
|
||||
|
||||
Create a new folder to contain your project. Add the following code below to a `CMakeLists.txt` file in that directory.
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
project(robot)
|
||||
|
||||
find_package(Java REQUIRED COMPONENTS Development)
|
||||
include(UseJava)
|
||||
find_package(wpilib REQUIRED)
|
||||
find_jar(opencvJar opencv-xxx PATHS ENV PATH) # Change to OpenCV version
|
||||
|
||||
file(GLOB_RECURSE JAVA_SOURCES *.java)
|
||||
# If you want Gradle compatibility or you are using one of the templates/examples, comment out the above line and uncomment this line instead:
|
||||
# file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
|
||||
add_jar(robot ${JAVA_SOURCES}
|
||||
INCLUDE_JARS apriltag_jar cscore_jar hal_jar ntcore_jar commandsv2_jar wpimath_jar wpinet_jar wpiutil_jar wpiunits_jar wpilibj_jar ${opencvJar})
|
||||
export_jars(TARGETS robot FILE robot.jar)
|
||||
```
|
||||
This includes all the built JARs except for the vendordeps. If you are not using a JAR/library, you may remove it.
|
||||
Add a `Main.java` file to contain your code, and create a build folder. Move into the build folder, and run
|
||||
|
||||
```
|
||||
cmake /path/to/folder/containing/CMakeLists
|
||||
```
|
||||
|
||||
After that, run `cmake --build .` to create your JAR file. To execute the JAR file, you need to include the wpilib JARs and your JAR in the classpath, and execute your Java program's entry point. If you are using cscore or cameraserver, you also need to include the path to the OpenCV JAR. If you built it from source, it will be in your OpenCV build directory. If it's installed on the system, CMake may find it from PATH, but you will likely need to locate the JAR and manually give CMake the JAR directory. If you are on Linux, you will also need to add the path of the libraries to `LD_LIBRARY_PATH`. This can be done by prepending `LD_LIBRARY_PATH=/path/to/libraries` to the Java command. If you need to add more paths, separate them with colons. The final command should look like `java -cp "robot.jar:/path/to/library_jars/*" main.package.Main`, using a semicolon to separate paths instead of a colon if you are on Windows. If you are on Linux, the final command should look more like `LD_LIBRARY_PATH=/path/to/libraries java -cp robot.jar:/path/to/library_jars/* main.package.Main`.
|
||||
|
||||
## Using vendordeps
|
||||
|
||||
Vendordeps are not included as part of the `wpilib` CMake package. However, if you want to use a vendordep, you need to use `find_package(VENDORDEP)`, where `VENDORDEP` is the name of the vendordep (case-sensitive), like `xrpVendordep` or `romiVendordep`. Note that commandsv2, while a vendordep in normal robot projects, is not built as a vendordep in CMake, and is instead included as part of the `wpilib` CMake package. After you used `find_package`, you can reference the vendordep library like normal, either by using `target_link_libraries` for C++ or `add_jar` for Java.
|
||||
Vendordeps are not included as part of the `wpilib` CMake package. However, if you want to use a vendordep, you need to use `find_package(VENDORDEP)`, where `VENDORDEP` is the name of the vendordep (case-sensitive), like `xrpVendordep` or `romiVendordep`. Note that commandsv2, while a vendordep in normal robot projects, is not built as a vendordep in CMake, and is instead included as part of the `wpilib` CMake package. After you used `find_package`, you can reference the vendordep library like normal (using `target_link_libraries`).
|
||||
|
||||
## Troubleshooting
|
||||
Below are some common issues that are run into when building.
|
||||
@@ -204,32 +161,3 @@ CMake Error at cscore/CMakeLists.txt:3 (find_package):
|
||||
```
|
||||
|
||||
If you get that, you need make sure OpenCV was installed, and then reattempt to configure. If that doesn't work, set the `OpenCV_DIR` variable to the directory where you built OpenCV.
|
||||
|
||||
#### Missing Java
|
||||
|
||||
If you are missing Java, you will get a message like the following.
|
||||
```
|
||||
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
|
||||
Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE
|
||||
Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
|
||||
Development)
|
||||
```
|
||||
|
||||
If this happens, make sure you have a JDK of at least version 25 installed, and that your JAVA_HOME variable is set properly to point to the JDK.
|
||||
|
||||
In addition, if you do not need Java, you can disable it with `-DWITH_JAVA=OFF`.
|
||||
|
||||
#### Java: Can't find dependent libraries
|
||||
|
||||
If one of the libraries can't be found, you will get an error similar to this one:
|
||||
|
||||
```
|
||||
java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
|
||||
attempted to load for platform windows-x86_64
|
||||
Last Load Error:
|
||||
C:\Program Files (x86)\allwpilib\bin\wpiHaljni.dll: Can't find dependent libraries
|
||||
```
|
||||
|
||||
If you get this error, that's usually an indication that not all your libraries are in your PATH. If the error is coming from cscore specifically, it's likely you're missing OpenCV. Otherwise, it's likely the wpilib libraries are not in a directory on PATH.
|
||||
|
||||
Note that Linux will not have this specific type of error, as it will usually tell you the dependent library you are missing. In that case, you most likely need to add the library to `LD_LIBRARY_PATH`.
|
||||
|
||||
@@ -49,6 +49,7 @@ mrcal tools/wpical/src/main/native/thirdparty/mrcal
|
||||
libdogleg tools/wpical/src/main/native/thirdparty/libdogleg
|
||||
Simd hal/src/main/native/systemcore/simd
|
||||
AdvantageScope fields/src/main/native/resources/org/wpilib/fields/ftc
|
||||
Avahi wpinet/src/main/native/linux/AvahiClient.hpp
|
||||
|
||||
Additionally, glfw and nanopb were modified for use in WPILib.
|
||||
|
||||
@@ -1595,3 +1596,509 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
=============
|
||||
Avahi License
|
||||
=============
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Moe Ghoul>, 1 April 1990
|
||||
Moe Ghoul, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
load("//thirdparty/ceres:repositories.bzl", "ceres_repositories")
|
||||
|
||||
ceres_repositories()
|
||||
|
||||
http_archive(
|
||||
name = "pybind11_bazel",
|
||||
integrity = "sha256-iwRj1wuX2pDS6t6DqiCfhIXisv4y+7CvxSJtZoSAzGw=",
|
||||
@@ -29,16 +25,6 @@ load("@bzlmodrio-opencv//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_opencv_cp
|
||||
|
||||
setup_legacy_bzlmodrio_opencv_cpp_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "bzlmodrio-libssh",
|
||||
sha256 = "f8fef627c7b393f7f6ed638e12b80ff90b2cfea11488b15214f25ce1e470723a",
|
||||
url = "https://github.com/wpilibsuite/bzlmodRio-libssh/releases/download/2024.0.105-1.bcr1/bzlmodrio-libssh-2024.0.105-1.bcr1.tar.gz",
|
||||
)
|
||||
|
||||
load("@bzlmodrio-libssh//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_libssh_cpp_dependencies")
|
||||
|
||||
setup_legacy_bzlmodrio_libssh_cpp_dependencies()
|
||||
|
||||
# Capture the repository environmental variables which specify the filter list for what architectures to build in CI.
|
||||
load("//shared/bazel/rules:publishing_rule.bzl", "publishing_repo")
|
||||
|
||||
|
||||
@@ -164,13 +164,13 @@ pkg_files(
|
||||
cc_test(
|
||||
name = "apriltag-cpp-test",
|
||||
size = "small",
|
||||
srcs = glob(["src/test/native/cpp/**"]),
|
||||
srcs = glob(["src/test/native/cpp/**/*.cpp"]),
|
||||
tags = [
|
||||
"no-asan",
|
||||
],
|
||||
deps = [
|
||||
":apriltag",
|
||||
"//thirdparty/googletest",
|
||||
"//thirdparty/catch2",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -31,81 +31,6 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
file(GLOB apriltag_jni_src src/main/native/cpp/jni/AprilTagJNI.cpp)
|
||||
|
||||
if(WITH_JAVA)
|
||||
include(UseJava)
|
||||
|
||||
set(CMAKE_JNI_TARGET true)
|
||||
|
||||
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
|
||||
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
|
||||
find_file(
|
||||
OPENCV_JAR_FILE
|
||||
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
|
||||
PATHS
|
||||
${OPENCV_JAVA_INSTALL_DIR}
|
||||
${OpenCV_INSTALL_PATH}/bin
|
||||
${OpenCV_INSTALL_PATH}/share/java
|
||||
${OpenCV_INSTALL_PATH}/share/java/opencv4
|
||||
${OpenCV_INSTALL_PATH}/share/OpenCV/java
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
|
||||
file(
|
||||
GLOB_RECURSE JAVA_RESOURCES
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
src/main/native/resources/*.json
|
||||
)
|
||||
add_jar(
|
||||
apriltag_jar
|
||||
SOURCES ${JAVA_SOURCES}
|
||||
RESOURCES
|
||||
NAMESPACE "org/wpilib/vision/apriltag" ${JAVA_RESOURCES}
|
||||
INCLUDE_JARS
|
||||
wpimath_jar
|
||||
wpiunits_jar
|
||||
wpiutil_jar
|
||||
${EJML_JARS}
|
||||
${OPENCV_JAR_FILE}
|
||||
${AVAJE_JARS}
|
||||
OUTPUT_NAME apriltag
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
GENERATE_NATIVE_HEADERS apriltag_jni_headers
|
||||
)
|
||||
set_property(TARGET apriltag_jar PROPERTY FOLDER "java")
|
||||
|
||||
install_jar(apriltag_jar DESTINATION ${java_lib_dest})
|
||||
install_jar_exports(TARGETS apriltag_jar FILE apriltag_jar.cmake DESTINATION share/apriltag)
|
||||
|
||||
add_library(apriltagjni ${apriltag_jni_src} ${apriltaglib_src})
|
||||
wpilib_target_warnings(apriltagjni)
|
||||
target_link_libraries(apriltagjni PUBLIC apriltag)
|
||||
|
||||
set_property(TARGET apriltagjni PROPERTY FOLDER "libraries")
|
||||
|
||||
target_link_libraries(apriltagjni PRIVATE apriltag_jni_headers)
|
||||
add_dependencies(apriltagjni apriltag_jar)
|
||||
|
||||
install(TARGETS apriltagjni EXPORT apriltagjni)
|
||||
export(TARGETS apriltagjni FILE apriltagjni.cmake NAMESPACE apriltagjni::)
|
||||
endif()
|
||||
|
||||
if(WITH_JAVA_SOURCE)
|
||||
include(UseJava)
|
||||
include(CreateSourceJar)
|
||||
add_source_jar(
|
||||
apriltag_src_jar
|
||||
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
|
||||
OUTPUT_NAME apriltag-sources
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
)
|
||||
set_property(TARGET apriltag_src_jar PROPERTY FOLDER "java")
|
||||
|
||||
install_jar(apriltag_src_jar DESTINATION ${java_lib_dest})
|
||||
endif()
|
||||
|
||||
generate_resources(
|
||||
src/main/native/resources/org/wpilib/vision/apriltag
|
||||
generated/main/cpp
|
||||
@@ -152,7 +77,7 @@ install(FILES ${WPILIB_BINARY_DIR}/apriltag-config.cmake DESTINATION share/april
|
||||
install(EXPORT apriltag DESTINATION share/apriltag)
|
||||
|
||||
if(WITH_TESTS)
|
||||
wpilib_add_test(apriltag src/test/native/cpp)
|
||||
wpilib_add_test_catch2(apriltag src/test/native/cpp)
|
||||
target_include_directories(apriltag_test PRIVATE src/test/native/include)
|
||||
target_link_libraries(apriltag_test apriltag googletest)
|
||||
target_link_libraries(apriltag_test apriltag)
|
||||
endif()
|
||||
|
||||
@@ -5,6 +5,3 @@ include(CMakeFindDependencyMacro)
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/apriltag.cmake)
|
||||
if(@WITH_JAVA@)
|
||||
include(${SELF_DIR}/apriltag_jar.cmake)
|
||||
endif()
|
||||
|
||||
@@ -5,11 +5,12 @@ apply plugin: 'c'
|
||||
ext {
|
||||
nativeName = 'apriltag'
|
||||
devMain = 'org.wpilib.vision.apriltag.DevMain'
|
||||
nativeTestSuiteName = "${nativeName}Catch2Test"
|
||||
useJava = true
|
||||
useCpp = true
|
||||
sharedCvConfigs = [
|
||||
apriltagDev : [],
|
||||
apriltagTest: []]
|
||||
(nativeTestSuiteName): []]
|
||||
staticCvConfigs = []
|
||||
|
||||
def generateTask = createGenerateResourcesTask('main', 'APRILTAG', 'wpi::apriltag', project)
|
||||
|
||||
39
apriltag/robotpy_native_build_info.bzl
generated
39
apriltag/robotpy_native_build_info.bzl
generated
@@ -1,9 +1,11 @@
|
||||
# THIS FILE IS AUTO GENERATED
|
||||
|
||||
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
|
||||
load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "native_wrappery_library")
|
||||
load("//shared/bazel/rules/robotpy:robotpy_rules.bzl", "copy_native_file", "generate_native_files", "robotpy_library")
|
||||
|
||||
def define_native_wrapper(name, pyproject_toml = None):
|
||||
pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml"
|
||||
|
||||
copy_to_directory(
|
||||
name = "{}.copy_headers".format(name),
|
||||
srcs = native.glob(["src/main/native/include/**"]) + native.glob(["src/generated/main/native/include/**"], allow_empty = True) + native.glob([
|
||||
@@ -20,25 +22,42 @@ def define_native_wrapper(name, pyproject_toml = None):
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
native_wrappery_library(
|
||||
libinit_files = ["native/apriltag/_init_robotpy_native_apriltag.py"]
|
||||
|
||||
generate_native_files(
|
||||
name = name,
|
||||
pyproject_toml = pyproject_toml or "src/main/python/native-pyproject.toml",
|
||||
libinit_file = "native/apriltag/_init_robotpy_native_apriltag.py",
|
||||
pc_file = "native/apriltag/robotpy-native-apriltag.pc",
|
||||
pyproject_toml = pyproject_toml,
|
||||
pc_deps = [
|
||||
"//wpimath:native/wpimath/robotpy-native-wpimath.pc",
|
||||
"//wpiutil:native/wpiutil/robotpy-native-wpiutil.pc",
|
||||
],
|
||||
libinit_files = libinit_files,
|
||||
pc_files = ["native/apriltag/robotpy-native-apriltag.pc"],
|
||||
)
|
||||
|
||||
copy_native_file(
|
||||
name = "apriltag",
|
||||
library = "shared/apriltag",
|
||||
base_path = "native/apriltag/",
|
||||
)
|
||||
|
||||
robotpy_library(
|
||||
name = name,
|
||||
distribution = "robotpy-native-apriltag",
|
||||
srcs = libinit_files,
|
||||
data = [
|
||||
name + ".pc_wrapper",
|
||||
":apriltag.copy_lib",
|
||||
"{}.copy_headers".format(name),
|
||||
],
|
||||
deps = [
|
||||
"//wpimath:robotpy-native-wpimath",
|
||||
"//wpiutil:robotpy-native-wpiutil",
|
||||
],
|
||||
headers = "{}.copy_headers".format(name),
|
||||
native_shared_library = "shared/apriltag",
|
||||
install_path = "native/apriltag/",
|
||||
strip_path_prefixes = ["apriltag"],
|
||||
requires = ["robotpy-native-wpiutil==0.0.0", "robotpy-native-wpimath==0.0.0"],
|
||||
summary = "WPILib AprilTag Library",
|
||||
requires = ["robotpy-native-wpiutil==0.0.0", "robotpy-native-wpimath==0.0.0"],
|
||||
python_requires = ">=3.11",
|
||||
strip_path_prefixes = ["apriltag"],
|
||||
entry_points = {
|
||||
"pkg_config": [
|
||||
"apriltag = native.apriltag",
|
||||
|
||||
4
apriltag/robotpy_pybind_build_info.bzl
generated
4
apriltag/robotpy_pybind_build_info.bzl
generated
@@ -1,7 +1,7 @@
|
||||
# THIS FILE IS AUTO GENERATED
|
||||
|
||||
load("//shared/bazel/rules/gen:gen-version-file.bzl", "generate_version_file")
|
||||
load("//shared/bazel/rules/robotpy:pybind_rules.bzl", "create_pybind_library", "robotpy_library")
|
||||
load("//shared/bazel/rules/robotpy:robotpy_rules.bzl", "create_pybind_library", "robotpy_library")
|
||||
load("//shared/bazel/rules/robotpy:semiwrap_helpers.bzl", "gen_libinit", "gen_modinit_hpp", "gen_pkgconf", "resolve_casters", "run_header_gen")
|
||||
load("//shared/bazel/rules/robotpy:semiwrap_tool_helpers.bzl", "scan_headers", "update_yaml_files")
|
||||
|
||||
@@ -198,6 +198,7 @@ def define_pybind_library(name, pkgcfgs = []):
|
||||
|
||||
robotpy_library(
|
||||
name = name,
|
||||
distribution = "robotpy-apriltag",
|
||||
srcs = native.glob(["src/main/python/robotpy_apriltag/**/*.py"]) + [
|
||||
"src/main/python/robotpy_apriltag/_init__apriltag.py",
|
||||
"{}.generate_version".format(name),
|
||||
@@ -219,6 +220,7 @@ def define_pybind_library(name, pkgcfgs = []):
|
||||
project_urls = {"Source code": "https://github.com/robotpy/mostrobotpy"},
|
||||
author_email = "RobotPy Development Team <robotpy@googlegroups.com>",
|
||||
requires = ["robotpy-native-apriltag==0.0.0", "robotpy-wpiutil==0.0.0", "robotpy-wpimath==0.0.0"],
|
||||
python_requires = ">=3.11",
|
||||
entry_points = {
|
||||
"pkg_config": ["apriltag = robotpy_apriltag"],
|
||||
},
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include "wpi/util/SymbolExports.hpp"
|
||||
|
||||
namespace wpi::apriltag {
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ requires = [
|
||||
name = "robotpy-native-apriltag"
|
||||
version = "0.0.0"
|
||||
description = "WPILib AprilTag Library"
|
||||
requires-python = ">=3.11"
|
||||
license = "BSD-3-Clause"
|
||||
|
||||
dependencies = [
|
||||
|
||||
@@ -14,6 +14,7 @@ requires = [
|
||||
name = "robotpy-apriltag"
|
||||
version = "0.0.0"
|
||||
description = "RobotPy bindings for WPILib's AprilTag library"
|
||||
requires-python = ">=3.11"
|
||||
authors = [
|
||||
{name = "RobotPy Development Team", email = "robotpy@googlegroups.com"},
|
||||
]
|
||||
|
||||
@@ -4,55 +4,55 @@
|
||||
|
||||
#include "wpi/apriltag/AprilTagDetector.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
TEST(AprilTagDetectorTest, ConfigDefaults) {
|
||||
TEST_CASE("AprilTagDetectorTest ConfigDefaults", "[apriltag][detector]") {
|
||||
AprilTagDetector detector;
|
||||
auto config = detector.GetConfig();
|
||||
ASSERT_EQ(config, AprilTagDetector::Config{});
|
||||
REQUIRE(config == AprilTagDetector::Config{});
|
||||
}
|
||||
|
||||
TEST(AprilTagDetectorTest, QtpDefaults) {
|
||||
TEST_CASE("AprilTagDetectorTest QtpDefaults", "[apriltag][detector]") {
|
||||
AprilTagDetector detector;
|
||||
auto params = detector.GetQuadThresholdParameters();
|
||||
ASSERT_EQ(params, AprilTagDetector::QuadThresholdParameters{});
|
||||
REQUIRE(params == AprilTagDetector::QuadThresholdParameters{});
|
||||
}
|
||||
|
||||
TEST(AprilTagDetectorTest, SetConfigNumThreads) {
|
||||
TEST_CASE("AprilTagDetectorTest SetConfigNumThreads", "[apriltag][detector]") {
|
||||
AprilTagDetector detector;
|
||||
detector.SetConfig({.numThreads = 2});
|
||||
auto config = detector.GetConfig();
|
||||
ASSERT_EQ(config.numThreads, 2);
|
||||
REQUIRE(config.numThreads == 2);
|
||||
}
|
||||
|
||||
TEST(AprilTagDetectorTest, QtpMinClusterPixels) {
|
||||
TEST_CASE("AprilTagDetectorTest QtpMinClusterPixels", "[apriltag][detector]") {
|
||||
AprilTagDetector detector;
|
||||
detector.SetQuadThresholdParameters({.minClusterPixels = 8});
|
||||
auto params = detector.GetQuadThresholdParameters();
|
||||
ASSERT_EQ(params.minClusterPixels, 8);
|
||||
REQUIRE(params.minClusterPixels == 8);
|
||||
}
|
||||
|
||||
TEST(AprilTagDetectorTest, Add16h5) {
|
||||
TEST_CASE("AprilTagDetectorTest Add16h5", "[apriltag][detector]") {
|
||||
AprilTagDetector detector;
|
||||
ASSERT_TRUE(detector.AddFamily("tag16h5"));
|
||||
REQUIRE(detector.AddFamily("tag16h5"));
|
||||
// duplicate addition is also okay
|
||||
ASSERT_TRUE(detector.AddFamily("tag16h5"));
|
||||
REQUIRE(detector.AddFamily("tag16h5"));
|
||||
}
|
||||
|
||||
TEST(AprilTagDetectorTest, Add36h11) {
|
||||
TEST_CASE("AprilTagDetectorTest Add36h11", "[apriltag][detector]") {
|
||||
AprilTagDetector detector;
|
||||
ASSERT_TRUE(detector.AddFamily("tag36h11"));
|
||||
REQUIRE(detector.AddFamily("tag36h11"));
|
||||
}
|
||||
|
||||
TEST(AprilTagDetectorTest, AddMultiple) {
|
||||
TEST_CASE("AprilTagDetectorTest AddMultiple", "[apriltag][detector]") {
|
||||
AprilTagDetector detector;
|
||||
ASSERT_TRUE(detector.AddFamily("tag16h5"));
|
||||
ASSERT_TRUE(detector.AddFamily("tag36h11"));
|
||||
REQUIRE(detector.AddFamily("tag16h5"));
|
||||
REQUIRE(detector.AddFamily("tag36h11"));
|
||||
}
|
||||
|
||||
TEST(AprilTagDetectorTest, RemoveFamily) {
|
||||
TEST_CASE("AprilTagDetectorTest RemoveFamily", "[apriltag][detector]") {
|
||||
AprilTagDetector detector;
|
||||
// okay to remove non-existent family
|
||||
detector.RemoveFamily("tag16h5");
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "wpi/apriltag/AprilTag.hpp"
|
||||
#include "wpi/apriltag/AprilTagFieldLayout.hpp"
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
TEST(AprilTagJsonTest, DeserializeMatches) {
|
||||
TEST_CASE("AprilTagJsonTest DeserializeMatches", "[apriltag][json]") {
|
||||
auto layout = AprilTagFieldLayout{
|
||||
std::vector{AprilTag{1, wpi::math::Pose3d{}},
|
||||
AprilTag{3, wpi::math::Pose3d{0_m, 1_m, 0_m,
|
||||
@@ -23,6 +23,6 @@ TEST(AprilTagJsonTest, DeserializeMatches) {
|
||||
|
||||
AprilTagFieldLayout deserialized;
|
||||
wpi::util::json json = layout;
|
||||
EXPECT_NO_THROW(deserialized = json.get<AprilTagFieldLayout>());
|
||||
EXPECT_EQ(layout, deserialized);
|
||||
CHECK_NOTHROW(deserialized = json.get<AprilTagFieldLayout>());
|
||||
CHECK(layout == deserialized);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "wpi/apriltag/AprilTag.hpp"
|
||||
#include "wpi/apriltag/AprilTagFieldLayout.hpp"
|
||||
@@ -13,7 +13,8 @@
|
||||
|
||||
using namespace wpi::apriltag;
|
||||
|
||||
TEST(AprilTagPoseSetOriginTest, TransformationMatches) {
|
||||
TEST_CASE("AprilTagPoseSetOriginTest TransformationMatches",
|
||||
"[apriltag][field-layout][pose]") {
|
||||
auto layout = AprilTagFieldLayout{
|
||||
std::vector<AprilTag>{
|
||||
AprilTag{
|
||||
@@ -29,8 +30,8 @@ TEST(AprilTagPoseSetOriginTest, TransformationMatches) {
|
||||
|
||||
auto mirrorPose = wpi::math::Pose3d{
|
||||
54_ft, 27_ft, 0_ft, wpi::math::Rotation3d{0_deg, 0_deg, 180_deg}};
|
||||
EXPECT_EQ(mirrorPose, *layout.GetTagPose(1));
|
||||
CHECK(mirrorPose == *layout.GetTagPose(1));
|
||||
mirrorPose = wpi::math::Pose3d{50_ft, 23_ft, 4_ft,
|
||||
wpi::math::Rotation3d{0_deg, 0_deg, 0_deg}};
|
||||
EXPECT_EQ(mirrorPose, *layout.GetTagPose(2));
|
||||
CHECK(mirrorPose == *layout.GetTagPose(2));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "wpi/apriltag/AprilTagFieldLayout.hpp"
|
||||
#include "wpi/apriltag/AprilTagFields.hpp"
|
||||
@@ -21,7 +21,8 @@ std::vector<AprilTagField> GetAllFields() {
|
||||
return output;
|
||||
}
|
||||
|
||||
TEST(AprilTagFieldsTest, TestLoad2022RapidReact) {
|
||||
TEST_CASE("AprilTagFieldsTest TestLoad2022RapidReact",
|
||||
"[apriltag][field-layout]") {
|
||||
AprilTagFieldLayout layout =
|
||||
AprilTagFieldLayout::LoadField(AprilTagField::k2022RapidReact);
|
||||
|
||||
@@ -30,39 +31,36 @@ TEST(AprilTagFieldsTest, TestLoad2022RapidReact) {
|
||||
wpi::math::Pose3d{127.272_in, 216.01_in, 67.932_in,
|
||||
wpi::math::Rotation3d{0_deg, 0_deg, 0_deg}};
|
||||
auto maybePose = layout.GetTagPose(1);
|
||||
EXPECT_TRUE(maybePose);
|
||||
EXPECT_EQ(expectedPose, *maybePose);
|
||||
REQUIRE(maybePose);
|
||||
CHECK(expectedPose == *maybePose);
|
||||
|
||||
// Blue Terminal Near Station
|
||||
expectedPose =
|
||||
wpi::math::Pose3d{4.768_in, 67.631_in, 35.063_in,
|
||||
wpi::math::Rotation3d{0_deg, 0_deg, 46.25_deg}};
|
||||
maybePose = layout.GetTagPose(5);
|
||||
EXPECT_TRUE(maybePose);
|
||||
EXPECT_EQ(expectedPose, *maybePose);
|
||||
REQUIRE(maybePose);
|
||||
CHECK(expectedPose == *maybePose);
|
||||
|
||||
// Upper Hub Blue-Near
|
||||
expectedPose =
|
||||
wpi::math::Pose3d{332.321_in, 183.676_in, 95.186_in,
|
||||
wpi::math::Rotation3d{0_deg, 26.75_deg, 69_deg}};
|
||||
maybePose = layout.GetTagPose(53);
|
||||
EXPECT_TRUE(maybePose);
|
||||
EXPECT_EQ(expectedPose, *maybePose);
|
||||
REQUIRE(maybePose);
|
||||
CHECK(expectedPose == *maybePose);
|
||||
|
||||
// Doesn't exist
|
||||
maybePose = layout.GetTagPose(54);
|
||||
EXPECT_FALSE(maybePose);
|
||||
CHECK_FALSE(maybePose);
|
||||
}
|
||||
|
||||
// Test all of the fields in the enum
|
||||
class AllFieldsFixtureTest : public ::testing::TestWithParam<AprilTagField> {};
|
||||
|
||||
TEST_P(AllFieldsFixtureTest, CheckEntireEnum) {
|
||||
AprilTagField field = GetParam();
|
||||
EXPECT_NO_THROW(AprilTagFieldLayout::LoadField(field));
|
||||
TEST_CASE("AprilTagFieldsTest CheckEntireEnum", "[apriltag][field-layout]") {
|
||||
for (auto field : GetAllFields()) {
|
||||
CAPTURE(field);
|
||||
CHECK_NOTHROW(AprilTagFieldLayout::LoadField(field));
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(ValuesEnumTestInstTests, AllFieldsFixtureTest,
|
||||
::testing::ValuesIn(GetAllFields()));
|
||||
|
||||
} // namespace wpi::apriltag
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <catch2/catch_session.hpp>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
return ret;
|
||||
return Catch::Session().run(argc, argv);
|
||||
}
|
||||
|
||||
@@ -3,57 +3,6 @@ project(cameraserver)
|
||||
include(CompileWarnings)
|
||||
include(AddTest)
|
||||
|
||||
# Java bindings
|
||||
if(WITH_JAVA)
|
||||
include(UseJava)
|
||||
|
||||
#find JAR file, copy it locally
|
||||
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/java/opencv4)
|
||||
|
||||
find_file(
|
||||
OPENCV_JAR_FILE
|
||||
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
|
||||
PATHS
|
||||
${OPENCV_JAVA_INSTALL_DIR}
|
||||
${OpenCV_INSTALL_PATH}/bin
|
||||
${OpenCV_INSTALL_PATH}/share/java
|
||||
${OpenCV_INSTALL_PATH}/share/OpenCV/java
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
|
||||
|
||||
add_jar(
|
||||
cameraserver_jar
|
||||
${JAVA_SOURCES}
|
||||
INCLUDE_JARS wpiutil_jar cscore_jar ntcore_jar ${OPENCV_JAR_FILE}
|
||||
OUTPUT_NAME cameraserver
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
)
|
||||
set_property(TARGET cameraserver_jar PROPERTY FOLDER "java")
|
||||
|
||||
install_jar(cameraserver_jar DESTINATION ${java_lib_dest})
|
||||
install_jar_exports(
|
||||
TARGETS cameraserver_jar
|
||||
FILE cameraserver_jar.cmake
|
||||
DESTINATION share/cameraserver
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_JAVA_SOURCE)
|
||||
include(UseJava)
|
||||
include(CreateSourceJar)
|
||||
add_source_jar(
|
||||
cameraserver_src_jar
|
||||
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
|
||||
OUTPUT_NAME cameraserver-sources
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
)
|
||||
set_property(TARGET cameraserver_src_jar PROPERTY FOLDER "java")
|
||||
|
||||
install_jar(cameraserver_src_jar DESTINATION ${java_lib_dest})
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE cameraserver_native_src src/main/native/cpp/*.cpp)
|
||||
add_library(cameraserver ${cameraserver_native_src})
|
||||
set_target_properties(cameraserver PROPERTIES DEBUG_POSTFIX "d")
|
||||
|
||||
@@ -8,6 +8,3 @@ find_dependency(OpenCV)
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/cameraserver.cmake)
|
||||
if(@WITH_JAVA@)
|
||||
include(${SELF_DIR}/cameraserver_jar.cmake)
|
||||
endif()
|
||||
|
||||
@@ -13,3 +13,23 @@ macro(wpilib_add_test name srcdir)
|
||||
endif()
|
||||
add_test(NAME ${name} COMMAND ${name}_test)
|
||||
endmacro()
|
||||
|
||||
macro(wpilib_add_test_catch2 name)
|
||||
set(wpilib_catch2_test_src)
|
||||
foreach(src ${ARGN})
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
||||
file(GLOB_RECURSE wpilib_catch2_dir_src ${src}/*.cpp)
|
||||
list(APPEND wpilib_catch2_test_src ${wpilib_catch2_dir_src})
|
||||
else()
|
||||
list(APPEND wpilib_catch2_test_src ${src})
|
||||
endif()
|
||||
endforeach()
|
||||
add_executable(${name}_test ${wpilib_catch2_test_src})
|
||||
set_property(TARGET ${name}_test PROPERTY FOLDER "tests")
|
||||
wpilib_target_warnings(${name}_test)
|
||||
target_link_libraries(${name}_test catch2)
|
||||
catch_discover_tests(${name}_test)
|
||||
if(MSVC)
|
||||
target_compile_options(${name}_test PRIVATE /wd4101 /wd4251 /utf-8)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
macro(add_source_jar target)
|
||||
set(oneValueArgs OUTPUT_NAME OUTPUT_DIR)
|
||||
cmake_parse_arguments(SOURCE_JAR "" "${oneValueArgs}" "BASE_DIRECTORIES" ${ARGN})
|
||||
foreach(base_package_dir ${SOURCE_JAR_BASE_DIRECTORIES})
|
||||
file(GLOB_RECURSE directories LIST_DIRECTORIES true ${base_package_dir}/*.directoriesonly)
|
||||
# Find all packages
|
||||
foreach(directory ${directories})
|
||||
cmake_path(
|
||||
RELATIVE_PATH directory
|
||||
BASE_DIRECTORY ${base_package_dir}
|
||||
OUTPUT_VARIABLE package_name
|
||||
)
|
||||
file(GLOB package_sources ${directory}/*.java)
|
||||
if(package_sources STREQUAL "")
|
||||
continue()
|
||||
endif()
|
||||
# If package sources are scattered across different places, consolidate them under one package
|
||||
list(FIND packages ${package_name} index)
|
||||
if(index EQUAL -1)
|
||||
list(APPEND packages ${package_name})
|
||||
endif()
|
||||
list(APPEND ${package_name} ${package_sources})
|
||||
endforeach()
|
||||
endforeach()
|
||||
set(resources "")
|
||||
foreach(package ${packages})
|
||||
string(APPEND resources "NAMESPACE \"${package}\" ${${package}} ")
|
||||
endforeach()
|
||||
cmake_language(
|
||||
EVAL CODE
|
||||
"add_jar(${target} RESOURCES ${resources} OUTPUT_NAME ${SOURCE_JAR_OUTPUT_NAME} OUTPUT_DIR ${SOURCE_JAR_OUTPUT_DIR})"
|
||||
)
|
||||
endmacro()
|
||||
@@ -2,14 +2,13 @@ load("@allwpilib_pip_deps//:requirements.bzl", "requirement")
|
||||
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_test")
|
||||
load("@rules_java//java:defs.bzl", "java_binary")
|
||||
load("@rules_pycross//pycross:defs.bzl", "pycross_wheel_library")
|
||||
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
|
||||
load("@rules_python//python:packaging.bzl", "py_wheel")
|
||||
load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("//commandsv2:generate.bzl", "generate_wpilib_new_commands")
|
||||
load("//shared/bazel/rules:cc_rules.bzl", "third_party_cc_lib_helper", "wpilib_cc_library", "wpilib_cc_shared_library", "wpilib_cc_static_library")
|
||||
load("//shared/bazel/rules:java_rules.bzl", "wpilib_java_junit5_test", "wpilib_java_library")
|
||||
load("//shared/bazel/rules:packaging.bzl", "package_default_cc_project")
|
||||
load("//shared/bazel/rules/robotpy:pytest_util.bzl", "robotpy_py_test")
|
||||
load("//shared/bazel/rules/robotpy:robotpy_rules.bzl", "robotpy_library")
|
||||
|
||||
filegroup(
|
||||
name = "doxygen-files",
|
||||
@@ -188,30 +187,21 @@ package_default_cc_project(
|
||||
maven_group_id = "org.wpilib.commandsv2",
|
||||
)
|
||||
|
||||
py_library(
|
||||
name = "commandsv2-py-lib",
|
||||
srcs = glob(["src/main/python/**/*.py"]),
|
||||
imports = ["src/main/python"],
|
||||
deps = [
|
||||
"//wpilibc:robotpy-wpilib",
|
||||
requirement("typing-extensions"),
|
||||
],
|
||||
)
|
||||
|
||||
py_wheel(
|
||||
name = "commandsv2-wheel",
|
||||
distribution = "commandsv2",
|
||||
strip_path_prefixes = ["commandsv2/src/main/python"],
|
||||
tags = ["robotpy"],
|
||||
version = "$(ROBOTPY_VERSION)",
|
||||
deps = [":commandsv2-py-lib"],
|
||||
)
|
||||
|
||||
pycross_wheel_library(
|
||||
robotpy_library(
|
||||
name = "commandsv2-py",
|
||||
tags = ["manual"],
|
||||
visibility = ["//visibility:public"],
|
||||
wheel = ":commandsv2-wheel",
|
||||
srcs = glob(["src/main/python/**/*.py"]),
|
||||
author_email = "RobotPy Development Team <robotpy@googlegroups.com>",
|
||||
description_file = "src/main/python/README.md",
|
||||
distribution = "robotpy-commands-v2",
|
||||
imports = ["src/main/python"],
|
||||
project_urls = {"Source code": "https://github.com/robotpy/mostrobotpy"},
|
||||
python_requires = ">=3.10",
|
||||
requires = [
|
||||
"wpilib==0.0.0",
|
||||
"typing_extensions>=4.1.0,<5",
|
||||
],
|
||||
strip_path_prefixes = ["commandsv2/src/main/python"],
|
||||
summary = "WPILib command framework v2",
|
||||
deps = [
|
||||
"//wpilibc:robotpy-wpilib",
|
||||
requirement("typing-extensions"),
|
||||
|
||||
@@ -4,55 +4,6 @@ include(SubDirList)
|
||||
include(CompileWarnings)
|
||||
include(AddTest)
|
||||
|
||||
if(WITH_JAVA)
|
||||
include(UseJava)
|
||||
|
||||
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
|
||||
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
|
||||
add_jar(
|
||||
commandsv2_jar
|
||||
${JAVA_SOURCES}
|
||||
INCLUDE_JARS
|
||||
hal_jar
|
||||
ntcore_jar
|
||||
${AVAJE_JARS}
|
||||
cscore_jar
|
||||
cameraserver_jar
|
||||
wpimath_jar
|
||||
wpiunits_jar
|
||||
wpiutil_jar
|
||||
wpilibj_jar
|
||||
datalog_jar
|
||||
wpiannotations_jar
|
||||
OUTPUT_NAME commandsv2
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
)
|
||||
set_property(TARGET commandsv2_jar PROPERTY FOLDER "java")
|
||||
|
||||
install_jar(commandsv2_jar DESTINATION ${java_lib_dest})
|
||||
install_jar_exports(
|
||||
TARGETS commandsv2_jar
|
||||
FILE commandsv2_jar.cmake
|
||||
DESTINATION share/commandsv2
|
||||
)
|
||||
endif()
|
||||
|
||||
if(WITH_JAVA_SOURCE)
|
||||
include(UseJava)
|
||||
include(CreateSourceJar)
|
||||
add_source_jar(
|
||||
commandsv2_src_jar
|
||||
BASE_DIRECTORIES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java
|
||||
OUTPUT_NAME commandsv2-sources
|
||||
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
|
||||
)
|
||||
set_property(TARGET commandsv2_src_jar PROPERTY FOLDER "java")
|
||||
|
||||
install_jar(commandsv2_src_jar DESTINATION ${java_lib_dest})
|
||||
endif()
|
||||
|
||||
file(
|
||||
GLOB_RECURSE commandsv2_native_src
|
||||
src/main/native/cpp/*.cpp
|
||||
|
||||
@@ -10,6 +10,3 @@ include(CMakeFindDependencyMacro)
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/commandsv2.cmake)
|
||||
if(@WITH_JAVA@)
|
||||
include(${SELF_DIR}/commandsv2_jar.cmake)
|
||||
endif()
|
||||
|
||||
@@ -7,6 +7,7 @@ def __generate_wpilib_new_commands_impl(ctx):
|
||||
args = ctx.actions.args()
|
||||
args.add("--output_directory", output_dir.path)
|
||||
args.add("--template_root", "commandsv2/src/generate")
|
||||
args.add("--python_output_directory", "__none__")
|
||||
|
||||
ctx.actions.run(
|
||||
inputs = ctx.attr._templates.files,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
@@ -63,6 +64,147 @@ def generate_hids(output_directory: Path, template_directory: Path, schema_file:
|
||||
write_controller_file(root_path, controllerName, output)
|
||||
|
||||
|
||||
def _capitalize_first(name: str) -> str:
|
||||
return name[0].upper() + name[1:]
|
||||
|
||||
|
||||
def _display_name(name: str) -> str:
|
||||
name = re.sub(r"([a-z0-9])([A-Z])", r"\1 \2", name)
|
||||
name = re.sub(r"([A-Z]+)([A-Z][a-z])", r"\1 \2", name)
|
||||
name = re.sub(r"([A-Za-z])([0-9])", r"\1 \2", name)
|
||||
return name[0].upper() + name[1:]
|
||||
|
||||
|
||||
def _constant_name(name: str) -> str:
|
||||
name = re.sub(r"([A-Z]+)([A-Z][a-z])", r"\1_\2", name)
|
||||
name = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name)
|
||||
name = re.sub(r"([a-z])([0-9])", r"\1_\2", name)
|
||||
return name.upper()
|
||||
|
||||
|
||||
def _is_trigger_axis(name: str) -> bool:
|
||||
return name.endswith("Trigger") or name in {
|
||||
"L2",
|
||||
"R2",
|
||||
"ZL",
|
||||
"ZR",
|
||||
}
|
||||
|
||||
|
||||
def _normalize_command_mapping(mapping: dict[str, int]):
|
||||
return [
|
||||
{
|
||||
"Name": name,
|
||||
"MethodName": _capitalize_first(name),
|
||||
"ConstantName": _constant_name(name),
|
||||
"DocName": _display_name(name),
|
||||
"value": value,
|
||||
}
|
||||
for name, value in mapping.items()
|
||||
]
|
||||
|
||||
|
||||
def _normalize_first_ds_command_controller(controller: dict):
|
||||
buttons = _normalize_command_mapping(controller["buttons"])
|
||||
axes = _normalize_command_mapping(controller["axes"])
|
||||
button_names = {button["Name"] for button in buttons}
|
||||
|
||||
trigger_axes = []
|
||||
for axis in axes:
|
||||
if not _is_trigger_axis(axis["Name"]):
|
||||
continue
|
||||
|
||||
name = axis["Name"]
|
||||
trigger_name = name
|
||||
trigger_axes.append(
|
||||
{
|
||||
"Name": trigger_name,
|
||||
"MethodName": _capitalize_first(trigger_name),
|
||||
"DocName": _display_name(trigger_name),
|
||||
"AxisName": axis["Name"],
|
||||
"AxisMethodName": axis["MethodName"],
|
||||
"AxisConstantName": axis["ConstantName"],
|
||||
"AxisDocName": axis["DocName"],
|
||||
"HasDefaultThresholdMethod": trigger_name not in button_names,
|
||||
}
|
||||
)
|
||||
|
||||
normalized = dict(controller)
|
||||
normalized["buttons"] = buttons
|
||||
normalized["axes"] = axes
|
||||
normalized["triggerAxes"] = trigger_axes
|
||||
return normalized
|
||||
|
||||
|
||||
def generate_first_ds_hids(
|
||||
output_directory: Path,
|
||||
template_directory: Path,
|
||||
schema_file: Path,
|
||||
python_output_directory: Path | None = None,
|
||||
):
|
||||
with schema_file.open(encoding="utf-8") as f:
|
||||
controllers = [
|
||||
_normalize_first_ds_command_controller(controller)
|
||||
for controller in json.load(f)
|
||||
]
|
||||
|
||||
# Java files
|
||||
java_subdirectory = "main/java/org/wpilib/command2/button"
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(template_directory / "main/java"),
|
||||
autoescape=False,
|
||||
keep_trailing_newline=True,
|
||||
)
|
||||
root_path = output_directory / java_subdirectory
|
||||
template = env.get_template("first_ds_commandhid.java.jinja")
|
||||
for controller in controllers:
|
||||
controller_name = f"Command{controller['ClassName']}Controller.java"
|
||||
output = template.render(controller)
|
||||
write_controller_file(root_path, controller_name, output)
|
||||
|
||||
# C++ headers
|
||||
hdr_subdirectory = "main/native/include/wpi/commands2/button"
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(template_directory / hdr_subdirectory),
|
||||
autoescape=False,
|
||||
keep_trailing_newline=True,
|
||||
)
|
||||
root_path = output_directory / hdr_subdirectory
|
||||
template = env.get_template("first_ds_commandhid.hpp.jinja")
|
||||
for controller in controllers:
|
||||
controller_name = f"Command{controller['ClassName']}Controller.hpp"
|
||||
output = template.render(controller)
|
||||
write_controller_file(root_path, controller_name, output)
|
||||
|
||||
# C++ files
|
||||
cpp_subdirectory = "main/native/cpp/wpi/commands2/button"
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(template_directory / cpp_subdirectory),
|
||||
autoescape=False,
|
||||
keep_trailing_newline=True,
|
||||
)
|
||||
root_path = output_directory / cpp_subdirectory
|
||||
template = env.get_template("first_ds_commandhid.cpp.jinja")
|
||||
for controller in controllers:
|
||||
controller_name = f"Command{controller['ClassName']}Controller.cpp"
|
||||
output = template.render(controller)
|
||||
write_controller_file(root_path, controller_name, output)
|
||||
|
||||
if python_output_directory is not None:
|
||||
python_subdirectory = "commands2/button"
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(template_directory / "main/python"),
|
||||
autoescape=False,
|
||||
keep_trailing_newline=True,
|
||||
)
|
||||
root_path = python_output_directory / python_subdirectory
|
||||
template = env.get_template("first_ds_commandhid.py.jinja")
|
||||
for controller in controllers:
|
||||
controller_name = f"command{controller['ClassName'].lower()}controller.py"
|
||||
output = template.render(controller)
|
||||
write_controller_file(root_path, controller_name, output)
|
||||
|
||||
|
||||
def main():
|
||||
script_path = Path(__file__).resolve()
|
||||
dirname = script_path.parent
|
||||
@@ -86,9 +228,32 @@ def main():
|
||||
default="wpilibj/src/generate/hids.json",
|
||||
type=Path,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--first_ds_schema_file",
|
||||
help="Optional. If set, will use this file for the FIRST Driver Station HID schema",
|
||||
default="wpilibj/src/generate/first_ds_hids.json",
|
||||
type=Path,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--python_output_directory",
|
||||
help="Optional. If set, will output generated Python files to this directory",
|
||||
default=dirname / "src/main/python",
|
||||
type=Path,
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
generate_hids(args.output_directory, args.template_root, args.schema_file)
|
||||
python_output_directory = (
|
||||
None
|
||||
if args.python_output_directory.name == "__none__"
|
||||
else args.python_output_directory
|
||||
)
|
||||
generate_first_ds_hids(
|
||||
args.output_directory,
|
||||
args.template_root,
|
||||
args.first_ds_schema_file,
|
||||
python_output_directory,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -18,8 +18,9 @@ import org.wpilib.event.EventLoop;
|
||||
* @see {{ ConsoleName }}Controller
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
|
||||
private final {{ ConsoleName }}Controller m_hid;
|
||||
public class Command{{ ConsoleName }}Controller {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final {{ ConsoleName }}Controller m_controller;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -27,19 +28,27 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public Command{{ ConsoleName }}Controller(int port) {
|
||||
super(port);
|
||||
m_hid = new {{ ConsoleName }}Controller(port);
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_controller = new {{ ConsoleName }}Controller(m_hid.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
@Override
|
||||
public {{ ConsoleName }}Controller getHID() {
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying {{ ConsoleName }}Controller object.
|
||||
*
|
||||
* @return the wrapped {{ ConsoleName }}Controller object
|
||||
*/
|
||||
public {{ ConsoleName }}Controller get{{ ConsoleName }}Controller() {
|
||||
return m_controller;
|
||||
}
|
||||
{% for button in buttons %}
|
||||
/**
|
||||
* Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's digital signal.
|
||||
@@ -60,7 +69,7 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger {{ button.name }}(EventLoop loop) {
|
||||
return button({{ ConsoleName }}Controller.Button.k{{ capitalize_first(button.name) }}.value, loop);
|
||||
return m_hid.button({{ ConsoleName }}Controller.Button.k{{ capitalize_first(button.name) }}.value, loop);
|
||||
}
|
||||
{% endfor -%}
|
||||
{% for trigger in triggers -%}
|
||||
@@ -76,7 +85,7 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public Trigger {{ trigger.name }}(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan({{ ConsoleName }}Controller.Axis.k{{ capitalize_first(trigger.name) }}.value, threshold, loop);
|
||||
return m_hid.axisGreaterThan({{ ConsoleName }}Controller.Axis.k{{ capitalize_first(trigger.name) }}.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,7 +121,7 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double get{{ stick.NameParts|map("capitalize")|join }}() {
|
||||
return m_hid.get{{ stick.NameParts|map("capitalize")|join }}();
|
||||
return m_controller.get{{ stick.NameParts|map("capitalize")|join }}();
|
||||
}
|
||||
{% endfor -%}
|
||||
{% for trigger in triggers %}
|
||||
@@ -123,7 +132,7 @@ public class Command{{ ConsoleName }}Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double get{{ capitalize_first(trigger.name) }}Axis() {
|
||||
return m_hid.get{{ capitalize_first(trigger.name) }}Axis();
|
||||
return m_controller.get{{ capitalize_first(trigger.name) }}Axis();
|
||||
}
|
||||
{% endfor -%}
|
||||
}
|
||||
|
||||
258
commandsv2/src/generate/main/java/first_ds_commandhid.java.jinja
Normal file
258
commandsv2/src/generate/main/java/first_ds_commandhid.java.jinja
Normal file
@@ -0,0 +1,258 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
|
||||
package org.wpilib.command2.button;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.wpilib.command2.CommandScheduler;
|
||||
import org.wpilib.driverstation.{{ ClassName }}Controller;
|
||||
import org.wpilib.event.EventLoop;
|
||||
|
||||
/**
|
||||
* A version of {@link {{ ClassName }}Controller} with {@link Trigger} factories for command-based.
|
||||
*
|
||||
* @see {{ ClassName }}Controller
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class Command{{ ClassName }}Controller {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final {{ ClassName }}Controller m_controller;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public Command{{ ClassName }}Controller(int port) {
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_controller = new {{ ClassName }}Controller(m_hid.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller with a {{ ClassName }}Controller object.
|
||||
*
|
||||
* @param controller The {{ ClassName }}Controller object to use for this controller.
|
||||
*/
|
||||
public Command{{ ClassName }}Controller({{ ClassName }}Controller controller) {
|
||||
m_controller =
|
||||
Objects.requireNonNull(controller, "Provided {{ ClassName }}Controller cannot be null");
|
||||
m_hid = new CommandGenericHID(m_controller.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
public {{ ClassName }}Controller getController() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @return an event instance representing the button's digital signal attached to the {@link
|
||||
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #button({{ ClassName }}Controller.Button, EventLoop)
|
||||
*/
|
||||
public Trigger button({{ ClassName }}Controller.Button button) {
|
||||
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return an event instance representing the button's digital signal attached to the given loop.
|
||||
*/
|
||||
public Trigger button({{ ClassName }}Controller.Button button, EventLoop loop) {
|
||||
return m_hid.button(button.value, loop);
|
||||
}
|
||||
{% for button in buttons %}
|
||||
/**
|
||||
* Constructs a Trigger instance around the {{ button.DocName }} button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the {{ button.DocName }} button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #{{ button.Name }}(EventLoop)
|
||||
*/
|
||||
public Trigger {{ button.Name }}() {
|
||||
return {{ button.Name }}(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the {{ button.DocName }} button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the {{ button.DocName }} button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger {{ button.Name }}(EventLoop loop) {
|
||||
return button({{ ClassName }}Controller.Button.{{ button.ConstantName }}, loop);
|
||||
}
|
||||
{% endfor -%}
|
||||
{% for trigger in triggerAxes %}
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the {{ trigger.DocName }}. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @param loop the event loop instance to attach the Trigger to.
|
||||
* @return a Trigger instance that is true when the {{ trigger.DocName }} axis exceeds the provided
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public Trigger {{ trigger.Name }}(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(
|
||||
{{ ClassName }}Controller.Axis.{{ trigger.AxisConstantName }}, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the {{ trigger.DocName }}. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @return a Trigger instance that is true when the {{ trigger.DocName }} axis exceeds the provided
|
||||
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
|
||||
* button loop}.
|
||||
*/
|
||||
public Trigger {{ trigger.Name }}(double threshold) {
|
||||
return {{ trigger.Name }}(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
{% if trigger.HasDefaultThresholdMethod %}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the {{ trigger.DocName }}. The returned
|
||||
* trigger will be true when the axis value is greater than 0.5.
|
||||
*
|
||||
* @return a Trigger instance that is true when the {{ trigger.DocName }} axis exceeds 0.5,
|
||||
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
|
||||
* loop}.
|
||||
*/
|
||||
public Trigger {{ trigger.Name }}() {
|
||||
return {{ trigger.Name }}(0.5);
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
|
||||
* loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the axis value is less than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisLessThan({{ ClassName }}Controller.Axis axis, double threshold) {
|
||||
return m_hid.axisLessThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to
|
||||
* @return a Trigger instance that is true when the axis value is less than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisLessThan(
|
||||
{{ ClassName }}Controller.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisLessThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
|
||||
* loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the axis value is greater than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisGreaterThan({{ ClassName }}Controller.Axis axis, double threshold) {
|
||||
return m_hid.axisGreaterThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is greater than {@code
|
||||
* threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis value is greater than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisGreaterThan(
|
||||
{{ ClassName }}Controller.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
|
||||
* threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis magnitude value is greater than the
|
||||
* provided threshold.
|
||||
*/
|
||||
public Trigger axisMagnitudeGreaterThan(
|
||||
{{ ClassName }}Controller.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
|
||||
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
|
||||
*/
|
||||
public Trigger axisMagnitudeGreaterThan({{ ClassName }}Controller.Axis axis, double threshold) {
|
||||
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the axis.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
public double getAxis({{ ClassName }}Controller.Axis axis) {
|
||||
return m_hid.getRawAxis(axis.value);
|
||||
}
|
||||
|
||||
{% for axis in axes %}
|
||||
/**
|
||||
* Get the {{ axis.DocName }} value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double get{{ axis.MethodName }}() {
|
||||
return m_controller.get{{ axis.MethodName }}();
|
||||
}
|
||||
{% endfor -%}
|
||||
}
|
||||
@@ -11,33 +11,39 @@
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Command{{ ConsoleName }}Controller::Command{{ ConsoleName }}Controller(int port)
|
||||
: CommandGenericHID(port), m_hid{wpi::{{ ConsoleName }}Controller(port)} {}
|
||||
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
|
||||
m_controller{m_hid->GetHID()} {}
|
||||
|
||||
wpi::{{ ConsoleName }}Controller& Command{{ ConsoleName }}Controller::GetHID() {
|
||||
return m_hid;
|
||||
CommandGenericHID& Command{{ ConsoleName }}Controller::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
wpi::{{ ConsoleName }}Controller&
|
||||
Command{{ ConsoleName }}Controller::Get{{ ConsoleName }}Controller() {
|
||||
return m_controller;
|
||||
}
|
||||
{% for button in buttons %}
|
||||
Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(button.name) }}(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::{{ ConsoleName }}Controller::Button::k{{ capitalize_first(button.name) }}, loop);
|
||||
return m_hid->Button(
|
||||
wpi::{{ ConsoleName }}Controller::Button::k{{ capitalize_first(button.name) }}, loop);
|
||||
}
|
||||
{% endfor -%}
|
||||
{% for trigger in triggers -%}
|
||||
{% if trigger.UseThresholdMethods %}
|
||||
Trigger Command{{ ConsoleName }}Controller::{{ capitalize_first(trigger.name) }}(double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.Get{{ capitalize_first(trigger.name) }}Axis() > threshold;
|
||||
});
|
||||
return m_hid->AxisGreaterThan(
|
||||
wpi::{{ ConsoleName }}Controller::Axis::k{{ capitalize_first(trigger.name) }}, threshold, loop);
|
||||
}
|
||||
{% endif -%}
|
||||
{% endfor -%}
|
||||
{% for stick in sticks %}
|
||||
double Command{{ ConsoleName }}Controller::Get{{ stick.NameParts|map("capitalize")|join }}() const {
|
||||
return m_hid.Get{{ stick.NameParts|map("capitalize")|join }}();
|
||||
return m_controller.Get{{ stick.NameParts|map("capitalize")|join }}();
|
||||
}
|
||||
{% endfor -%}
|
||||
{% for trigger in triggers %}
|
||||
double Command{{ ConsoleName }}Controller::Get{{ capitalize_first(trigger.name) }}Axis() const {
|
||||
return m_hid.Get{{ capitalize_first(trigger.name) }}Axis();
|
||||
return m_controller.Get{{ capitalize_first(trigger.name) }}Axis();
|
||||
}
|
||||
{% endfor -%}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
#include "wpi/commands2/button/Command{{ ClassName }}Controller.hpp"
|
||||
|
||||
using namespace wpi::cmd;
|
||||
|
||||
Command{{ ClassName }}Controller::Command{{ ClassName }}Controller(int port)
|
||||
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
|
||||
m_ownedController =
|
||||
std::make_unique<wpi::{{ ClassName }}Controller>(m_hid->GetHID());
|
||||
m_controller = m_ownedController.get();
|
||||
}
|
||||
|
||||
Command{{ ClassName }}Controller::Command{{ ClassName }}Controller(
|
||||
wpi::{{ ClassName }}Controller* controller)
|
||||
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
|
||||
m_hid{m_ownedHid.get()},
|
||||
m_controller{controller} {}
|
||||
|
||||
CommandGenericHID& Command{{ ClassName }}Controller::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
wpi::{{ ClassName }}Controller&
|
||||
Command{{ ClassName }}Controller::GetController() {
|
||||
return *m_controller;
|
||||
}
|
||||
|
||||
const wpi::{{ ClassName }}Controller&
|
||||
Command{{ ClassName }}Controller::GetController() const {
|
||||
return *m_controller;
|
||||
}
|
||||
|
||||
Trigger Command{{ ClassName }}Controller::Button(
|
||||
enum wpi::{{ ClassName }}Controller::Button button,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->Button(static_cast<int>(button), loop);
|
||||
}
|
||||
|
||||
{% for button in buttons %}
|
||||
Trigger Command{{ ClassName }}Controller::{{ button.MethodName }}(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::{{ ClassName }}Controller::Button::{{ button.ConstantName }},
|
||||
loop);
|
||||
}
|
||||
{% endfor -%}
|
||||
{% for trigger in triggerAxes %}
|
||||
Trigger Command{{ ClassName }}Controller::{{ trigger.MethodName }}(
|
||||
double threshold, wpi::EventLoop* loop) const {
|
||||
return AxisGreaterThan(
|
||||
wpi::{{ ClassName }}Controller::Axis::{{ trigger.AxisConstantName }},
|
||||
threshold, loop);
|
||||
}
|
||||
{% endfor %}
|
||||
Trigger Command{{ ClassName }}Controller::AxisLessThan(
|
||||
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
|
||||
}
|
||||
|
||||
Trigger Command{{ ClassName }}Controller::AxisGreaterThan(
|
||||
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
|
||||
}
|
||||
|
||||
Trigger Command{{ ClassName }}Controller::AxisMagnitudeGreaterThan(
|
||||
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
|
||||
loop);
|
||||
}
|
||||
|
||||
{% for axis in axes %}
|
||||
double Command{{ ClassName }}Controller::Get{{ axis.MethodName }}() const {
|
||||
return m_controller->Get{{ axis.MethodName }}();
|
||||
}
|
||||
{% endfor -%}
|
||||
@@ -8,11 +8,10 @@
|
||||
{%- endmacro %}
|
||||
#pragma once
|
||||
|
||||
#include "wpi/driverstation/{{ ConsoleName }}Controller.hpp"
|
||||
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
#include "wpi/driverstation/{{ ConsoleName }}Controller.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
@@ -21,7 +20,7 @@ namespace wpi::cmd {
|
||||
*
|
||||
* @see wpi::{{ ConsoleName }}Controller
|
||||
*/
|
||||
class Command{{ ConsoleName }}Controller : public CommandGenericHID {
|
||||
class Command{{ ConsoleName }}Controller {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -32,11 +31,18 @@ class Command{{ ConsoleName }}Controller : public CommandGenericHID {
|
||||
explicit Command{{ ConsoleName }}Controller(int port);
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
wpi::{{ ConsoleName }}Controller& GetHID();
|
||||
CommandGenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Get the underlying {{ ConsoleName }}Controller object.
|
||||
*
|
||||
* @return the wrapped {{ ConsoleName }}Controller object
|
||||
*/
|
||||
wpi::{{ ConsoleName }}Controller& Get{{ ConsoleName }}Controller();
|
||||
{% for button in buttons %}
|
||||
/**
|
||||
* Constructs a Trigger instance around the {{ button.DocName|default(button.name) }} button's
|
||||
@@ -88,6 +94,7 @@ class Command{{ ConsoleName }}Controller : public CommandGenericHID {
|
||||
double Get{{ capitalize_first(trigger.name) }}Axis() const;
|
||||
{% endfor %}
|
||||
private:
|
||||
wpi::{{ ConsoleName }}Controller m_hid;
|
||||
CommandGenericHID* m_hid;
|
||||
wpi::{{ ConsoleName }}Controller m_controller;
|
||||
};
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "wpi/driverstation/{{ ClassName }}Controller.hpp"
|
||||
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link wpi::{{ ClassName }}Controller} with {@link Trigger}
|
||||
* factories for command-based.
|
||||
*
|
||||
* @see wpi::{{ ClassName }}Controller
|
||||
*/
|
||||
class Command{{ ClassName }}Controller {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is
|
||||
* plugged into.
|
||||
*/
|
||||
explicit Command{{ ClassName }}Controller(int port);
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller with a {{ ClassName }}Controller object.
|
||||
*
|
||||
* @param controller The {{ ClassName }}Controller object to use for this controller.
|
||||
*/
|
||||
explicit Command{{ ClassName }}Controller(wpi::{{ ClassName }}Controller* controller);
|
||||
|
||||
/**
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
CommandGenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
wpi::{{ ClassName }}Controller& GetController();
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
const wpi::{{ ClassName }}Controller& GetController() const;
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return an event instance representing the button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
Trigger Button(enum wpi::{{ ClassName }}Controller::Button button,
|
||||
wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
{% for button in buttons %}
|
||||
/**
|
||||
* Constructs a Trigger instance around the {{ button.DocName }} button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the {{ button.DocName }} button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger {{ button.MethodName }}(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
{% endfor -%}
|
||||
{% for trigger in triggerAxes %}
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the
|
||||
* {{ trigger.DocName }}. The returned Trigger will be true when the axis value
|
||||
* is greater than threshold.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned Trigger to be
|
||||
* true. This value should be in the range [0, 1] where 0 is the unpressed
|
||||
* state of the axis.{% if trigger.HasDefaultThresholdMethod %} Defaults to 0.5.{% endif %}
|
||||
* @param loop the event loop instance to attach the Trigger to. Defaults to
|
||||
* the CommandScheduler's default loop.
|
||||
* @return a Trigger instance that is true when the {{ trigger.DocName }} axis
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger {{ trigger.MethodName }}(
|
||||
double threshold{% if trigger.HasDefaultThresholdMethod %} = 0.5{% endif %},
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
{% endfor %}
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than
|
||||
* {@code threshold}, attached to {@link
|
||||
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
|
||||
* button loop}.
|
||||
* @param axis The axis to read, starting at 0.
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the event to. Defaults to
|
||||
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
* @return a Trigger instance that is true when the axis value is less than
|
||||
* the provided threshold.
|
||||
*/
|
||||
Trigger AxisLessThan(
|
||||
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is greater
|
||||
* than {@code threshold}, attached to {@link
|
||||
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
|
||||
* button loop}.
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the event to. Defaults to
|
||||
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
* @return a Trigger instance that is true when the axis value is greater than
|
||||
* the provided threshold.
|
||||
*/
|
||||
Trigger AxisGreaterThan(
|
||||
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is
|
||||
* greater than {@code threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis magnitude value is
|
||||
* greater than the provided threshold.
|
||||
*/
|
||||
Trigger AxisMagnitudeGreaterThan(
|
||||
wpi::{{ ClassName }}Controller::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
{% for axis in axes %}
|
||||
/**
|
||||
* Get the {{ axis.DocName }} value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double Get{{ axis.MethodName }}() const;
|
||||
{% endfor %}
|
||||
private:
|
||||
std::unique_ptr<CommandGenericHID> m_ownedHid;
|
||||
CommandGenericHID* m_hid = nullptr;
|
||||
std::unique_ptr<wpi::{{ ClassName }}Controller> m_ownedController;
|
||||
wpi::{{ ClassName }}Controller* m_controller = nullptr;
|
||||
};
|
||||
} // namespace wpi::cmd
|
||||
170
commandsv2/src/generate/main/python/first_ds_commandhid.py.jinja
Normal file
170
commandsv2/src/generate/main/python/first_ds_commandhid.py.jinja
Normal file
@@ -0,0 +1,170 @@
|
||||
# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
|
||||
from typing import Optional, Union
|
||||
|
||||
from wpilib import EventLoop, {{ ClassName }}Controller
|
||||
|
||||
from .commandgenerichid import CommandGenericHID
|
||||
from .trigger import Trigger
|
||||
|
||||
|
||||
class Command{{ ClassName }}Controller:
|
||||
"""
|
||||
A version of :class:`wpilib.{{ ClassName }}Controller` with :class:`.Trigger` factories for command-based.
|
||||
"""
|
||||
|
||||
_hid: CommandGenericHID
|
||||
_controller: {{ ClassName }}Controller
|
||||
|
||||
def __init__(self, hid: Union[int, {{ ClassName }}Controller]):
|
||||
"""
|
||||
Construct an instance of a controller.
|
||||
|
||||
:param hid: The port index on the Driver Station that the controller is plugged into,
|
||||
or the {{ ClassName }}Controller object to use for this controller.
|
||||
"""
|
||||
if isinstance(hid, int):
|
||||
self._hid = CommandGenericHID.getCommandGenericHID(hid)
|
||||
self._controller = {{ ClassName }}Controller(self._hid.getHID())
|
||||
else:
|
||||
self._hid = CommandGenericHID(hid.getHID())
|
||||
self._controller = hid
|
||||
|
||||
def getHID(self) -> CommandGenericHID:
|
||||
"""
|
||||
Get the underlying CommandGenericHID object.
|
||||
|
||||
:returns: the wrapped CommandGenericHID object
|
||||
"""
|
||||
return self._hid
|
||||
|
||||
def getController(self) -> {{ ClassName }}Controller:
|
||||
"""
|
||||
Get the wrapped controller object.
|
||||
|
||||
:returns: the wrapped controller object
|
||||
"""
|
||||
return self._controller
|
||||
|
||||
def button(
|
||||
self,
|
||||
button: {{ ClassName }}Controller.Button,
|
||||
loop: Optional[EventLoop] = None,
|
||||
) -> Trigger:
|
||||
"""
|
||||
Constructs an event instance around this button's digital signal.
|
||||
|
||||
:param button: the :class:`wpilib.{{ ClassName }}Controller.Button` to read
|
||||
:param loop: the event loop instance to attach the event to
|
||||
"""
|
||||
return self._hid.button(button.value, loop)
|
||||
{% for button in buttons %}
|
||||
def {{ button.Name }}(self, loop: Optional[EventLoop] = None) -> Trigger:
|
||||
"""
|
||||
Constructs a Trigger instance around the {{ button.DocName }} button's digital signal.
|
||||
|
||||
:param loop: the event loop instance to attach the Trigger to, defaults
|
||||
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`
|
||||
|
||||
:returns: a Trigger instance representing the {{ button.DocName }} button's digital signal
|
||||
attached to the given loop.
|
||||
"""
|
||||
return self.button({{ ClassName }}Controller.Button.{{ button.ConstantName }}, loop)
|
||||
{% endfor -%}
|
||||
{% for trigger in triggerAxes %}
|
||||
def {{ trigger.Name }}(
|
||||
self,
|
||||
threshold: float{% if trigger.HasDefaultThresholdMethod %} = 0.5{% endif %},
|
||||
loop: Optional[EventLoop] = None,
|
||||
) -> Trigger:
|
||||
"""
|
||||
Constructs a Trigger instance around the {{ trigger.DocName }} axis value. The returned
|
||||
Trigger will be true when the axis value is greater than ``threshold``.
|
||||
|
||||
:param threshold: the minimum axis value for the returned Trigger to be true. This value
|
||||
should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
:param loop: the event loop instance to attach the Trigger to, defaults
|
||||
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`
|
||||
|
||||
:returns: a Trigger instance that is true when the {{ trigger.DocName }} axis exceeds the
|
||||
provided threshold, attached to the given event loop.
|
||||
"""
|
||||
return self.axisGreaterThan(
|
||||
{{ ClassName }}Controller.Axis.{{ trigger.AxisConstantName }},
|
||||
threshold,
|
||||
loop,
|
||||
)
|
||||
{% endfor %}
|
||||
def axisLessThan(
|
||||
self,
|
||||
axis: {{ ClassName }}Controller.Axis,
|
||||
threshold: float,
|
||||
loop: Optional[EventLoop] = None,
|
||||
) -> Trigger:
|
||||
"""
|
||||
Constructs a Trigger instance that is true when the axis value is less than
|
||||
``threshold``, attached to the given loop.
|
||||
|
||||
:param axis: the :class:`wpilib.{{ ClassName }}Controller.Axis` to read
|
||||
:param threshold: the value below which this Trigger should return true.
|
||||
:param loop: the event loop instance to attach the Trigger to
|
||||
|
||||
:returns: a Trigger instance that is true when the axis value is less than
|
||||
the provided threshold.
|
||||
"""
|
||||
return self._hid.axisLessThan(axis.value, threshold, loop)
|
||||
|
||||
def axisGreaterThan(
|
||||
self,
|
||||
axis: {{ ClassName }}Controller.Axis,
|
||||
threshold: float,
|
||||
loop: Optional[EventLoop] = None,
|
||||
) -> Trigger:
|
||||
"""
|
||||
Constructs a Trigger instance that is true when the axis value is greater
|
||||
than ``threshold``, attached to the given loop.
|
||||
|
||||
:param axis: the :class:`wpilib.{{ ClassName }}Controller.Axis` to read
|
||||
:param threshold: the value above which this Trigger should return true.
|
||||
:param loop: the event loop instance to attach the Trigger to.
|
||||
|
||||
:returns: a Trigger instance that is true when the axis value is greater
|
||||
than the provided threshold.
|
||||
"""
|
||||
return self._hid.axisGreaterThan(axis.value, threshold, loop)
|
||||
|
||||
def axisMagnitudeGreaterThan(
|
||||
self,
|
||||
axis: {{ ClassName }}Controller.Axis,
|
||||
threshold: float,
|
||||
loop: Optional[EventLoop] = None,
|
||||
) -> Trigger:
|
||||
"""
|
||||
Constructs a Trigger instance that is true when the axis magnitude is
|
||||
greater than ``threshold``, attached to the given loop.
|
||||
|
||||
:param axis: the :class:`wpilib.{{ ClassName }}Controller.Axis` to read
|
||||
:param threshold: the value above which this Trigger should return true.
|
||||
:param loop: the event loop instance to attach the Trigger to.
|
||||
|
||||
:returns: a Trigger instance that is true when the axis magnitude is
|
||||
greater than the provided threshold.
|
||||
"""
|
||||
return self._hid.axisMagnitudeGreaterThan(axis.value, threshold, loop)
|
||||
|
||||
def getAxis(self, axis: {{ ClassName }}Controller.Axis) -> float:
|
||||
"""
|
||||
Get the value of the axis.
|
||||
|
||||
:param axis: the :class:`wpilib.{{ ClassName }}Controller.Axis` to read
|
||||
"""
|
||||
return self._hid.getRawAxis(axis.value)
|
||||
{% for axis in axes %}
|
||||
def get{{ axis.MethodName }}(self) -> float:
|
||||
"""
|
||||
Get the {{ axis.DocName }} value of the controller.
|
||||
|
||||
:returns: the axis value.
|
||||
"""
|
||||
return self._controller.get{{ axis.MethodName }}()
|
||||
{% endfor -%}
|
||||
696
commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandDualSenseController.java
generated
Normal file
696
commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandDualSenseController.java
generated
Normal file
@@ -0,0 +1,696 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
|
||||
package org.wpilib.command2.button;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.wpilib.command2.CommandScheduler;
|
||||
import org.wpilib.driverstation.DualSenseController;
|
||||
import org.wpilib.event.EventLoop;
|
||||
|
||||
/**
|
||||
* A version of {@link DualSenseController} with {@link Trigger} factories for command-based.
|
||||
*
|
||||
* @see DualSenseController
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class CommandDualSenseController {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final DualSenseController m_controller;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public CommandDualSenseController(int port) {
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_controller = new DualSenseController(m_hid.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller with a DualSenseController object.
|
||||
*
|
||||
* @param controller The DualSenseController object to use for this controller.
|
||||
*/
|
||||
public CommandDualSenseController(DualSenseController controller) {
|
||||
m_controller =
|
||||
Objects.requireNonNull(controller, "Provided DualSenseController cannot be null");
|
||||
m_hid = new CommandGenericHID(m_controller.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
public DualSenseController getController() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @return an event instance representing the button's digital signal attached to the {@link
|
||||
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #button(DualSenseController.Button, EventLoop)
|
||||
*/
|
||||
public Trigger button(DualSenseController.Button button) {
|
||||
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return an event instance representing the button's digital signal attached to the given loop.
|
||||
*/
|
||||
public Trigger button(DualSenseController.Button button, EventLoop loop) {
|
||||
return m_hid.button(button.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Cross button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Cross button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #cross(EventLoop)
|
||||
*/
|
||||
public Trigger cross() {
|
||||
return cross(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Cross button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Cross button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger cross(EventLoop loop) {
|
||||
return button(DualSenseController.Button.CROSS, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Circle button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Circle button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #circle(EventLoop)
|
||||
*/
|
||||
public Trigger circle() {
|
||||
return circle(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Circle button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Circle button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger circle(EventLoop loop) {
|
||||
return button(DualSenseController.Button.CIRCLE, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Square button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Square button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #square(EventLoop)
|
||||
*/
|
||||
public Trigger square() {
|
||||
return square(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Square button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Square button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger square(EventLoop loop) {
|
||||
return button(DualSenseController.Button.SQUARE, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Triangle button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Triangle button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #triangle(EventLoop)
|
||||
*/
|
||||
public Trigger triangle() {
|
||||
return triangle(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Triangle button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Triangle button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger triangle(EventLoop loop) {
|
||||
return button(DualSenseController.Button.TRIANGLE, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Create button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Create button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #create(EventLoop)
|
||||
*/
|
||||
public Trigger create() {
|
||||
return create(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Create button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Create button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger create(EventLoop loop) {
|
||||
return button(DualSenseController.Button.CREATE, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the PS button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the PS button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #PS(EventLoop)
|
||||
*/
|
||||
public Trigger PS() {
|
||||
return PS(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the PS button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the PS button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger PS(EventLoop loop) {
|
||||
return button(DualSenseController.Button.PS, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Options button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Options button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #options(EventLoop)
|
||||
*/
|
||||
public Trigger options() {
|
||||
return options(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Options button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Options button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger options(EventLoop loop) {
|
||||
return button(DualSenseController.Button.OPTIONS, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the L 3 button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the L 3 button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #L3(EventLoop)
|
||||
*/
|
||||
public Trigger L3() {
|
||||
return L3(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the L 3 button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the L 3 button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger L3(EventLoop loop) {
|
||||
return button(DualSenseController.Button.L3, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the R 3 button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the R 3 button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #R3(EventLoop)
|
||||
*/
|
||||
public Trigger R3() {
|
||||
return R3(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the R 3 button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the R 3 button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger R3(EventLoop loop) {
|
||||
return button(DualSenseController.Button.R3, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the L 1 button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the L 1 button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #L1(EventLoop)
|
||||
*/
|
||||
public Trigger L1() {
|
||||
return L1(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the L 1 button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the L 1 button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger L1(EventLoop loop) {
|
||||
return button(DualSenseController.Button.L1, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the R 1 button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the R 1 button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #R1(EventLoop)
|
||||
*/
|
||||
public Trigger R1() {
|
||||
return R1(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the R 1 button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the R 1 button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger R1(EventLoop loop) {
|
||||
return button(DualSenseController.Button.R1, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Up button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Dpad Up button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #dpadUp(EventLoop)
|
||||
*/
|
||||
public Trigger dpadUp() {
|
||||
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Up button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Dpad Up button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger dpadUp(EventLoop loop) {
|
||||
return button(DualSenseController.Button.DPAD_UP, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Down button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Dpad Down button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #dpadDown(EventLoop)
|
||||
*/
|
||||
public Trigger dpadDown() {
|
||||
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Down button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Dpad Down button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger dpadDown(EventLoop loop) {
|
||||
return button(DualSenseController.Button.DPAD_DOWN, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Left button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Dpad Left button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #dpadLeft(EventLoop)
|
||||
*/
|
||||
public Trigger dpadLeft() {
|
||||
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Left button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Dpad Left button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger dpadLeft(EventLoop loop) {
|
||||
return button(DualSenseController.Button.DPAD_LEFT, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Right button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Dpad Right button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #dpadRight(EventLoop)
|
||||
*/
|
||||
public Trigger dpadRight() {
|
||||
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Right button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Dpad Right button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger dpadRight(EventLoop loop) {
|
||||
return button(DualSenseController.Button.DPAD_RIGHT, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Microphone button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Microphone button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #microphone(EventLoop)
|
||||
*/
|
||||
public Trigger microphone() {
|
||||
return microphone(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Microphone button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Microphone button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger microphone(EventLoop loop) {
|
||||
return button(DualSenseController.Button.MICROPHONE, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Touchpad button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Touchpad button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #touchpad(EventLoop)
|
||||
*/
|
||||
public Trigger touchpad() {
|
||||
return touchpad(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Touchpad button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Touchpad button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger touchpad(EventLoop loop) {
|
||||
return button(DualSenseController.Button.TOUCHPAD, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the L 2. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @param loop the event loop instance to attach the Trigger to.
|
||||
* @return a Trigger instance that is true when the L 2 axis exceeds the provided
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public Trigger L2(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(
|
||||
DualSenseController.Axis.L2, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the L 2. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @return a Trigger instance that is true when the L 2 axis exceeds the provided
|
||||
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
|
||||
* button loop}.
|
||||
*/
|
||||
public Trigger L2(double threshold) {
|
||||
return L2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the L 2. The returned
|
||||
* trigger will be true when the axis value is greater than 0.5.
|
||||
*
|
||||
* @return a Trigger instance that is true when the L 2 axis exceeds 0.5,
|
||||
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
|
||||
* loop}.
|
||||
*/
|
||||
public Trigger L2() {
|
||||
return L2(0.5);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the R 2. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @param loop the event loop instance to attach the Trigger to.
|
||||
* @return a Trigger instance that is true when the R 2 axis exceeds the provided
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public Trigger R2(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(
|
||||
DualSenseController.Axis.R2, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the R 2. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @return a Trigger instance that is true when the R 2 axis exceeds the provided
|
||||
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
|
||||
* button loop}.
|
||||
*/
|
||||
public Trigger R2(double threshold) {
|
||||
return R2(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the R 2. The returned
|
||||
* trigger will be true when the axis value is greater than 0.5.
|
||||
*
|
||||
* @return a Trigger instance that is true when the R 2 axis exceeds 0.5,
|
||||
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
|
||||
* loop}.
|
||||
*/
|
||||
public Trigger R2() {
|
||||
return R2(0.5);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
|
||||
* loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the axis value is less than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisLessThan(DualSenseController.Axis axis, double threshold) {
|
||||
return m_hid.axisLessThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to
|
||||
* @return a Trigger instance that is true when the axis value is less than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisLessThan(
|
||||
DualSenseController.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisLessThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
|
||||
* loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the axis value is greater than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisGreaterThan(DualSenseController.Axis axis, double threshold) {
|
||||
return m_hid.axisGreaterThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is greater than {@code
|
||||
* threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis value is greater than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisGreaterThan(
|
||||
DualSenseController.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
|
||||
* threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis magnitude value is greater than the
|
||||
* provided threshold.
|
||||
*/
|
||||
public Trigger axisMagnitudeGreaterThan(
|
||||
DualSenseController.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
|
||||
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
|
||||
*/
|
||||
public Trigger axisMagnitudeGreaterThan(DualSenseController.Axis axis, double threshold) {
|
||||
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the axis.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
public double getAxis(DualSenseController.Axis axis) {
|
||||
return m_hid.getRawAxis(axis.value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Left X value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return m_controller.getLeftX();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Left Y value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return m_controller.getLeftY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Right X value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return m_controller.getRightX();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Right Y value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return m_controller.getRightY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the L 2 value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getL2() {
|
||||
return m_controller.getL2();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the R 2 value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getR2() {
|
||||
return m_controller.getR2();
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,9 @@ import org.wpilib.event.EventLoop;
|
||||
* @see NiDsPS4Controller
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
private final NiDsPS4Controller m_hid;
|
||||
public class CommandNiDsPS4Controller {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final NiDsPS4Controller m_controller;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -25,20 +26,28 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public CommandNiDsPS4Controller(int port) {
|
||||
super(port);
|
||||
m_hid = new NiDsPS4Controller(port);
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_controller = new NiDsPS4Controller(m_hid.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
@Override
|
||||
public NiDsPS4Controller getHID() {
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying NiDsPS4Controller object.
|
||||
*
|
||||
* @return the wrapped NiDsPS4Controller object
|
||||
*/
|
||||
public NiDsPS4Controller getNiDsPS4Controller() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the square button's digital signal.
|
||||
*
|
||||
@@ -58,7 +67,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger square(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kSquare.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kSquare.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +89,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger cross(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kCross.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kCross.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +111,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger circle(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kCircle.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kCircle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +133,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger triangle(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kTriangle.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kTriangle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +155,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger L1(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kL1.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kL1.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +177,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger R1(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kR1.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kR1.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +199,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger L2(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kL2.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kL2.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +221,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger R2(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kR2.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kR2.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +243,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger share(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kShare.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kShare.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +265,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger options(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kOptions.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kOptions.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +287,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger L3(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kL3.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kL3.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +309,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger R3(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kR3.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kR3.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +331,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger PS(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kPS.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kPS.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,7 +353,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger touchpad(EventLoop loop) {
|
||||
return button(NiDsPS4Controller.Button.kTouchpad.value, loop);
|
||||
return m_hid.button(NiDsPS4Controller.Button.kTouchpad.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,7 +362,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return m_hid.getLeftX();
|
||||
return m_controller.getLeftX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,7 +371,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return m_hid.getLeftY();
|
||||
return m_controller.getLeftY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +380,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return m_hid.getRightX();
|
||||
return m_controller.getRightX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,7 +389,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return m_hid.getRightY();
|
||||
return m_controller.getRightY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,7 +399,7 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getL2Axis() {
|
||||
return m_hid.getL2Axis();
|
||||
return m_controller.getL2Axis();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,6 +409,6 @@ public class CommandNiDsPS4Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getR2Axis() {
|
||||
return m_hid.getR2Axis();
|
||||
return m_controller.getR2Axis();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ import org.wpilib.event.EventLoop;
|
||||
* @see NiDsPS5Controller
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
private final NiDsPS5Controller m_hid;
|
||||
public class CommandNiDsPS5Controller {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final NiDsPS5Controller m_controller;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -25,20 +26,28 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public CommandNiDsPS5Controller(int port) {
|
||||
super(port);
|
||||
m_hid = new NiDsPS5Controller(port);
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_controller = new NiDsPS5Controller(m_hid.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
@Override
|
||||
public NiDsPS5Controller getHID() {
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying NiDsPS5Controller object.
|
||||
*
|
||||
* @return the wrapped NiDsPS5Controller object
|
||||
*/
|
||||
public NiDsPS5Controller getNiDsPS5Controller() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the square button's digital signal.
|
||||
*
|
||||
@@ -58,7 +67,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger square(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kSquare.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kSquare.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +89,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger cross(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kCross.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kCross.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +111,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger circle(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kCircle.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kCircle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +133,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger triangle(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kTriangle.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kTriangle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +155,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger L1(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kL1.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kL1.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +177,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger R1(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kR1.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kR1.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +199,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger L2(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kL2.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kL2.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +221,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger R2(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kR2.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kR2.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +243,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger create(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kCreate.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kCreate.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +265,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger options(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kOptions.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kOptions.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +287,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger L3(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kL3.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kL3.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +309,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger R3(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kR3.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kR3.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +331,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger PS(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kPS.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kPS.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,7 +353,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger touchpad(EventLoop loop) {
|
||||
return button(NiDsPS5Controller.Button.kTouchpad.value, loop);
|
||||
return m_hid.button(NiDsPS5Controller.Button.kTouchpad.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,7 +362,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return m_hid.getLeftX();
|
||||
return m_controller.getLeftX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,7 +371,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return m_hid.getLeftY();
|
||||
return m_controller.getLeftY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +380,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return m_hid.getRightX();
|
||||
return m_controller.getRightX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,7 +389,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return m_hid.getRightY();
|
||||
return m_controller.getRightY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,7 +399,7 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getL2Axis() {
|
||||
return m_hid.getL2Axis();
|
||||
return m_controller.getL2Axis();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,6 +409,6 @@ public class CommandNiDsPS5Controller extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getR2Axis() {
|
||||
return m_hid.getR2Axis();
|
||||
return m_controller.getR2Axis();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ import org.wpilib.event.EventLoop;
|
||||
* @see NiDsStadiaController
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
private final NiDsStadiaController m_hid;
|
||||
public class CommandNiDsStadiaController {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final NiDsStadiaController m_controller;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -25,20 +26,28 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public CommandNiDsStadiaController(int port) {
|
||||
super(port);
|
||||
m_hid = new NiDsStadiaController(port);
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_controller = new NiDsStadiaController(m_hid.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
@Override
|
||||
public NiDsStadiaController getHID() {
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying NiDsStadiaController object.
|
||||
*
|
||||
* @return the wrapped NiDsStadiaController object
|
||||
*/
|
||||
public NiDsStadiaController getNiDsStadiaController() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's digital signal.
|
||||
*
|
||||
@@ -58,7 +67,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger a(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kA.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kA.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +89,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger b(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kB.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kB.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +111,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger x(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kX.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kX.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +133,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger y(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kY.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kY.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +155,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger leftBumper(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kLeftBumper.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kLeftBumper.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +177,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger rightBumper(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kRightBumper.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kRightBumper.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +199,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger leftStick(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kLeftStick.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kLeftStick.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +221,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger rightStick(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kRightStick.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kRightStick.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +243,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger ellipses(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kEllipses.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kEllipses.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +265,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger hamburger(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kHamburger.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kHamburger.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +287,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger stadia(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kStadia.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kStadia.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,7 +309,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger rightTrigger(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kRightTrigger.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kRightTrigger.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +331,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger leftTrigger(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kLeftTrigger.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kLeftTrigger.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,7 +353,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger google(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kGoogle.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kGoogle.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,7 +375,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger frame(EventLoop loop) {
|
||||
return button(NiDsStadiaController.Button.kFrame.value, loop);
|
||||
return m_hid.button(NiDsStadiaController.Button.kFrame.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +384,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return m_hid.getLeftX();
|
||||
return m_controller.getLeftX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,7 +393,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return m_hid.getRightX();
|
||||
return m_controller.getRightX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,7 +402,7 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return m_hid.getLeftY();
|
||||
return m_controller.getLeftY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -402,6 +411,6 @@ public class CommandNiDsStadiaController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return m_hid.getRightY();
|
||||
return m_controller.getRightY();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ import org.wpilib.event.EventLoop;
|
||||
* @see NiDsXboxController
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
private final NiDsXboxController m_hid;
|
||||
public class CommandNiDsXboxController {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final NiDsXboxController m_controller;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -25,20 +26,28 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public CommandNiDsXboxController(int port) {
|
||||
super(port);
|
||||
m_hid = new NiDsXboxController(port);
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_controller = new NiDsXboxController(m_hid.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
@Override
|
||||
public NiDsXboxController getHID() {
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying NiDsXboxController object.
|
||||
*
|
||||
* @return the wrapped NiDsXboxController object
|
||||
*/
|
||||
public NiDsXboxController getNiDsXboxController() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's digital signal.
|
||||
*
|
||||
@@ -58,7 +67,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger a(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kA.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kA.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +89,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger b(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kB.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kB.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +111,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger x(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kX.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kX.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +133,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger y(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kY.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kY.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +155,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger leftBumper(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kLeftBumper.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kLeftBumper.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +177,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger rightBumper(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kRightBumper.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kRightBumper.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +199,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger back(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kBack.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kBack.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +221,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger start(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kStart.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kStart.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +243,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger leftStick(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kLeftStick.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kLeftStick.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +265,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger rightStick(EventLoop loop) {
|
||||
return button(NiDsXboxController.Button.kRightStick.value, loop);
|
||||
return m_hid.button(NiDsXboxController.Button.kRightStick.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +279,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public Trigger leftTrigger(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(NiDsXboxController.Axis.kLeftTrigger.value, threshold, loop);
|
||||
return m_hid.axisGreaterThan(NiDsXboxController.Axis.kLeftTrigger.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -309,7 +318,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public Trigger rightTrigger(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(NiDsXboxController.Axis.kRightTrigger.value, threshold, loop);
|
||||
return m_hid.axisGreaterThan(NiDsXboxController.Axis.kRightTrigger.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,7 +352,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return m_hid.getLeftX();
|
||||
return m_controller.getLeftX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -352,7 +361,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return m_hid.getRightX();
|
||||
return m_controller.getRightX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -361,7 +370,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return m_hid.getLeftY();
|
||||
return m_controller.getLeftY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,7 +379,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return m_hid.getRightY();
|
||||
return m_controller.getRightY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,7 +389,7 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftTriggerAxis() {
|
||||
return m_hid.getLeftTriggerAxis();
|
||||
return m_controller.getLeftTriggerAxis();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -390,6 +399,6 @@ public class CommandNiDsXboxController extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightTriggerAxis() {
|
||||
return m_hid.getRightTriggerAxis();
|
||||
return m_controller.getRightTriggerAxis();
|
||||
}
|
||||
}
|
||||
|
||||
652
commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandXboxController.java
generated
Normal file
652
commandsv2/src/generated/main/java/org/wpilib/command2/button/CommandXboxController.java
generated
Normal file
@@ -0,0 +1,652 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
|
||||
package org.wpilib.command2.button;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.wpilib.command2.CommandScheduler;
|
||||
import org.wpilib.driverstation.XboxController;
|
||||
import org.wpilib.event.EventLoop;
|
||||
|
||||
/**
|
||||
* A version of {@link XboxController} with {@link Trigger} factories for command-based.
|
||||
*
|
||||
* @see XboxController
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class CommandXboxController {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final XboxController m_controller;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public CommandXboxController(int port) {
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_controller = new XboxController(m_hid.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller with a XboxController object.
|
||||
*
|
||||
* @param controller The XboxController object to use for this controller.
|
||||
*/
|
||||
public CommandXboxController(XboxController controller) {
|
||||
m_controller =
|
||||
Objects.requireNonNull(controller, "Provided XboxController cannot be null");
|
||||
m_hid = new CommandGenericHID(m_controller.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
public XboxController getController() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @return an event instance representing the button's digital signal attached to the {@link
|
||||
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #button(XboxController.Button, EventLoop)
|
||||
*/
|
||||
public Trigger button(XboxController.Button button) {
|
||||
return button(button, CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return an event instance representing the button's digital signal attached to the given loop.
|
||||
*/
|
||||
public Trigger button(XboxController.Button button, EventLoop loop) {
|
||||
return m_hid.button(button.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the A button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #a(EventLoop)
|
||||
*/
|
||||
public Trigger a() {
|
||||
return a(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the A button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger a(EventLoop loop) {
|
||||
return button(XboxController.Button.A, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the B button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the B button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #b(EventLoop)
|
||||
*/
|
||||
public Trigger b() {
|
||||
return b(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the B button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the B button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger b(EventLoop loop) {
|
||||
return button(XboxController.Button.B, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the X button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the X button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #x(EventLoop)
|
||||
*/
|
||||
public Trigger x() {
|
||||
return x(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the X button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the X button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger x(EventLoop loop) {
|
||||
return button(XboxController.Button.X, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Y button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Y button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #y(EventLoop)
|
||||
*/
|
||||
public Trigger y() {
|
||||
return y(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Y button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Y button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger y(EventLoop loop) {
|
||||
return button(XboxController.Button.Y, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the View button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the View button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #view(EventLoop)
|
||||
*/
|
||||
public Trigger view() {
|
||||
return view(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the View button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the View button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger view(EventLoop loop) {
|
||||
return button(XboxController.Button.VIEW, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Xbox button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Xbox button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #xbox(EventLoop)
|
||||
*/
|
||||
public Trigger xbox() {
|
||||
return xbox(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Xbox button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Xbox button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger xbox(EventLoop loop) {
|
||||
return button(XboxController.Button.XBOX, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Menu button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Menu button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #menu(EventLoop)
|
||||
*/
|
||||
public Trigger menu() {
|
||||
return menu(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Menu button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Menu button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger menu(EventLoop loop) {
|
||||
return button(XboxController.Button.MENU, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Left Stick button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Left Stick button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #leftStick(EventLoop)
|
||||
*/
|
||||
public Trigger leftStick() {
|
||||
return leftStick(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Left Stick button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Left Stick button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger leftStick(EventLoop loop) {
|
||||
return button(XboxController.Button.LEFT_STICK, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Right Stick button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Right Stick button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #rightStick(EventLoop)
|
||||
*/
|
||||
public Trigger rightStick() {
|
||||
return rightStick(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Right Stick button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Right Stick button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger rightStick(EventLoop loop) {
|
||||
return button(XboxController.Button.RIGHT_STICK, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Left Bumper button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Left Bumper button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #leftBumper(EventLoop)
|
||||
*/
|
||||
public Trigger leftBumper() {
|
||||
return leftBumper(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Left Bumper button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Left Bumper button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger leftBumper(EventLoop loop) {
|
||||
return button(XboxController.Button.LEFT_BUMPER, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Right Bumper button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Right Bumper button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #rightBumper(EventLoop)
|
||||
*/
|
||||
public Trigger rightBumper() {
|
||||
return rightBumper(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Right Bumper button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Right Bumper button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger rightBumper(EventLoop loop) {
|
||||
return button(XboxController.Button.RIGHT_BUMPER, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Up button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Dpad Up button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #dpadUp(EventLoop)
|
||||
*/
|
||||
public Trigger dpadUp() {
|
||||
return dpadUp(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Up button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Dpad Up button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger dpadUp(EventLoop loop) {
|
||||
return button(XboxController.Button.DPAD_UP, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Down button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Dpad Down button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #dpadDown(EventLoop)
|
||||
*/
|
||||
public Trigger dpadDown() {
|
||||
return dpadDown(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Down button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Dpad Down button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger dpadDown(EventLoop loop) {
|
||||
return button(XboxController.Button.DPAD_DOWN, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Left button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Dpad Left button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #dpadLeft(EventLoop)
|
||||
*/
|
||||
public Trigger dpadLeft() {
|
||||
return dpadLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Left button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Dpad Left button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger dpadLeft(EventLoop loop) {
|
||||
return button(XboxController.Button.DPAD_LEFT, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Right button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the Dpad Right button's digital signal attached
|
||||
* to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #dpadRight(EventLoop)
|
||||
*/
|
||||
public Trigger dpadRight() {
|
||||
return dpadRight(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Right button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the Dpad Right button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
public Trigger dpadRight(EventLoop loop) {
|
||||
return button(XboxController.Button.DPAD_RIGHT, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the Left Trigger. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @param loop the event loop instance to attach the Trigger to.
|
||||
* @return a Trigger instance that is true when the Left Trigger axis exceeds the provided
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public Trigger leftTrigger(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(
|
||||
XboxController.Axis.LEFT_TRIGGER, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the Left Trigger. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @return a Trigger instance that is true when the Left Trigger axis exceeds the provided
|
||||
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
|
||||
* button loop}.
|
||||
*/
|
||||
public Trigger leftTrigger(double threshold) {
|
||||
return leftTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the Left Trigger. The returned
|
||||
* trigger will be true when the axis value is greater than 0.5.
|
||||
*
|
||||
* @return a Trigger instance that is true when the Left Trigger axis exceeds 0.5,
|
||||
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
|
||||
* loop}.
|
||||
*/
|
||||
public Trigger leftTrigger() {
|
||||
return leftTrigger(0.5);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the Right Trigger. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @param loop the event loop instance to attach the Trigger to.
|
||||
* @return a Trigger instance that is true when the Right Trigger axis exceeds the provided
|
||||
* threshold, attached to the given event loop
|
||||
*/
|
||||
public Trigger rightTrigger(double threshold, EventLoop loop) {
|
||||
return axisGreaterThan(
|
||||
XboxController.Axis.RIGHT_TRIGGER, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the Right Trigger. The returned
|
||||
* trigger will be true when the axis value is greater than {@code threshold}.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned {@link Trigger} to be true. This value
|
||||
* should be in the range [0, 1] where 0 is the unpressed state of the axis.
|
||||
* @return a Trigger instance that is true when the Right Trigger axis exceeds the provided
|
||||
* threshold, attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler
|
||||
* button loop}.
|
||||
*/
|
||||
public Trigger rightTrigger(double threshold) {
|
||||
return rightTrigger(threshold, CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the Right Trigger. The returned
|
||||
* trigger will be true when the axis value is greater than 0.5.
|
||||
*
|
||||
* @return a Trigger instance that is true when the Right Trigger axis exceeds 0.5,
|
||||
* attached to the {@link CommandScheduler#getDefaultButtonLoop() default scheduler button
|
||||
* loop}.
|
||||
*/
|
||||
public Trigger rightTrigger() {
|
||||
return rightTrigger(0.5);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
|
||||
* loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the axis value is less than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisLessThan(XboxController.Axis axis, double threshold) {
|
||||
return m_hid.axisLessThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to
|
||||
* @return a Trigger instance that is true when the axis value is less than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisLessThan(
|
||||
XboxController.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisLessThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than {@code threshold},
|
||||
* attached to {@link CommandScheduler#getDefaultButtonLoop() the default command scheduler button
|
||||
* loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the axis value is greater than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisGreaterThan(XboxController.Axis axis, double threshold) {
|
||||
return m_hid.axisGreaterThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is greater than {@code
|
||||
* threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis value is greater than the provided
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisGreaterThan(
|
||||
XboxController.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
|
||||
* threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis magnitude value is greater than the
|
||||
* provided threshold.
|
||||
*/
|
||||
public Trigger axisMagnitudeGreaterThan(
|
||||
XboxController.Axis axis, double threshold, EventLoop loop) {
|
||||
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is greater than {@code
|
||||
* threshold}, attached to {@link CommandScheduler#getDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
|
||||
*/
|
||||
public Trigger axisMagnitudeGreaterThan(XboxController.Axis axis, double threshold) {
|
||||
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the axis.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
public double getAxis(XboxController.Axis axis) {
|
||||
return m_hid.getRawAxis(axis.value);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Left X value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return m_controller.getLeftX();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Left Y value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return m_controller.getLeftY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Right X value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return m_controller.getRightX();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Right Y value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return m_controller.getRightY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Left Trigger value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftTrigger() {
|
||||
return m_controller.getLeftTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Right Trigger value of the controller.
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightTrigger() {
|
||||
return m_controller.getRightTrigger();
|
||||
}
|
||||
}
|
||||
202
commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandDualSenseController.cpp
generated
Normal file
202
commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandDualSenseController.cpp
generated
Normal file
@@ -0,0 +1,202 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
#include "wpi/commands2/button/CommandDualSenseController.hpp"
|
||||
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandDualSenseController::CommandDualSenseController(int port)
|
||||
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
|
||||
m_ownedController =
|
||||
std::make_unique<wpi::DualSenseController>(m_hid->GetHID());
|
||||
m_controller = m_ownedController.get();
|
||||
}
|
||||
|
||||
CommandDualSenseController::CommandDualSenseController(
|
||||
wpi::DualSenseController* controller)
|
||||
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
|
||||
m_hid{m_ownedHid.get()},
|
||||
m_controller{controller} {}
|
||||
|
||||
CommandGenericHID& CommandDualSenseController::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
wpi::DualSenseController&
|
||||
CommandDualSenseController::GetController() {
|
||||
return *m_controller;
|
||||
}
|
||||
|
||||
const wpi::DualSenseController&
|
||||
CommandDualSenseController::GetController() const {
|
||||
return *m_controller;
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::Button(
|
||||
enum wpi::DualSenseController::Button button,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->Button(static_cast<int>(button), loop);
|
||||
}
|
||||
|
||||
|
||||
Trigger CommandDualSenseController::Cross(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::CROSS,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::Circle(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::CIRCLE,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::Square(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::SQUARE,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::Triangle(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::TRIANGLE,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::Create(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::CREATE,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::PS(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::PS,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::Options(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::OPTIONS,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::L3(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::L3,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::R3(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::R3,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::L1(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::L1,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::R1(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::R1,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::DpadUp(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::DPAD_UP,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::DpadDown(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::DPAD_DOWN,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::DpadLeft(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::DPAD_LEFT,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::DpadRight(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::DPAD_RIGHT,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::Microphone(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::MICROPHONE,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::Touchpad(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::DualSenseController::Button::TOUCHPAD,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::L2(
|
||||
double threshold, wpi::EventLoop* loop) const {
|
||||
return AxisGreaterThan(
|
||||
wpi::DualSenseController::Axis::L2,
|
||||
threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::R2(
|
||||
double threshold, wpi::EventLoop* loop) const {
|
||||
return AxisGreaterThan(
|
||||
wpi::DualSenseController::Axis::R2,
|
||||
threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::AxisLessThan(
|
||||
wpi::DualSenseController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::AxisGreaterThan(
|
||||
wpi::DualSenseController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandDualSenseController::AxisMagnitudeGreaterThan(
|
||||
wpi::DualSenseController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
|
||||
loop);
|
||||
}
|
||||
|
||||
|
||||
double CommandDualSenseController::GetLeftX() const {
|
||||
return m_controller->GetLeftX();
|
||||
}
|
||||
|
||||
double CommandDualSenseController::GetLeftY() const {
|
||||
return m_controller->GetLeftY();
|
||||
}
|
||||
|
||||
double CommandDualSenseController::GetRightX() const {
|
||||
return m_controller->GetRightX();
|
||||
}
|
||||
|
||||
double CommandDualSenseController::GetRightY() const {
|
||||
return m_controller->GetRightY();
|
||||
}
|
||||
|
||||
double CommandDualSenseController::GetL2() const {
|
||||
return m_controller->GetL2();
|
||||
}
|
||||
|
||||
double CommandDualSenseController::GetR2() const {
|
||||
return m_controller->GetR2();
|
||||
}
|
||||
@@ -9,88 +9,108 @@
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandNiDsPS4Controller::CommandNiDsPS4Controller(int port)
|
||||
: CommandGenericHID(port), m_hid{wpi::NiDsPS4Controller(port)} {}
|
||||
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
|
||||
m_controller{m_hid->GetHID()} {}
|
||||
|
||||
wpi::NiDsPS4Controller& CommandNiDsPS4Controller::GetHID() {
|
||||
return m_hid;
|
||||
CommandGenericHID& CommandNiDsPS4Controller::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
wpi::NiDsPS4Controller&
|
||||
CommandNiDsPS4Controller::GetNiDsPS4Controller() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::Square(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kSquare, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kSquare, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::Cross(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kCross, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kCross, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::Circle(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kCircle, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kCircle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::Triangle(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kTriangle, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kTriangle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::L1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kL1, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kL1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::R1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kR1, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kR1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::L2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kL2, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kL2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::R2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kR2, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kR2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::Share(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kShare, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kShare, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::Options(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kOptions, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kOptions, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::L3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kL3, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kL3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::R3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kR3, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kR3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::PS(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kPS, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kPS, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS4Controller::Touchpad(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS4Controller::Button::kTouchpad, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS4Controller::Button::kTouchpad, loop);
|
||||
}
|
||||
|
||||
double CommandNiDsPS4Controller::GetLeftX() const {
|
||||
return m_hid.GetLeftX();
|
||||
return m_controller.GetLeftX();
|
||||
}
|
||||
|
||||
double CommandNiDsPS4Controller::GetLeftY() const {
|
||||
return m_hid.GetLeftY();
|
||||
return m_controller.GetLeftY();
|
||||
}
|
||||
|
||||
double CommandNiDsPS4Controller::GetRightX() const {
|
||||
return m_hid.GetRightX();
|
||||
return m_controller.GetRightX();
|
||||
}
|
||||
|
||||
double CommandNiDsPS4Controller::GetRightY() const {
|
||||
return m_hid.GetRightY();
|
||||
return m_controller.GetRightY();
|
||||
}
|
||||
|
||||
double CommandNiDsPS4Controller::GetL2Axis() const {
|
||||
return m_hid.GetL2Axis();
|
||||
return m_controller.GetL2Axis();
|
||||
}
|
||||
|
||||
double CommandNiDsPS4Controller::GetR2Axis() const {
|
||||
return m_hid.GetR2Axis();
|
||||
return m_controller.GetR2Axis();
|
||||
}
|
||||
|
||||
@@ -9,88 +9,108 @@
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandNiDsPS5Controller::CommandNiDsPS5Controller(int port)
|
||||
: CommandGenericHID(port), m_hid{wpi::NiDsPS5Controller(port)} {}
|
||||
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
|
||||
m_controller{m_hid->GetHID()} {}
|
||||
|
||||
wpi::NiDsPS5Controller& CommandNiDsPS5Controller::GetHID() {
|
||||
return m_hid;
|
||||
CommandGenericHID& CommandNiDsPS5Controller::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
wpi::NiDsPS5Controller&
|
||||
CommandNiDsPS5Controller::GetNiDsPS5Controller() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::Square(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kSquare, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kSquare, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::Cross(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kCross, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kCross, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::Circle(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kCircle, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kCircle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::Triangle(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kTriangle, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kTriangle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::L1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kL1, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kL1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::R1(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kR1, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kR1, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::L2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kL2, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kL2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::R2(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kR2, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kR2, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::Create(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kCreate, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kCreate, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::Options(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kOptions, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kOptions, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::L3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kL3, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kL3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::R3(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kR3, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kR3, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::PS(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kPS, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kPS, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsPS5Controller::Touchpad(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsPS5Controller::Button::kTouchpad, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsPS5Controller::Button::kTouchpad, loop);
|
||||
}
|
||||
|
||||
double CommandNiDsPS5Controller::GetLeftX() const {
|
||||
return m_hid.GetLeftX();
|
||||
return m_controller.GetLeftX();
|
||||
}
|
||||
|
||||
double CommandNiDsPS5Controller::GetLeftY() const {
|
||||
return m_hid.GetLeftY();
|
||||
return m_controller.GetLeftY();
|
||||
}
|
||||
|
||||
double CommandNiDsPS5Controller::GetRightX() const {
|
||||
return m_hid.GetRightX();
|
||||
return m_controller.GetRightX();
|
||||
}
|
||||
|
||||
double CommandNiDsPS5Controller::GetRightY() const {
|
||||
return m_hid.GetRightY();
|
||||
return m_controller.GetRightY();
|
||||
}
|
||||
|
||||
double CommandNiDsPS5Controller::GetL2Axis() const {
|
||||
return m_hid.GetL2Axis();
|
||||
return m_controller.GetL2Axis();
|
||||
}
|
||||
|
||||
double CommandNiDsPS5Controller::GetR2Axis() const {
|
||||
return m_hid.GetR2Axis();
|
||||
return m_controller.GetR2Axis();
|
||||
}
|
||||
|
||||
@@ -9,84 +9,105 @@
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandNiDsStadiaController::CommandNiDsStadiaController(int port)
|
||||
: CommandGenericHID(port), m_hid{wpi::NiDsStadiaController(port)} {}
|
||||
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
|
||||
m_controller{m_hid->GetHID()} {}
|
||||
|
||||
wpi::NiDsStadiaController& CommandNiDsStadiaController::GetHID() {
|
||||
return m_hid;
|
||||
CommandGenericHID& CommandNiDsStadiaController::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
wpi::NiDsStadiaController&
|
||||
CommandNiDsStadiaController::GetNiDsStadiaController() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::A(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kA, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kA, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::B(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kB, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kB, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::X(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kX, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kX, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::Y(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kY, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kY, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::LeftBumper(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kLeftBumper, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kLeftBumper, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::RightBumper(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kRightBumper, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kRightBumper, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::LeftStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kLeftStick, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kLeftStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::RightStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kRightStick, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kRightStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::Ellipses(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kEllipses, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kEllipses, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::Hamburger(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kHamburger, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kHamburger, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::Stadia(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kStadia, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kStadia, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::RightTrigger(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kRightTrigger, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kRightTrigger, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::LeftTrigger(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kLeftTrigger, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kLeftTrigger, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::Google(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kGoogle, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kGoogle, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsStadiaController::Frame(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsStadiaController::Button::kFrame, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsStadiaController::Button::kFrame, loop);
|
||||
}
|
||||
|
||||
double CommandNiDsStadiaController::GetLeftX() const {
|
||||
return m_hid.GetLeftX();
|
||||
return m_controller.GetLeftX();
|
||||
}
|
||||
|
||||
double CommandNiDsStadiaController::GetRightX() const {
|
||||
return m_hid.GetRightX();
|
||||
return m_controller.GetRightX();
|
||||
}
|
||||
|
||||
double CommandNiDsStadiaController::GetLeftY() const {
|
||||
return m_hid.GetLeftY();
|
||||
return m_controller.GetLeftY();
|
||||
}
|
||||
|
||||
double CommandNiDsStadiaController::GetRightY() const {
|
||||
return m_hid.GetRightY();
|
||||
return m_controller.GetRightY();
|
||||
}
|
||||
|
||||
@@ -9,86 +9,100 @@
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandNiDsXboxController::CommandNiDsXboxController(int port)
|
||||
: CommandGenericHID(port), m_hid{wpi::NiDsXboxController(port)} {}
|
||||
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)},
|
||||
m_controller{m_hid->GetHID()} {}
|
||||
|
||||
wpi::NiDsXboxController& CommandNiDsXboxController::GetHID() {
|
||||
return m_hid;
|
||||
CommandGenericHID& CommandNiDsXboxController::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
wpi::NiDsXboxController&
|
||||
CommandNiDsXboxController::GetNiDsXboxController() {
|
||||
return m_controller;
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::A(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kA, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kA, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::B(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kB, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kB, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::X(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kX, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kX, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::Y(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kY, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kY, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::LeftBumper(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kLeftBumper, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kLeftBumper, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::RightBumper(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kRightBumper, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kRightBumper, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::Back(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kBack, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kBack, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::Start(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kStart, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kStart, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::LeftStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kLeftStick, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kLeftStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::RightStick(wpi::EventLoop* loop) const {
|
||||
return Button(wpi::NiDsXboxController::Button::kRightStick, loop);
|
||||
return m_hid->Button(
|
||||
wpi::NiDsXboxController::Button::kRightStick, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::LeftTrigger(double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.GetLeftTriggerAxis() > threshold;
|
||||
});
|
||||
return m_hid->AxisGreaterThan(
|
||||
wpi::NiDsXboxController::Axis::kLeftTrigger, threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandNiDsXboxController::RightTrigger(double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return Trigger(loop, [this, threshold] {
|
||||
return m_hid.GetRightTriggerAxis() > threshold;
|
||||
});
|
||||
return m_hid->AxisGreaterThan(
|
||||
wpi::NiDsXboxController::Axis::kRightTrigger, threshold, loop);
|
||||
}
|
||||
|
||||
double CommandNiDsXboxController::GetLeftX() const {
|
||||
return m_hid.GetLeftX();
|
||||
return m_controller.GetLeftX();
|
||||
}
|
||||
|
||||
double CommandNiDsXboxController::GetRightX() const {
|
||||
return m_hid.GetRightX();
|
||||
return m_controller.GetRightX();
|
||||
}
|
||||
|
||||
double CommandNiDsXboxController::GetLeftY() const {
|
||||
return m_hid.GetLeftY();
|
||||
return m_controller.GetLeftY();
|
||||
}
|
||||
|
||||
double CommandNiDsXboxController::GetRightY() const {
|
||||
return m_hid.GetRightY();
|
||||
return m_controller.GetRightY();
|
||||
}
|
||||
|
||||
double CommandNiDsXboxController::GetLeftTriggerAxis() const {
|
||||
return m_hid.GetLeftTriggerAxis();
|
||||
return m_controller.GetLeftTriggerAxis();
|
||||
}
|
||||
|
||||
double CommandNiDsXboxController::GetRightTriggerAxis() const {
|
||||
return m_hid.GetRightTriggerAxis();
|
||||
return m_controller.GetRightTriggerAxis();
|
||||
}
|
||||
|
||||
190
commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandXboxController.cpp
generated
Normal file
190
commandsv2/src/generated/main/native/cpp/wpi/commands2/button/CommandXboxController.cpp
generated
Normal file
@@ -0,0 +1,190 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
#include "wpi/commands2/button/CommandXboxController.hpp"
|
||||
|
||||
using namespace wpi::cmd;
|
||||
|
||||
CommandXboxController::CommandXboxController(int port)
|
||||
: m_hid{&CommandGenericHID::GetCommandGenericHID(port)} {
|
||||
m_ownedController =
|
||||
std::make_unique<wpi::XboxController>(m_hid->GetHID());
|
||||
m_controller = m_ownedController.get();
|
||||
}
|
||||
|
||||
CommandXboxController::CommandXboxController(
|
||||
wpi::XboxController* controller)
|
||||
: m_ownedHid{std::make_unique<CommandGenericHID>(controller->GetHID())},
|
||||
m_hid{m_ownedHid.get()},
|
||||
m_controller{controller} {}
|
||||
|
||||
CommandGenericHID& CommandXboxController::GetHID() {
|
||||
return *m_hid;
|
||||
}
|
||||
|
||||
wpi::XboxController&
|
||||
CommandXboxController::GetController() {
|
||||
return *m_controller;
|
||||
}
|
||||
|
||||
const wpi::XboxController&
|
||||
CommandXboxController::GetController() const {
|
||||
return *m_controller;
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::Button(
|
||||
enum wpi::XboxController::Button button,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->Button(static_cast<int>(button), loop);
|
||||
}
|
||||
|
||||
|
||||
Trigger CommandXboxController::A(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::A,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::B(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::B,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::X(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::X,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::Y(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::Y,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::View(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::VIEW,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::Xbox(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::XBOX,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::Menu(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::MENU,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::LeftStick(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::LEFT_STICK,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::RightStick(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::RIGHT_STICK,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::LeftBumper(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::LEFT_BUMPER,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::RightBumper(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::RIGHT_BUMPER,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::DpadUp(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::DPAD_UP,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::DpadDown(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::DPAD_DOWN,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::DpadLeft(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::DPAD_LEFT,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::DpadRight(
|
||||
wpi::EventLoop* loop) const {
|
||||
return Button(wpi::XboxController::Button::DPAD_RIGHT,
|
||||
loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::LeftTrigger(
|
||||
double threshold, wpi::EventLoop* loop) const {
|
||||
return AxisGreaterThan(
|
||||
wpi::XboxController::Axis::LEFT_TRIGGER,
|
||||
threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::RightTrigger(
|
||||
double threshold, wpi::EventLoop* loop) const {
|
||||
return AxisGreaterThan(
|
||||
wpi::XboxController::Axis::RIGHT_TRIGGER,
|
||||
threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::AxisLessThan(
|
||||
wpi::XboxController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisLessThan(static_cast<int>(axis), threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::AxisGreaterThan(
|
||||
wpi::XboxController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisGreaterThan(static_cast<int>(axis), threshold, loop);
|
||||
}
|
||||
|
||||
Trigger CommandXboxController::AxisMagnitudeGreaterThan(
|
||||
wpi::XboxController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop) const {
|
||||
return m_hid->AxisMagnitudeGreaterThan(static_cast<int>(axis), threshold,
|
||||
loop);
|
||||
}
|
||||
|
||||
|
||||
double CommandXboxController::GetLeftX() const {
|
||||
return m_controller->GetLeftX();
|
||||
}
|
||||
|
||||
double CommandXboxController::GetLeftY() const {
|
||||
return m_controller->GetLeftY();
|
||||
}
|
||||
|
||||
double CommandXboxController::GetRightX() const {
|
||||
return m_controller->GetRightX();
|
||||
}
|
||||
|
||||
double CommandXboxController::GetRightY() const {
|
||||
return m_controller->GetRightY();
|
||||
}
|
||||
|
||||
double CommandXboxController::GetLeftTrigger() const {
|
||||
return m_controller->GetLeftTrigger();
|
||||
}
|
||||
|
||||
double CommandXboxController::GetRightTrigger() const {
|
||||
return m_controller->GetRightTrigger();
|
||||
}
|
||||
432
commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandDualSenseController.hpp
generated
Normal file
432
commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandDualSenseController.hpp
generated
Normal file
@@ -0,0 +1,432 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "wpi/driverstation/DualSenseController.hpp"
|
||||
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link wpi::DualSenseController} with {@link Trigger}
|
||||
* factories for command-based.
|
||||
*
|
||||
* @see wpi::DualSenseController
|
||||
*/
|
||||
class CommandDualSenseController {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is
|
||||
* plugged into.
|
||||
*/
|
||||
explicit CommandDualSenseController(int port);
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller with a DualSenseController object.
|
||||
*
|
||||
* @param controller The DualSenseController object to use for this controller.
|
||||
*/
|
||||
explicit CommandDualSenseController(wpi::DualSenseController* controller);
|
||||
|
||||
/**
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
CommandGenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
wpi::DualSenseController& GetController();
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
const wpi::DualSenseController& GetController() const;
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return an event instance representing the button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
Trigger Button(enum wpi::DualSenseController::Button button,
|
||||
wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Cross button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Cross button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Cross(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Circle button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Circle button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Circle(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Square button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Square button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Square(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Triangle button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Triangle button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Triangle(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Create button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Create button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Create(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the PS button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the PS button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger PS(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Options button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Options button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Options(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the L 3 button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the L 3 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger L3(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the R 3 button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the R 3 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger R3(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the L 1 button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the L 1 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger L1(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the R 1 button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the R 1 button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger R1(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Up button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Dpad Up button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadUp(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Down button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Dpad Down button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadDown(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Left button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Dpad Left button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadLeft(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Right button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Dpad Right button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadRight(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Microphone button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Microphone button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Microphone(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Touchpad button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Touchpad button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Touchpad(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the
|
||||
* L 2. The returned Trigger will be true when the axis value
|
||||
* is greater than threshold.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned Trigger to be
|
||||
* true. This value should be in the range [0, 1] where 0 is the unpressed
|
||||
* state of the axis. Defaults to 0.5.
|
||||
* @param loop the event loop instance to attach the Trigger to. Defaults to
|
||||
* the CommandScheduler's default loop.
|
||||
* @return a Trigger instance that is true when the L 2 axis
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger L2(
|
||||
double threshold = 0.5,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the
|
||||
* R 2. The returned Trigger will be true when the axis value
|
||||
* is greater than threshold.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned Trigger to be
|
||||
* true. This value should be in the range [0, 1] where 0 is the unpressed
|
||||
* state of the axis. Defaults to 0.5.
|
||||
* @param loop the event loop instance to attach the Trigger to. Defaults to
|
||||
* the CommandScheduler's default loop.
|
||||
* @return a Trigger instance that is true when the R 2 axis
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger R2(
|
||||
double threshold = 0.5,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than
|
||||
* {@code threshold}, attached to {@link
|
||||
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
|
||||
* button loop}.
|
||||
* @param axis The axis to read, starting at 0.
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the event to. Defaults to
|
||||
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
* @return a Trigger instance that is true when the axis value is less than
|
||||
* the provided threshold.
|
||||
*/
|
||||
Trigger AxisLessThan(
|
||||
wpi::DualSenseController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is greater
|
||||
* than {@code threshold}, attached to {@link
|
||||
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
|
||||
* button loop}.
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the event to. Defaults to
|
||||
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
* @return a Trigger instance that is true when the axis value is greater than
|
||||
* the provided threshold.
|
||||
*/
|
||||
Trigger AxisGreaterThan(
|
||||
wpi::DualSenseController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is
|
||||
* greater than {@code threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis magnitude value is
|
||||
* greater than the provided threshold.
|
||||
*/
|
||||
Trigger AxisMagnitudeGreaterThan(
|
||||
wpi::DualSenseController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get the Left X value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetLeftX() const;
|
||||
|
||||
/**
|
||||
* Get the Left Y value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetLeftY() const;
|
||||
|
||||
/**
|
||||
* Get the Right X value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetRightX() const;
|
||||
|
||||
/**
|
||||
* Get the Right Y value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetRightY() const;
|
||||
|
||||
/**
|
||||
* Get the L 2 value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetL2() const;
|
||||
|
||||
/**
|
||||
* Get the R 2 value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetR2() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<CommandGenericHID> m_ownedHid;
|
||||
CommandGenericHID* m_hid = nullptr;
|
||||
std::unique_ptr<wpi::DualSenseController> m_ownedController;
|
||||
wpi::DualSenseController* m_controller = nullptr;
|
||||
};
|
||||
} // namespace wpi::cmd
|
||||
@@ -6,11 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wpi/driverstation/NiDsPS4Controller.hpp"
|
||||
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
#include "wpi/driverstation/NiDsPS4Controller.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
@@ -19,7 +18,7 @@ namespace wpi::cmd {
|
||||
*
|
||||
* @see wpi::NiDsPS4Controller
|
||||
*/
|
||||
class CommandNiDsPS4Controller : public CommandGenericHID {
|
||||
class CommandNiDsPS4Controller {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -30,11 +29,18 @@ class CommandNiDsPS4Controller : public CommandGenericHID {
|
||||
explicit CommandNiDsPS4Controller(int port);
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
wpi::NiDsPS4Controller& GetHID();
|
||||
CommandGenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Get the underlying NiDsPS4Controller object.
|
||||
*
|
||||
* @return the wrapped NiDsPS4Controller object
|
||||
*/
|
||||
wpi::NiDsPS4Controller& GetNiDsPS4Controller();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the square button's
|
||||
@@ -249,6 +255,7 @@ class CommandNiDsPS4Controller : public CommandGenericHID {
|
||||
double GetR2Axis() const;
|
||||
|
||||
private:
|
||||
wpi::NiDsPS4Controller m_hid;
|
||||
CommandGenericHID* m_hid;
|
||||
wpi::NiDsPS4Controller m_controller;
|
||||
};
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wpi/driverstation/NiDsPS5Controller.hpp"
|
||||
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
#include "wpi/driverstation/NiDsPS5Controller.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
@@ -19,7 +18,7 @@ namespace wpi::cmd {
|
||||
*
|
||||
* @see wpi::NiDsPS5Controller
|
||||
*/
|
||||
class CommandNiDsPS5Controller : public CommandGenericHID {
|
||||
class CommandNiDsPS5Controller {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -30,11 +29,18 @@ class CommandNiDsPS5Controller : public CommandGenericHID {
|
||||
explicit CommandNiDsPS5Controller(int port);
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
wpi::NiDsPS5Controller& GetHID();
|
||||
CommandGenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Get the underlying NiDsPS5Controller object.
|
||||
*
|
||||
* @return the wrapped NiDsPS5Controller object
|
||||
*/
|
||||
wpi::NiDsPS5Controller& GetNiDsPS5Controller();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the square button's
|
||||
@@ -249,6 +255,7 @@ class CommandNiDsPS5Controller : public CommandGenericHID {
|
||||
double GetR2Axis() const;
|
||||
|
||||
private:
|
||||
wpi::NiDsPS5Controller m_hid;
|
||||
CommandGenericHID* m_hid;
|
||||
wpi::NiDsPS5Controller m_controller;
|
||||
};
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wpi/driverstation/NiDsStadiaController.hpp"
|
||||
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
#include "wpi/driverstation/NiDsStadiaController.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
@@ -19,7 +18,7 @@ namespace wpi::cmd {
|
||||
*
|
||||
* @see wpi::NiDsStadiaController
|
||||
*/
|
||||
class CommandNiDsStadiaController : public CommandGenericHID {
|
||||
class CommandNiDsStadiaController {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -30,11 +29,18 @@ class CommandNiDsStadiaController : public CommandGenericHID {
|
||||
explicit CommandNiDsStadiaController(int port);
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
wpi::NiDsStadiaController& GetHID();
|
||||
CommandGenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Get the underlying NiDsStadiaController object.
|
||||
*
|
||||
* @return the wrapped NiDsStadiaController object
|
||||
*/
|
||||
wpi::NiDsStadiaController& GetNiDsStadiaController();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's
|
||||
@@ -245,6 +251,7 @@ class CommandNiDsStadiaController : public CommandGenericHID {
|
||||
double GetRightY() const;
|
||||
|
||||
private:
|
||||
wpi::NiDsStadiaController m_hid;
|
||||
CommandGenericHID* m_hid;
|
||||
wpi::NiDsStadiaController m_controller;
|
||||
};
|
||||
} // namespace wpi::cmd
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wpi/driverstation/NiDsXboxController.hpp"
|
||||
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
#include "wpi/driverstation/NiDsXboxController.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
@@ -19,7 +18,7 @@ namespace wpi::cmd {
|
||||
*
|
||||
* @see wpi::NiDsXboxController
|
||||
*/
|
||||
class CommandNiDsXboxController : public CommandGenericHID {
|
||||
class CommandNiDsXboxController {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -30,11 +29,18 @@ class CommandNiDsXboxController : public CommandGenericHID {
|
||||
explicit CommandNiDsXboxController(int port);
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
wpi::NiDsXboxController& GetHID();
|
||||
CommandGenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Get the underlying NiDsXboxController object.
|
||||
*
|
||||
* @return the wrapped NiDsXboxController object
|
||||
*/
|
||||
wpi::NiDsXboxController& GetNiDsXboxController();
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's
|
||||
@@ -235,6 +241,7 @@ class CommandNiDsXboxController : public CommandGenericHID {
|
||||
double GetRightTriggerAxis() const;
|
||||
|
||||
private:
|
||||
wpi::NiDsXboxController m_hid;
|
||||
CommandGenericHID* m_hid;
|
||||
wpi::NiDsXboxController m_controller;
|
||||
};
|
||||
} // namespace wpi::cmd
|
||||
|
||||
406
commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandXboxController.hpp
generated
Normal file
406
commandsv2/src/generated/main/native/include/wpi/commands2/button/CommandXboxController.hpp
generated
Normal file
@@ -0,0 +1,406 @@
|
||||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
// THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "wpi/driverstation/XboxController.hpp"
|
||||
|
||||
#include "wpi/commands2/CommandScheduler.hpp"
|
||||
#include "wpi/commands2/button/CommandGenericHID.hpp"
|
||||
#include "wpi/commands2/button/Trigger.hpp"
|
||||
|
||||
namespace wpi::cmd {
|
||||
/**
|
||||
* A version of {@link wpi::XboxController} with {@link Trigger}
|
||||
* factories for command-based.
|
||||
*
|
||||
* @see wpi::XboxController
|
||||
*/
|
||||
class CommandXboxController {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the controller is
|
||||
* plugged into.
|
||||
*/
|
||||
explicit CommandXboxController(int port);
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller with a XboxController object.
|
||||
*
|
||||
* @param controller The XboxController object to use for this controller.
|
||||
*/
|
||||
explicit CommandXboxController(wpi::XboxController* controller);
|
||||
|
||||
/**
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
CommandGenericHID& GetHID();
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
wpi::XboxController& GetController();
|
||||
|
||||
/**
|
||||
* Get the wrapped controller object.
|
||||
*
|
||||
* @return the wrapped controller object
|
||||
*/
|
||||
const wpi::XboxController& GetController() const;
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return an event instance representing the button's digital signal attached
|
||||
* to the given loop.
|
||||
*/
|
||||
Trigger Button(enum wpi::XboxController::Button button,
|
||||
wpi::EventLoop* loop = CommandScheduler::GetInstance()
|
||||
.GetDefaultButtonLoop()) const;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the A button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the A button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger A(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the B button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the B button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger B(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the X button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the X button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger X(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Y button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Y button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Y(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the View button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the View button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger View(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Xbox button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Xbox button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Xbox(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Menu button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Menu button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger Menu(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Left Stick button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Left Stick button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftStick(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Right Stick button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Right Stick button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightStick(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Left Bumper button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Left Bumper button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger LeftBumper(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Right Bumper button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Right Bumper button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger RightBumper(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Up button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Dpad Up button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadUp(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Down button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Dpad Down button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadDown(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Left button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Dpad Left button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadLeft(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the Dpad Right button's
|
||||
* digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to. Defaults to the
|
||||
* CommandScheduler's default loop.
|
||||
* @return a Trigger instance representing the Dpad Right button's
|
||||
* digital signal attached to the given loop.
|
||||
*/
|
||||
Trigger DpadRight(
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the
|
||||
* Left Trigger. The returned Trigger will be true when the axis value
|
||||
* is greater than threshold.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned Trigger to be
|
||||
* true. This value should be in the range [0, 1] where 0 is the unpressed
|
||||
* state of the axis. Defaults to 0.5.
|
||||
* @param loop the event loop instance to attach the Trigger to. Defaults to
|
||||
* the CommandScheduler's default loop.
|
||||
* @return a Trigger instance that is true when the Left Trigger axis
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger LeftTrigger(
|
||||
double threshold = 0.5,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the axis value of the
|
||||
* Right Trigger. The returned Trigger will be true when the axis value
|
||||
* is greater than threshold.
|
||||
*
|
||||
* @param threshold the minimum axis value for the returned Trigger to be
|
||||
* true. This value should be in the range [0, 1] where 0 is the unpressed
|
||||
* state of the axis. Defaults to 0.5.
|
||||
* @param loop the event loop instance to attach the Trigger to. Defaults to
|
||||
* the CommandScheduler's default loop.
|
||||
* @return a Trigger instance that is true when the Right Trigger axis
|
||||
* exceeds the provided threshold, attached to the given loop
|
||||
*/
|
||||
Trigger RightTrigger(
|
||||
double threshold = 0.5,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is less than
|
||||
* {@code threshold}, attached to {@link
|
||||
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
|
||||
* button loop}.
|
||||
* @param axis The axis to read, starting at 0.
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the event to. Defaults to
|
||||
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
* @return a Trigger instance that is true when the axis value is less than
|
||||
* the provided threshold.
|
||||
*/
|
||||
Trigger AxisLessThan(
|
||||
wpi::XboxController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis value is greater
|
||||
* than {@code threshold}, attached to {@link
|
||||
* CommandScheduler::GetDefaultButtonLoop() the default command scheduler
|
||||
* button loop}.
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value below which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the event to. Defaults to
|
||||
* {@link CommandScheduler::GetDefaultButtonLoop() the default command
|
||||
* scheduler button loop}.
|
||||
* @return a Trigger instance that is true when the axis value is greater than
|
||||
* the provided threshold.
|
||||
*/
|
||||
Trigger AxisGreaterThan(
|
||||
wpi::XboxController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance that is true when the axis magnitude value is
|
||||
* greater than {@code threshold}, attached to the given loop.
|
||||
*
|
||||
* @param axis The axis to read
|
||||
* @param threshold The value above which this trigger should return true.
|
||||
* @param loop the event loop instance to attach the trigger to.
|
||||
* @return a Trigger instance that is true when the axis magnitude value is
|
||||
* greater than the provided threshold.
|
||||
*/
|
||||
Trigger AxisMagnitudeGreaterThan(
|
||||
wpi::XboxController::Axis axis, double threshold,
|
||||
wpi::EventLoop* loop =
|
||||
CommandScheduler::GetInstance().GetDefaultButtonLoop()) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get the Left X value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetLeftX() const;
|
||||
|
||||
/**
|
||||
* Get the Left Y value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetLeftY() const;
|
||||
|
||||
/**
|
||||
* Get the Right X value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetRightX() const;
|
||||
|
||||
/**
|
||||
* Get the Right Y value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetRightY() const;
|
||||
|
||||
/**
|
||||
* Get the Left Trigger value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetLeftTrigger() const;
|
||||
|
||||
/**
|
||||
* Get the Right Trigger value of the controller.
|
||||
*
|
||||
* @return the axis value.
|
||||
*/
|
||||
double GetRightTrigger() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<CommandGenericHID> m_ownedHid;
|
||||
CommandGenericHID* m_hid = nullptr;
|
||||
std::unique_ptr<wpi::XboxController> m_ownedController;
|
||||
wpi::XboxController* m_controller = nullptr;
|
||||
};
|
||||
} // namespace wpi::cmd
|
||||
@@ -4,7 +4,9 @@
|
||||
|
||||
package org.wpilib.command2.button;
|
||||
|
||||
import java.util.Objects;
|
||||
import org.wpilib.command2.CommandScheduler;
|
||||
import org.wpilib.driverstation.DriverStation;
|
||||
import org.wpilib.driverstation.Gamepad;
|
||||
import org.wpilib.event.EventLoop;
|
||||
|
||||
@@ -14,8 +16,9 @@ import org.wpilib.event.EventLoop;
|
||||
* @see Gamepad
|
||||
*/
|
||||
@SuppressWarnings("MethodName")
|
||||
public class CommandGamepad extends CommandGenericHID {
|
||||
private final Gamepad m_hid;
|
||||
public class CommandGamepad {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final Gamepad m_gamepad;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -23,20 +26,61 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public CommandGamepad(int port) {
|
||||
super(port);
|
||||
m_hid = new Gamepad(port);
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_gamepad = DriverStation.getGamepad(port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Construct an instance of a controller with a Gamepad object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @param gamepad The Gamepad object to use for this controller.
|
||||
*/
|
||||
@Override
|
||||
public Gamepad getHID() {
|
||||
public CommandGamepad(Gamepad gamepad) {
|
||||
m_gamepad = Objects.requireNonNull(gamepad, "Provided gamepad cannot be null");
|
||||
m_hid = new CommandGenericHID(m_gamepad.getHID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying Gamepad object.
|
||||
*
|
||||
* @return the wrapped Gamepad object
|
||||
*/
|
||||
public Gamepad getGamepad() {
|
||||
return m_gamepad;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button index
|
||||
* @return an event instance representing the button's digital signal attached to the {@link
|
||||
* CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #button(int, EventLoop)
|
||||
*/
|
||||
public Trigger button(int button) {
|
||||
return m_hid.button(button);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
* @param button the button index
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return an event instance representing the button's digital signal attached to the given loop.
|
||||
*/
|
||||
public Trigger button(int button, EventLoop loop) {
|
||||
return m_hid.button(button, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around this button's digital signal.
|
||||
*
|
||||
@@ -46,7 +90,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* @see #button(Gamepad.Button, EventLoop)
|
||||
*/
|
||||
public Trigger button(Gamepad.Button button) {
|
||||
return super.button(button.value);
|
||||
return button(button.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,91 +105,91 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the South Face button's digital signal.
|
||||
* Constructs a Trigger instance around the Face Down button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the South Face button's digital signal attached to the
|
||||
* @return a Trigger instance representing the Face Down button's digital signal attached to the
|
||||
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #southFace(EventLoop)
|
||||
* @see #faceDown(EventLoop)
|
||||
*/
|
||||
public Trigger southFace() {
|
||||
return southFace(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
public Trigger faceDown() {
|
||||
return faceDown(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the South Face button's digital signal.
|
||||
* Constructs a Trigger instance around the Face Down button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the South Face button's digital signal attached to the
|
||||
* @return a Trigger instance representing the Face Down button's digital signal attached to the
|
||||
* given loop.
|
||||
*/
|
||||
public Trigger southFace(EventLoop loop) {
|
||||
return button(Gamepad.Button.SOUTH_FACE, loop);
|
||||
public Trigger faceDown(EventLoop loop) {
|
||||
return button(Gamepad.Button.FACE_DOWN, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the East Face button's digital signal.
|
||||
* Constructs a Trigger instance around the Face Right button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the East Face button's digital signal attached to the
|
||||
* @return a Trigger instance representing the Face Right button's digital signal attached to the
|
||||
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #eastFace(EventLoop)
|
||||
* @see #faceRight(EventLoop)
|
||||
*/
|
||||
public Trigger eastFace() {
|
||||
return eastFace(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
public Trigger faceRight() {
|
||||
return faceRight(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the East Face button's digital signal.
|
||||
* Constructs a Trigger instance around the Face Right button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the East Face button's digital signal attached to the
|
||||
* @return a Trigger instance representing the Face Right button's digital signal attached to the
|
||||
* given loop.
|
||||
*/
|
||||
public Trigger eastFace(EventLoop loop) {
|
||||
return button(Gamepad.Button.EAST_FACE, loop);
|
||||
public Trigger faceRight(EventLoop loop) {
|
||||
return button(Gamepad.Button.FACE_RIGHT, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the West Face button's digital signal.
|
||||
* Constructs a Trigger instance around the Face Left button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the West Face button's digital signal attached to the
|
||||
* @return a Trigger instance representing the Face Left button's digital signal attached to the
|
||||
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #westFace(EventLoop)
|
||||
* @see #faceLeft(EventLoop)
|
||||
*/
|
||||
public Trigger westFace() {
|
||||
return westFace(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
public Trigger faceLeft() {
|
||||
return faceLeft(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the West Face button's digital signal.
|
||||
* Constructs a Trigger instance around the Face Left button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the West Face button's digital signal attached to the
|
||||
* @return a Trigger instance representing the Face Left button's digital signal attached to the
|
||||
* given loop.
|
||||
*/
|
||||
public Trigger westFace(EventLoop loop) {
|
||||
return button(Gamepad.Button.WEST_FACE, loop);
|
||||
public Trigger faceLeft(EventLoop loop) {
|
||||
return button(Gamepad.Button.FACE_LEFT, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the North Face button's digital signal.
|
||||
* Constructs a Trigger instance around the Face Up button's digital signal.
|
||||
*
|
||||
* @return a Trigger instance representing the North Face button's digital signal attached to the
|
||||
* @return a Trigger instance representing the Face Up button's digital signal attached to the
|
||||
* {@link CommandScheduler#getDefaultButtonLoop() default scheduler button loop}.
|
||||
* @see #northFace(EventLoop)
|
||||
* @see #faceUp(EventLoop)
|
||||
*/
|
||||
public Trigger northFace() {
|
||||
return northFace(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
public Trigger faceUp() {
|
||||
return faceUp(CommandScheduler.getInstance().getDefaultButtonLoop());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Trigger instance around the North Face button's digital signal.
|
||||
* Constructs a Trigger instance around the Face Up button's digital signal.
|
||||
*
|
||||
* @param loop the event loop instance to attach the event to.
|
||||
* @return a Trigger instance representing the North Face button's digital signal attached to the
|
||||
* @return a Trigger instance representing the Face Up button's digital signal attached to the
|
||||
* given loop.
|
||||
*/
|
||||
public Trigger northFace(EventLoop loop) {
|
||||
return button(Gamepad.Button.NORTH_FACE, loop);
|
||||
public Trigger faceUp(EventLoop loop) {
|
||||
return button(Gamepad.Button.FACE_UP, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -721,7 +765,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisLessThan(Gamepad.Axis axis, double threshold) {
|
||||
return super.axisLessThan(axis.value, threshold);
|
||||
return m_hid.axisLessThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -735,7 +779,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisLessThan(Gamepad.Axis axis, double threshold, EventLoop loop) {
|
||||
return super.axisLessThan(axis.value, threshold, loop);
|
||||
return m_hid.axisLessThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -749,7 +793,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisGreaterThan(Gamepad.Axis axis, double threshold) {
|
||||
return super.axisGreaterThan(axis.value, threshold);
|
||||
return m_hid.axisGreaterThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -763,7 +807,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* threshold.
|
||||
*/
|
||||
public Trigger axisGreaterThan(Gamepad.Axis axis, double threshold, EventLoop loop) {
|
||||
return super.axisGreaterThan(axis.value, threshold, loop);
|
||||
return m_hid.axisGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -777,7 +821,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* provided threshold.
|
||||
*/
|
||||
public Trigger axisMagnitudeGreaterThan(Gamepad.Axis axis, double threshold, EventLoop loop) {
|
||||
return super.axisMagnitudeGreaterThan(axis.value, threshold, loop);
|
||||
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -790,7 +834,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* @return a Trigger instance that is true when the deadbanded axis value is active (non-zero).
|
||||
*/
|
||||
public Trigger axisMagnitudeGreaterThan(Gamepad.Axis axis, double threshold) {
|
||||
return super.axisMagnitudeGreaterThan(axis.value, threshold);
|
||||
return m_hid.axisMagnitudeGreaterThan(axis.value, threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -800,7 +844,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
public double getAxis(Gamepad.Axis axis) {
|
||||
return getRawAxis(axis.value);
|
||||
return m_hid.getRawAxis(axis.value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -809,7 +853,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftX() {
|
||||
return m_hid.getLeftX();
|
||||
return m_gamepad.getLeftX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -818,7 +862,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftY() {
|
||||
return m_hid.getLeftY();
|
||||
return m_gamepad.getLeftY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -827,7 +871,7 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightX() {
|
||||
return m_hid.getRightX();
|
||||
return m_gamepad.getRightX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -836,26 +880,26 @@ public class CommandGamepad extends CommandGenericHID {
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightY() {
|
||||
return m_hid.getRightY();
|
||||
return m_gamepad.getRightY();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the left trigger axis value of the controller. Note that this axis is bound to the range of
|
||||
* [0, 1] as opposed to the usual [-1, 1].
|
||||
* Get the left trigger value of the controller. Note that this axis is bound to the range of [0,
|
||||
* 1] as opposed to the usual [-1, 1].
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getLeftTriggerAxis() {
|
||||
return m_hid.getLeftTriggerAxis();
|
||||
public double getLeftTrigger() {
|
||||
return m_gamepad.getLeftTrigger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the right trigger axis value of the controller. Note that this axis is bound to the range
|
||||
* of [0, 1] as opposed to the usual [-1, 1].
|
||||
* Get the right trigger value of the controller. Note that this axis is bound to the range of [0,
|
||||
* 1] as opposed to the usual [-1, 1].
|
||||
*
|
||||
* @return The axis value.
|
||||
*/
|
||||
public double getRightTriggerAxis() {
|
||||
return m_hid.getRightTriggerAxis();
|
||||
public double getRightTrigger() {
|
||||
return m_gamepad.getRightTrigger();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,13 @@ package org.wpilib.command2.button;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.wpilib.command2.CommandScheduler;
|
||||
import org.wpilib.driverstation.DriverStation;
|
||||
import org.wpilib.driverstation.GenericHID;
|
||||
import org.wpilib.driverstation.POVDirection;
|
||||
import org.wpilib.driverstation.internal.DriverStationBackend;
|
||||
import org.wpilib.event.EventLoop;
|
||||
import org.wpilib.math.util.Pair;
|
||||
|
||||
@@ -17,7 +21,11 @@ import org.wpilib.math.util.Pair;
|
||||
*
|
||||
* @see GenericHID
|
||||
*/
|
||||
public class CommandGenericHID {
|
||||
public final class CommandGenericHID {
|
||||
private static final Lock m_hidsLock = new ReentrantLock();
|
||||
private static final CommandGenericHID[] m_hids =
|
||||
new CommandGenericHID[DriverStationBackend.JOYSTICK_PORTS];
|
||||
|
||||
private final GenericHID m_hid;
|
||||
private final Map<EventLoop, Map<Integer, Trigger>> m_buttonCache = new HashMap<>();
|
||||
private final Map<EventLoop, Map<Pair<Integer, Double>, Trigger>> m_axisLessThanCache =
|
||||
@@ -34,7 +42,38 @@ public class CommandGenericHID {
|
||||
* @param port The port index on the Driver Station that the device is plugged into.
|
||||
*/
|
||||
public CommandGenericHID(int port) {
|
||||
m_hid = new GenericHID(port);
|
||||
m_hid = DriverStation.getGenericHID(port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance of a device with a GenericHID object.
|
||||
*
|
||||
* @param hid The GenericHID object to use for this command HID.
|
||||
*/
|
||||
public CommandGenericHID(GenericHID hid) {
|
||||
m_hid = hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the CommandGenericHID object for the given port. CommandGenericHID objects are cached, so
|
||||
* this will always return the same object for the same port.
|
||||
*
|
||||
* @param port The port index on the Driver Station that the device is plugged into.
|
||||
* @return The CommandGenericHID object for the given port.
|
||||
*/
|
||||
public static CommandGenericHID getCommandGenericHID(int port) {
|
||||
DriverStation.getGenericHID(port);
|
||||
m_hidsLock.lock();
|
||||
try {
|
||||
CommandGenericHID toRet = m_hids[port];
|
||||
if (toRet == null) {
|
||||
toRet = new CommandGenericHID(port);
|
||||
m_hids[port] = toRet;
|
||||
}
|
||||
return toRet;
|
||||
} finally {
|
||||
m_hidsLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package org.wpilib.command2.button;
|
||||
|
||||
import org.wpilib.command2.CommandScheduler;
|
||||
import org.wpilib.driverstation.DriverStation;
|
||||
import org.wpilib.driverstation.Joystick;
|
||||
import org.wpilib.event.EventLoop;
|
||||
|
||||
@@ -13,8 +14,9 @@ import org.wpilib.event.EventLoop;
|
||||
*
|
||||
* @see Joystick
|
||||
*/
|
||||
public class CommandJoystick extends CommandGenericHID {
|
||||
private final Joystick m_hid;
|
||||
public class CommandJoystick {
|
||||
private final CommandGenericHID m_hid;
|
||||
private final Joystick m_joystick;
|
||||
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -22,20 +24,28 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @param port The port index on the Driver Station that the controller is plugged into.
|
||||
*/
|
||||
public CommandJoystick(int port) {
|
||||
super(port);
|
||||
m_hid = new Joystick(port);
|
||||
m_hid = CommandGenericHID.getCommandGenericHID(port);
|
||||
m_joystick = new Joystick(DriverStation.getGenericHID(port));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying GenericHID object.
|
||||
* Get the underlying CommandGenericHID object.
|
||||
*
|
||||
* @return the wrapped GenericHID object
|
||||
* @return the wrapped CommandGenericHID object
|
||||
*/
|
||||
@Override
|
||||
public Joystick getHID() {
|
||||
public CommandGenericHID getHID() {
|
||||
return m_hid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying Joystick object.
|
||||
*
|
||||
* @return the wrapped Joystick object
|
||||
*/
|
||||
public Joystick getJoystick() {
|
||||
return m_joystick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an event instance around the trigger button's digital signal.
|
||||
*
|
||||
@@ -55,7 +65,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* given loop.
|
||||
*/
|
||||
public Trigger trigger(EventLoop loop) {
|
||||
return button(Joystick.ButtonType.kTrigger.value, loop);
|
||||
return m_hid.button(Joystick.ButtonType.kTrigger.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +87,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* loop.
|
||||
*/
|
||||
public Trigger top(EventLoop loop) {
|
||||
return button(Joystick.ButtonType.kTop.value, loop);
|
||||
return m_hid.button(Joystick.ButtonType.kTop.value, loop);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +96,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @param channel The channel to set the axis to.
|
||||
*/
|
||||
public void setXChannel(int channel) {
|
||||
m_hid.setXChannel(channel);
|
||||
m_joystick.setXChannel(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +105,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @param channel The channel to set the axis to.
|
||||
*/
|
||||
public void setYChannel(int channel) {
|
||||
m_hid.setYChannel(channel);
|
||||
m_joystick.setYChannel(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +114,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @param channel The channel to set the axis to.
|
||||
*/
|
||||
public void setZChannel(int channel) {
|
||||
m_hid.setZChannel(channel);
|
||||
m_joystick.setZChannel(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +123,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @param channel The channel to set the axis to.
|
||||
*/
|
||||
public void setThrottleChannel(int channel) {
|
||||
m_hid.setThrottleChannel(channel);
|
||||
m_joystick.setThrottleChannel(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +132,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @param channel The channel to set the axis to.
|
||||
*/
|
||||
public void setTwistChannel(int channel) {
|
||||
m_hid.setTwistChannel(channel);
|
||||
m_joystick.setTwistChannel(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +141,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The channel for the axis.
|
||||
*/
|
||||
public int getXChannel() {
|
||||
return m_hid.getXChannel();
|
||||
return m_joystick.getXChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +150,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The channel for the axis.
|
||||
*/
|
||||
public int getYChannel() {
|
||||
return m_hid.getYChannel();
|
||||
return m_joystick.getYChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +159,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The channel for the axis.
|
||||
*/
|
||||
public int getZChannel() {
|
||||
return m_hid.getZChannel();
|
||||
return m_joystick.getZChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +168,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The channel for the axis.
|
||||
*/
|
||||
public int getTwistChannel() {
|
||||
return m_hid.getTwistChannel();
|
||||
return m_joystick.getTwistChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +177,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The channel for the axis.
|
||||
*/
|
||||
public int getThrottleChannel() {
|
||||
return m_hid.getThrottleChannel();
|
||||
return m_joystick.getThrottleChannel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,7 +189,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return the x position
|
||||
*/
|
||||
public double getX() {
|
||||
return m_hid.getX();
|
||||
return m_joystick.getX();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +201,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return the y position
|
||||
*/
|
||||
public double getY() {
|
||||
return m_hid.getY();
|
||||
return m_joystick.getY();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +210,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return the z position
|
||||
*/
|
||||
public double getZ() {
|
||||
return m_hid.getZ();
|
||||
return m_joystick.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +220,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The Twist value of the joystick.
|
||||
*/
|
||||
public double getTwist() {
|
||||
return m_hid.getTwist();
|
||||
return m_joystick.getTwist();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +230,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The Throttle value of the joystick.
|
||||
*/
|
||||
public double getThrottle() {
|
||||
return m_hid.getThrottle();
|
||||
return m_joystick.getThrottle();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +240,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The magnitude of the direction vector
|
||||
*/
|
||||
public double getMagnitude() {
|
||||
return m_hid.getMagnitude();
|
||||
return m_joystick.getMagnitude();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,7 +258,7 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
//
|
||||
// It's rotated 90 degrees CCW (y is negated and the arguments are reversed)
|
||||
// so that 0 radians is forward.
|
||||
return m_hid.getDirectionRadians();
|
||||
return m_joystick.getDirectionRadians();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,6 +268,6 @@ public class CommandJoystick extends CommandGenericHID {
|
||||
* @return The direction of the vector in degrees
|
||||
*/
|
||||
public double getDirectionDegrees() {
|
||||
return m_hid.getDirectionDegrees();
|
||||
return m_joystick.getDirectionDegrees();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.wpilib.command2.button;
|
||||
import static org.wpilib.util.ErrorMessages.requireNonNullParam;
|
||||
|
||||
import org.wpilib.driverstation.GenericHID;
|
||||
import org.wpilib.driverstation.HIDDevice;
|
||||
|
||||
/**
|
||||
* A {@link Trigger} that gets its state from a {@link GenericHID}.
|
||||
@@ -24,4 +25,14 @@ public class JoystickButton extends Trigger {
|
||||
super(() -> joystick.getRawButton(buttonNumber));
|
||||
requireNonNullParam(joystick, "joystick", "JoystickButton");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a joystick button for triggering commands.
|
||||
*
|
||||
* @param joystick The HIDDevice object that has the button
|
||||
* @param buttonNumber The button number (see {@link GenericHID#getRawButton(int) }
|
||||
*/
|
||||
public JoystickButton(HIDDevice joystick, int buttonNumber) {
|
||||
this(requireNonNullParam(joystick, "joystick", "JoystickButton").getHID(), buttonNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.wpilib.command2.button;
|
||||
import static org.wpilib.util.ErrorMessages.requireNonNullParam;
|
||||
|
||||
import org.wpilib.driverstation.GenericHID;
|
||||
import org.wpilib.driverstation.HIDDevice;
|
||||
import org.wpilib.driverstation.POVDirection;
|
||||
|
||||
/**
|
||||
@@ -36,4 +37,25 @@ public class POVButton extends Trigger {
|
||||
public POVButton(GenericHID joystick, POVDirection angle) {
|
||||
this(joystick, angle, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a POV button for triggering commands.
|
||||
*
|
||||
* @param joystick The HIDDevice object that has the POV
|
||||
* @param angle The desired angle
|
||||
* @param povNumber The POV number (see {@link GenericHID#getPOV(int)})
|
||||
*/
|
||||
public POVButton(HIDDevice joystick, POVDirection angle, int povNumber) {
|
||||
this(requireNonNullParam(joystick, "joystick", "POVButton").getHID(), angle, povNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a POV button for triggering commands. By default, acts on POV 0
|
||||
*
|
||||
* @param joystick The HIDDevice object that has the POV
|
||||
* @param angle The desired angle
|
||||
*/
|
||||
public POVButton(HIDDevice joystick, POVDirection angle) {
|
||||
this(joystick, angle, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user