mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
Compare commits
172 Commits
v2024.1.1-
...
v2024.1.1-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9599c1f56f | ||
|
|
f87c64af8a | ||
|
|
8798700cec | ||
|
|
85c9ae6eff | ||
|
|
7c8b7a97ad | ||
|
|
d9b504bc84 | ||
|
|
906b810136 | ||
|
|
56e5b404d1 | ||
|
|
8723ee5c39 | ||
|
|
192a28af47 | ||
|
|
d40bdd70ba | ||
|
|
7bfadf32e5 | ||
|
|
a770110438 | ||
|
|
54a55b8b53 | ||
|
|
7d4e515a6b | ||
|
|
5200316c14 | ||
|
|
ddf79a25d4 | ||
|
|
a71adef316 | ||
|
|
39a0bf4b98 | ||
|
|
f5fc101fda | ||
|
|
38bf024c96 | ||
|
|
9d11544c18 | ||
|
|
28deba20f5 | ||
|
|
c2971c0bb3 | ||
|
|
41cfc961e4 | ||
|
|
14c3ade155 | ||
|
|
90757b9e90 | ||
|
|
2676b77873 | ||
|
|
d32c10487c | ||
|
|
9bc5fcf886 | ||
|
|
d431abba3b | ||
|
|
2bb1409b82 | ||
|
|
66172ab288 | ||
|
|
e8f8c0ceb0 | ||
|
|
890992a849 | ||
|
|
a583ca01e1 | ||
|
|
ca272de400 | ||
|
|
76ae090570 | ||
|
|
5172ab8fd0 | ||
|
|
96914143ba | ||
|
|
464e6121ef | ||
|
|
5dad46cd45 | ||
|
|
54ab65a63a | ||
|
|
7ed900ae3a | ||
|
|
74b85b76a9 | ||
|
|
30816111db | ||
|
|
5cc923de33 | ||
|
|
1144115da0 | ||
|
|
ac7d726ac3 | ||
|
|
e09be72ee0 | ||
|
|
0f9ebe92d9 | ||
|
|
9fa28eb07a | ||
|
|
ca684ac207 | ||
|
|
51eecef2bd | ||
|
|
4fcf0b25a1 | ||
|
|
9b8011aa67 | ||
|
|
e00a0e84c1 | ||
|
|
23dd591394 | ||
|
|
b0719942f0 | ||
|
|
7bc89c4322 | ||
|
|
841ea682d1 | ||
|
|
a74db52dae | ||
|
|
a7eb422662 | ||
|
|
544b231d4d | ||
|
|
31cd015970 | ||
|
|
9280054eab | ||
|
|
2aba97c610 | ||
|
|
c80b2d2017 | ||
|
|
3c0652c18a | ||
|
|
95716eb0cb | ||
|
|
423fd75fa8 | ||
|
|
dfdea9c992 | ||
|
|
ca81ced409 | ||
|
|
437cc91af5 | ||
|
|
25b7dca46b | ||
|
|
bb05e20247 | ||
|
|
35744a036e | ||
|
|
80d7ad58ea | ||
|
|
f8d983b154 | ||
|
|
4a44210ee3 | ||
|
|
bdc8620d55 | ||
|
|
0ca1e9b5f9 | ||
|
|
cc30824409 | ||
|
|
b1fad062f7 | ||
|
|
ead9ae5a69 | ||
|
|
cfbff32185 | ||
|
|
7d90d0bcc3 | ||
|
|
7755e45aac | ||
|
|
3985c031da | ||
|
|
7a87fe4b60 | ||
|
|
09f3ed6a5f | ||
|
|
79dd795bc0 | ||
|
|
e117274a67 | ||
|
|
a8b80ca256 | ||
|
|
b3a9c3e96b | ||
|
|
0f8129677b | ||
|
|
d105f9e3e9 | ||
|
|
c5f2f6a0fb | ||
|
|
c1a57e422a | ||
|
|
78ebc6e9ec | ||
|
|
9ada181866 | ||
|
|
95fa5ec72f | ||
|
|
b6f2d3cc14 | ||
|
|
cc2cbeb04c | ||
|
|
fa6b171e1c | ||
|
|
d504639bbe | ||
|
|
3a1194be40 | ||
|
|
70392cbbcb | ||
|
|
17c1bd5a83 | ||
|
|
e69a9efeba | ||
|
|
14dcd0d26f | ||
|
|
ec1d261984 | ||
|
|
63dbf5c614 | ||
|
|
b2e7be9250 | ||
|
|
201a42a3cd | ||
|
|
04a781b4d7 | ||
|
|
87a8a1ced4 | ||
|
|
f1a82828fe | ||
|
|
2a04e12c6f | ||
|
|
33e0089afb | ||
|
|
d06fa633d5 | ||
|
|
049732afb8 | ||
|
|
87f7c19f90 | ||
|
|
6b53ef47cf | ||
|
|
8a3a268ae6 | ||
|
|
1c35d42cd0 | ||
|
|
ddc8db6c26 | ||
|
|
c6aff2c431 | ||
|
|
a9c5b18a39 | ||
|
|
9540b6922d | ||
|
|
83a7d33c47 | ||
|
|
a4a8ad9c75 | ||
|
|
9eecf2a456 | ||
|
|
9536a311cb | ||
|
|
8d5e6737fc | ||
|
|
07e13d60a2 | ||
|
|
1713386869 | ||
|
|
35472f5fc9 | ||
|
|
ed168b522c | ||
|
|
3e7ba2cc6f | ||
|
|
80c47da237 | ||
|
|
abe1cec90c | ||
|
|
cdf981abba | ||
|
|
04dcd80adb | ||
|
|
49920234ac | ||
|
|
366b715942 | ||
|
|
3ba501f947 | ||
|
|
ec569a58ef | ||
|
|
b91317fd36 | ||
|
|
2ab4fcbc24 | ||
|
|
98c14f1692 | ||
|
|
60bcdeded9 | ||
|
|
c87f8fd538 | ||
|
|
ad80eb3a0b | ||
|
|
c7d6ad5a0b | ||
|
|
8a8e220792 | ||
|
|
cfc6a47f76 | ||
|
|
8efa586ace | ||
|
|
23ea188e60 | ||
|
|
928e87b4f4 | ||
|
|
63ef585d4b | ||
|
|
b03a7668f9 | ||
|
|
3f08bcde54 | ||
|
|
196d963dc4 | ||
|
|
f4cbcbc984 | ||
|
|
ec0f7fefb0 | ||
|
|
3d618bdbfd | ||
|
|
1fa7445667 | ||
|
|
269b9647da | ||
|
|
bee32f080e | ||
|
|
25dad5a531 | ||
|
|
4a93581f1a |
6
.gersemirc
Normal file
6
.gersemirc
Normal file
@@ -0,0 +1,6 @@
|
||||
color: false
|
||||
definitions: []
|
||||
line_length: 100
|
||||
list_expansion: favour-inlining
|
||||
quiet: false
|
||||
unsafe: false
|
||||
5
.gitattributes
vendored
5
.gitattributes
vendored
@@ -3,3 +3,8 @@
|
||||
*.json text eol=lf
|
||||
*.md text eol=lf
|
||||
*.xml text eol=lf
|
||||
|
||||
# Generated files
|
||||
hal/src/generated/** linguist-generated
|
||||
ntcore/src/generated/** linguist-generated
|
||||
wpimath/src/generated/** linguist-generated
|
||||
|
||||
16
.github/workflows/cmake.yml
vendored
16
.github/workflows/cmake.yml
vendored
@@ -50,7 +50,7 @@ jobs:
|
||||
- name: Install jinja
|
||||
run: python -m pip install jinja2
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: configure
|
||||
run: cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ${{ matrix.flags }}
|
||||
@@ -76,19 +76,19 @@ jobs:
|
||||
- name: Install CMake
|
||||
uses: lukka/get-cmake@v3.27.6
|
||||
|
||||
- name: Run vcpkg
|
||||
uses: lukka/run-vcpkg@v11.1
|
||||
with:
|
||||
vcpkgDirectory: ${{ runner.workspace }}/vcpkg
|
||||
vcpkgGitCommitId: 78b61582c9e093fda56a01ebb654be15a0033897 # HEAD on 2023-08-6
|
||||
|
||||
- name: Run sccache-cache
|
||||
uses: mozilla-actions/sccache-action@v0.0.3
|
||||
|
||||
- name: Install jinja
|
||||
run: python -m pip install jinja2
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Run vcpkg
|
||||
uses: lukka/run-vcpkg@v11.1
|
||||
with:
|
||||
vcpkgDirectory: ${{ runner.workspace }}/vcpkg
|
||||
vcpkgGitCommitId: 78b61582c9e093fda56a01ebb654be15a0033897 # HEAD on 2023-08-6
|
||||
|
||||
- name: configure
|
||||
run: cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=ON -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release
|
||||
|
||||
10
.github/workflows/comment-command.yml
vendored
10
.github/workflows/comment-command.yml
vendored
@@ -9,22 +9,22 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: React Rocket
|
||||
uses: actions/github-script@v4
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const {owner, repo} = context.issue
|
||||
github.reactions.createForIssueComment({
|
||||
github.rest.reactions.createForIssueComment({
|
||||
owner,
|
||||
repo,
|
||||
comment_id: context.payload.comment.id,
|
||||
content: "rocket",
|
||||
});
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}
|
||||
- name: Fetch all history and metadata
|
||||
run: |
|
||||
git fetch --prune --unshallow
|
||||
git checkout -b pr
|
||||
git branch -f main origin/main
|
||||
- name: Checkout PR
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
GITHUB_TOKEN: "${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}"
|
||||
NUMBER: ${{ github.event.issue.number }}
|
||||
- name: Set up Python 3.8
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Setup Java
|
||||
|
||||
2
.github/workflows/documentation.yml
vendored
2
.github/workflows/documentation.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
if: github.repository_owner == 'wpilibsuite' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
concurrency: ci-docs-publish
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
42
.github/workflows/fix_compile_commands.py
vendored
Executable file
42
.github/workflows/fix_compile_commands.py
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Fix compile_commands.json generated by Gradle"
|
||||
)
|
||||
parser.add_argument("filename", help="compile_commands.json location")
|
||||
cmd_args = parser.parse_args()
|
||||
|
||||
# Read JSON
|
||||
with open(cmd_args.filename) as f:
|
||||
data = json.load(f)
|
||||
|
||||
for obj in data:
|
||||
out_args = []
|
||||
|
||||
# Filter out -isystem flags that cause false positives
|
||||
iter_args = iter(obj["arguments"])
|
||||
for arg in iter_args:
|
||||
if arg == "-isystem":
|
||||
next_arg = next(iter_args)
|
||||
|
||||
# /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include/xmmintrin.h:54:1:
|
||||
# error: conflicting types for '_mm_prefetch' [clang-diagnostic-error]
|
||||
if not next_arg.startswith("/usr/lib/gcc/"):
|
||||
out_args += ["-isystem", next_arg]
|
||||
else:
|
||||
out_args.append(arg)
|
||||
|
||||
obj["arguments"] = out_args
|
||||
|
||||
# Write JSON
|
||||
with open(cmd_args.filename, "w") as f:
|
||||
json.dump(data, f, indent=2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -10,5 +10,5 @@ jobs:
|
||||
name: "Validation"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
- uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
25
.github/workflows/gradle.yml
vendored
25
.github/workflows/gradle.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set release environment variable
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
|
||||
build-host:
|
||||
env:
|
||||
MACOSX_DEPLOYMENT_TARGET: 11
|
||||
MACOSX_DEPLOYMENT_TARGET: 12
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -109,7 +109,7 @@ jobs:
|
||||
name: "Build - ${{ matrix.artifact-name }}"
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-java@v3
|
||||
@@ -168,7 +168,7 @@ jobs:
|
||||
name: "Build - Documentation"
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-java@v3
|
||||
@@ -193,7 +193,20 @@ jobs:
|
||||
needs: [build-docker, build-host, build-documentation]
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Free Disk Space
|
||||
if: |
|
||||
github.repository_owner == 'wpilibsuite' &&
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
uses: jlumbroso/free-disk-space@main
|
||||
with:
|
||||
tool-cache: false
|
||||
android: true
|
||||
dotnet: true
|
||||
haskell: true
|
||||
large-packages: false
|
||||
docker-images: false
|
||||
swap-storage: false
|
||||
- uses: actions/checkout@v4
|
||||
if: |
|
||||
github.repository_owner == 'wpilibsuite' &&
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
@@ -223,7 +236,7 @@ jobs:
|
||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: 11
|
||||
java-version: 17
|
||||
- name: Combine (Main)
|
||||
if: |
|
||||
github.repository_owner == 'wpilibsuite' &&
|
||||
|
||||
31
.github/workflows/lint-format.yml
vendored
31
.github/workflows/lint-format.yml
vendored
@@ -15,11 +15,11 @@ jobs:
|
||||
name: "wpiformat"
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Fetch all history and metadata
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/allwpilib/allwpilib
|
||||
git fetch --prune --unshallow
|
||||
git checkout -b pr
|
||||
git branch -f main origin/main
|
||||
- name: Set up Python 3.8
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
with:
|
||||
python-version: 3.8
|
||||
- name: Install wpiformat
|
||||
run: pip3 install wpiformat
|
||||
run: pip3 install wpiformat==2023.36
|
||||
- name: Run
|
||||
run: wpiformat
|
||||
- name: Check output
|
||||
@@ -53,11 +53,12 @@ jobs:
|
||||
runs-on: ubuntu-22.04
|
||||
container: wpilib/roborio-cross-ubuntu:2023-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Fetch all history and metadata
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/allwpilib/allwpilib
|
||||
git fetch --prune --unshallow
|
||||
git checkout -b pr
|
||||
git branch -f main origin/main
|
||||
- name: Set up Python 3.8
|
||||
@@ -67,21 +68,27 @@ jobs:
|
||||
- name: Install wpiformat
|
||||
run: pip3 install wpiformat
|
||||
- name: Create compile_commands.json
|
||||
run: ./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
|
||||
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: wpiformat -list-changed-files
|
||||
- name: Run clang-tidy
|
||||
run: wpiformat -no-format -tidy-changed -compile-commands=build/compile_commands/linuxx86-64 -vv
|
||||
- name: Run clang-tidy release
|
||||
run: wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64release -vv
|
||||
- name: Run clang-tidy debug
|
||||
run: wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64debug -vv
|
||||
javaformat:
|
||||
name: "Java format"
|
||||
runs-on: ubuntu-22.04
|
||||
container: wpilib/ubuntu-base:22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Fetch all history and metadata
|
||||
run: |
|
||||
git config --global --add safe.directory /__w/allwpilib/allwpilib
|
||||
git fetch --prune --unshallow
|
||||
git checkout -b pr
|
||||
git branch -f main origin/main
|
||||
- name: Run Java format
|
||||
@@ -95,7 +102,7 @@ jobs:
|
||||
name: "Documentation"
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-java@v3
|
||||
|
||||
49
.github/workflows/pregenerate.yml
vendored
Normal file
49
.github/workflows/pregenerate.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Check Pregenerated Files
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches-ignore:
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
update:
|
||||
name: "Update"
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Fetch all history and metadata
|
||||
run: |
|
||||
git fetch --prune --unshallow
|
||||
git checkout -b pr
|
||||
git branch -f main origin/main
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.9
|
||||
- name: Install jinja
|
||||
run: python -m pip install jinja2
|
||||
- name: Install protobuf dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler && wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.2/protoc-gen-quickbuf-1.3.2-linux-x86_64.exe && chmod +x protoc-gen-quickbuf-1.3.2-linux-x86_64.exe
|
||||
- name: Run hal
|
||||
run: ./hal/generate_usage_reporting.py
|
||||
- name: Run ntcore
|
||||
run: ./ntcore/generate_topics.py
|
||||
- name: Run wpimath
|
||||
run: ./wpimath/generate_numbers.py && ./wpimath/generate_quickbuf.py protoc protoc-gen-quickbuf-1.3.2-linux-x86_64.exe
|
||||
- name: Add untracked files to index so they count as changes
|
||||
run: git add -A
|
||||
- name: Check output
|
||||
run: git --no-pager diff --exit-code HEAD
|
||||
- name: Generate diff
|
||||
run: git diff HEAD > pregenerated-files-fixes.patch
|
||||
if: ${{ failure() }}
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: pregenerated-files-fixes
|
||||
path: pregenerated-files-fixes.patch
|
||||
if: ${{ failure() }}
|
||||
4
.github/workflows/sanitizers.yml
vendored
4
.github/workflows/sanitizers.yml
vendored
@@ -41,10 +41,10 @@ jobs:
|
||||
- name: Install jinja
|
||||
run: python -m pip install jinja2
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- 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-14 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 ${{ 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-14 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 -DWITH_JAVA=OFF ${{ matrix.cmake-flags }} ..
|
||||
env:
|
||||
SCCACHE_GHA_ENABLED: "true"
|
||||
|
||||
|
||||
5
.github/workflows/upstream-utils.yml
vendored
5
.github/workflows/upstream-utils.yml
vendored
@@ -15,10 +15,11 @@ jobs:
|
||||
name: "Update"
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Fetch all history and metadata
|
||||
run: |
|
||||
git fetch --prune --unshallow
|
||||
git checkout -b pr
|
||||
git branch -f main origin/main
|
||||
- name: Set up Python 3.9
|
||||
|
||||
@@ -10,6 +10,7 @@ cppSrcFileInclude {
|
||||
}
|
||||
|
||||
modifiableFileExclude {
|
||||
cmake/toolchains/
|
||||
\.patch$
|
||||
gradlew
|
||||
}
|
||||
|
||||
310
CMakeLists.txt
310
CMakeLists.txt
@@ -1,12 +1,15 @@
|
||||
# Disable in-source builds to prevent source tree corruption.
|
||||
if(" ${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL " ${CMAKE_CURRENT_BINARY_DIR}")
|
||||
message(FATAL_ERROR "
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: In-source builds are not allowed.
|
||||
You should create a separate directory for build files.
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
|
||||
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
|
||||
set(CMAKE_SYSTEM_VERSION 10.0.18362.0 CACHE STRING INTERNAL FORCE)
|
||||
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION 10.0.18362.0 CACHE STRING INTERNAL FORCE)
|
||||
endif()
|
||||
@@ -16,7 +19,7 @@ project(allwpilib)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||
|
||||
# Make timestamps of extracted files from FetchContent the time of extraction
|
||||
if (POLICY CMP0135)
|
||||
if(POLICY CMP0135)
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
endif()
|
||||
|
||||
@@ -24,7 +27,7 @@ message(STATUS "Platform version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
|
||||
|
||||
set(WPILIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
INCLUDE(CPack)
|
||||
include(CPack)
|
||||
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
@@ -35,30 +38,32 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${WPILIB_BINARY_DIR}/bin)
|
||||
set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${WPILIB_BINARY_DIR}/jar)
|
||||
|
||||
# use, i.e. don't skip the full RPATH for the build tree
|
||||
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
|
||||
# when building, don't use the install RPATH already
|
||||
# (but later on when installing)
|
||||
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
|
||||
# add the automatically determined parts of the RPATH
|
||||
# which point to directories outside the build tree to the install RPATH
|
||||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
|
||||
# the RPATH to be used when installing, but only if it's not a system directory
|
||||
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
|
||||
IF("${isSystemDir}" STREQUAL "-1")
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
ENDIF("${isSystemDir}" STREQUAL "-1")
|
||||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
|
||||
if("${isSystemDir}" STREQUAL "-1")
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif("${isSystemDir}" STREQUAL "-1")
|
||||
|
||||
# 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" ON)
|
||||
option(WITH_JAVA "Include Java and JNI in the build" ON)
|
||||
option(WITH_JAVA_SOURCE "Build Java source jars" ${WITH_JAVA})
|
||||
option(WITH_CSCORE "Build cscore (needs OpenCV)" ON)
|
||||
option(WITH_NTCORE "Build ntcore" ON)
|
||||
option(WITH_WPIMATH "Build wpimath" ON)
|
||||
option(WITH_WPIUNITS "Build wpiunits" ON)
|
||||
option(WITH_WPILIB "Build hal, wpilibc/j, and myRobot (needs OpenCV)" ON)
|
||||
option(WITH_EXAMPLES "Build examples" OFF)
|
||||
option(WITH_TESTS "Build unit tests (requires internet connection)" ON)
|
||||
@@ -74,135 +79,152 @@ option(USE_SYSTEM_FMTLIB "Use system fmtlib" OFF)
|
||||
option(USE_SYSTEM_LIBUV "Use system libuv" OFF)
|
||||
option(USE_SYSTEM_EIGEN "Use system eigen" OFF)
|
||||
|
||||
# Options for installation.
|
||||
option(WITH_FLAT_INSTALL "Use a flat install directory" OFF)
|
||||
|
||||
# Options for location of OpenCV Java.
|
||||
set(OPENCV_JAVA_INSTALL_DIR "" CACHE PATH "Location to search for the OpenCV jar file")
|
||||
|
||||
# Set default build type to release with debug info (i.e. release mode optimizations
|
||||
# are performed, but debug info still exists).
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
|
||||
if (WITH_JAVA AND NOT BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "
|
||||
if(WITH_JAVA AND NOT BUILD_SHARED_LIBS)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build static libs with Java enabled.
|
||||
Static libs requires both BUILD_SHARED_LIBS=OFF and
|
||||
WITH_JAVA=OFF
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WITH_SIMULATION_MODULES AND NOT BUILD_SHARED_LIBS)
|
||||
message(FATAL_ERROR "
|
||||
if(WITH_SIMULATION_MODULES AND NOT BUILD_SHARED_LIBS)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build static libs with simulation modules enabled.
|
||||
Static libs requires both BUILD_SHARED_LIBS=OFF and
|
||||
WITH_SIMULATION_MODULES=OFF
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT WITH_JAVA OR NOT WITH_CSCORE)
|
||||
if(NOT WITH_JAVA OR NOT WITH_CSCORE)
|
||||
if(NOT "${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "")
|
||||
message(WARNING "
|
||||
message(
|
||||
WARNING
|
||||
"
|
||||
WARNING: OpenCV Java dir set but java is not enabled!
|
||||
It will be ignored.
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT WITH_WPILIB AND WITH_SIMULATION_MODULES)
|
||||
message(FATAL_ERROR "
|
||||
if(NOT WITH_WPILIB AND WITH_SIMULATION_MODULES)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build simulation modules with wpilib disabled.
|
||||
Enable wpilib by setting WITH_WPILIB=ON
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT WITH_NTCORE AND WITH_CSCORE)
|
||||
message(FATAL_ERROR "
|
||||
if(NOT WITH_NTCORE AND WITH_CSCORE)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build cameraserver without ntcore.
|
||||
Enable ntcore by setting WITH_NTCORE=ON
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT WITH_NTCORE AND WITH_GUI)
|
||||
message(FATAL_ERROR "
|
||||
if(NOT WITH_NTCORE AND WITH_GUI)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build GUI modules without ntcore.
|
||||
Enable ntcore by setting WITH_NTCORE=ON
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT WITH_NTCORE AND WITH_SIMULATION_MODULES)
|
||||
message(FATAL_ERROR "
|
||||
if(NOT WITH_NTCORE AND WITH_SIMULATION_MODULES)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build simulation modules without ntcore.
|
||||
Enable ntcore by setting WITH_NTCORE=ON
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT WITH_NTCORE AND WITH_WPILIB)
|
||||
message(FATAL_ERROR "
|
||||
if(NOT WITH_NTCORE AND WITH_WPILIB)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build wpilib without ntcore.
|
||||
Enable ntcore by setting WITH_NTCORE=ON
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT WITH_WPIMATH AND WITH_WPILIB)
|
||||
message(FATAL_ERROR "
|
||||
if(NOT WITH_WPIMATH AND WITH_WPILIB)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build wpilib without wpimath.
|
||||
Enable wpimath by setting WITH_WPIMATH=ON
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
set( wpilib_dest "")
|
||||
set( include_dest include )
|
||||
set( java_lib_dest java )
|
||||
set( jni_lib_dest jni )
|
||||
|
||||
if (WITH_FLAT_INSTALL)
|
||||
set (wpilib_config_dir ${wpilib_dest})
|
||||
else()
|
||||
set (wpilib_config_dir share/wpilib)
|
||||
if(NOT WITH_WPIUNITS AND WITH_WPIMATH AND WITH_JAVA)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"
|
||||
FATAL: Cannot build Java wpimath without wpiunits.
|
||||
Enable wpiunits by setting WITH_WPIUNITS=ON or disable the Java build by setting WITH_JAVA=OFF
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (USE_SYSTEM_LIBUV)
|
||||
set (LIBUV_SYSTEM_REPLACE "
|
||||
set(include_dest include)
|
||||
set(java_lib_dest java)
|
||||
set(jni_lib_dest jni)
|
||||
|
||||
if(USE_SYSTEM_LIBUV)
|
||||
set(LIBUV_SYSTEM_REPLACE
|
||||
"
|
||||
find_dependency(libuv CONFIG)
|
||||
")
|
||||
"
|
||||
)
|
||||
endif()
|
||||
|
||||
if (USE_SYSTEM_EIGEN)
|
||||
set (EIGEN_SYSTEM_REPLACE "find_package(Eigen3 CONFIG)")
|
||||
if(USE_SYSTEM_EIGEN)
|
||||
set(EIGEN_SYSTEM_REPLACE "find_package(Eigen3 CONFIG)")
|
||||
endif()
|
||||
|
||||
find_package(LIBSSH 0.7.1)
|
||||
|
||||
find_package(Protobuf REQUIRED)
|
||||
find_program(Quickbuf_EXECUTABLE
|
||||
NAMES protoc-gen-quickbuf
|
||||
DOC "The Quickbuf protoc plugin"
|
||||
)
|
||||
find_program(Quickbuf_EXECUTABLE NAMES protoc-gen-quickbuf DOC "The Quickbuf protoc plugin")
|
||||
|
||||
if (WITH_FLAT_INSTALL)
|
||||
set(WPIUTIL_DEP_REPLACE "include($\{SELF_DIR\}/wpiutil-config.cmake)")
|
||||
set(WPINET_DEP_REPLACE "include($\{SELF_DIR\}/wpinet-config.cmake)")
|
||||
set(NTCORE_DEP_REPLACE "include($\{SELF_DIR\}/ntcore-config.cmake)")
|
||||
set(CSCORE_DEP_REPLACE_IMPL "include(\${SELF_DIR}/cscore-config.cmake)")
|
||||
set(CAMERASERVER_DEP_REPLACE_IMPL "include(\${SELF_DIR}/cameraserver-config.cmake)")
|
||||
set(HAL_DEP_REPLACE_IMPL "include(\${SELF_DIR}/hal-config.cmake)")
|
||||
set(WPIMATH_DEP_REPLACE "include($\{SELF_DIR\}/wpimath-config.cmake)")
|
||||
set(WPILIBC_DEP_REPLACE_IMPL "include(\${SELF_DIR}/wpilibc-config.cmake)")
|
||||
set(WPILIBNEWCOMMANDS_DEP_REPLACE "include(\${SELF_DIR}/wpilibNewcommands-config.cmake)")
|
||||
else()
|
||||
set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)")
|
||||
set(WPINET_DEP_REPLACE "find_dependency(wpinet)")
|
||||
set(NTCORE_DEP_REPLACE "find_dependency(ntcore)")
|
||||
set(CSCORE_DEP_REPLACE_IMPL "find_dependency(cscore)")
|
||||
set(APRILTAG_DEP_REPLACE "find_dependency(apriltag)")
|
||||
set(CAMERASERVER_DEP_REPLACE_IMPL "find_dependency(cameraserver)")
|
||||
set(CSCORE_DEP_REPLACE_IMPL "find_dependency(cscore)")
|
||||
set(HAL_DEP_REPLACE_IMPL "find_dependency(hal)")
|
||||
set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)")
|
||||
set(NTCORE_DEP_REPLACE "find_dependency(ntcore)")
|
||||
set(WPILIBC_DEP_REPLACE_IMPL "find_dependency(wpilibc)")
|
||||
set(WPILIBJ_DEP_REPLACE "find_dependency(wpilibj)")
|
||||
set(WPILIBNEWCOMMANDS_DEP_REPLACE "find_dependency(wpilibNewCommands)")
|
||||
endif()
|
||||
set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)")
|
||||
set(WPINET_DEP_REPLACE "find_dependency(wpinet)")
|
||||
set(WPIUNITS_DEP_REPLACE "find_dependency(wpiunits)")
|
||||
set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)")
|
||||
|
||||
set(FILENAME_DEP_REPLACE "get_filename_component(SELF_DIR \"$\{CMAKE_CURRENT_LIST_FILE\}\" PATH)")
|
||||
set(SELF_DIR "$\{SELF_DIR\}")
|
||||
@@ -220,7 +242,15 @@ if(isMultiConfig)
|
||||
list(APPEND CMAKE_CONFIGURATION_TYPES Ubsan)
|
||||
endif()
|
||||
else()
|
||||
set(allowedBuildTypes Asan Tsan Ubsan Debug Release RelWithDebInfo MinSizeRel)
|
||||
set(allowedBuildTypes
|
||||
Asan
|
||||
Tsan
|
||||
Ubsan
|
||||
Debug
|
||||
Release
|
||||
RelWithDebInfo
|
||||
MinSizeRel
|
||||
)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowedBuildTypes}")
|
||||
|
||||
if(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE IN_LIST allowedBuildTypes)
|
||||
@@ -229,54 +259,90 @@ else()
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS_ASAN
|
||||
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING
|
||||
"Flags used by the C compiler for Asan build type or configuration." FORCE)
|
||||
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer"
|
||||
CACHE STRING
|
||||
"Flags used by the C compiler for Asan build type or configuration."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_ASAN
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING
|
||||
"Flags used by the C++ compiler for Asan build type or configuration." FORCE)
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer"
|
||||
CACHE STRING
|
||||
"Flags used by the C++ compiler for Asan build type or configuration."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_ASAN
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING
|
||||
"Linker flags to be used to create executables for Asan build type." FORCE)
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address"
|
||||
CACHE STRING
|
||||
"Linker flags to be used to create executables for Asan build type."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_ASAN
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING
|
||||
"Linker lags to be used to create shared libraries for Asan build type." FORCE)
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address"
|
||||
CACHE STRING
|
||||
"Linker lags to be used to create shared libraries for Asan build type."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_C_FLAGS_TSAN
|
||||
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING
|
||||
"Flags used by the C compiler for Tsan build type or configuration." FORCE)
|
||||
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer"
|
||||
CACHE STRING
|
||||
"Flags used by the C compiler for Tsan build type or configuration."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_TSAN
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING
|
||||
"Flags used by the C++ compiler for Tsan build type or configuration." FORCE)
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer"
|
||||
CACHE STRING
|
||||
"Flags used by the C++ compiler for Tsan build type or configuration."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_TSAN
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread" CACHE STRING
|
||||
"Linker flags to be used to create executables for Tsan build type." FORCE)
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread"
|
||||
CACHE STRING
|
||||
"Linker flags to be used to create executables for Tsan build type."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_TSAN
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread" CACHE STRING
|
||||
"Linker lags to be used to create shared libraries for Tsan build type." FORCE)
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread"
|
||||
CACHE STRING
|
||||
"Linker lags to be used to create shared libraries for Tsan build type."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_C_FLAGS_UBSAN
|
||||
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" CACHE STRING
|
||||
"Flags used by the C compiler for Ubsan build type or configuration." FORCE)
|
||||
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"
|
||||
CACHE STRING
|
||||
"Flags used by the C compiler for Ubsan build type or configuration."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_UBSAN
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" CACHE STRING
|
||||
"Flags used by the C++ compiler for Ubsan build type or configuration." FORCE)
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"
|
||||
CACHE STRING
|
||||
"Flags used by the C++ compiler for Ubsan build type or configuration."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_UBSAN
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all" CACHE STRING
|
||||
"Linker flags to be used to create executables for Ubsan build type." FORCE)
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all"
|
||||
CACHE STRING
|
||||
"Linker flags to be used to create executables for Ubsan build type."
|
||||
FORCE
|
||||
)
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_UBSAN
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined" CACHE STRING
|
||||
"Linker lags to be used to create shared libraries for Ubsan build type." FORCE)
|
||||
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined"
|
||||
CACHE STRING
|
||||
"Linker lags to be used to create shared libraries for Ubsan build type."
|
||||
FORCE
|
||||
)
|
||||
|
||||
if (WITH_TESTS)
|
||||
if(WITH_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(googletest)
|
||||
include(GoogleTest)
|
||||
@@ -284,41 +350,49 @@ endif()
|
||||
|
||||
add_subdirectory(wpiutil)
|
||||
|
||||
if (WITH_NTCORE)
|
||||
if(WITH_NTCORE)
|
||||
add_subdirectory(wpinet)
|
||||
add_subdirectory(ntcore)
|
||||
endif()
|
||||
|
||||
if (WITH_WPIMATH)
|
||||
if(WITH_WPIMATH)
|
||||
if(WITH_JAVA)
|
||||
add_subdirectory(wpiunits)
|
||||
endif()
|
||||
add_subdirectory(wpimath)
|
||||
endif()
|
||||
|
||||
if (WITH_GUI)
|
||||
if(WITH_WPIUNITS AND NOT WITH_WPIMATH)
|
||||
# In case of building wpiunits standalone
|
||||
add_subdirectory(wpiunits)
|
||||
endif()
|
||||
|
||||
if(WITH_GUI)
|
||||
add_subdirectory(fieldImages)
|
||||
add_subdirectory(imgui)
|
||||
add_subdirectory(wpigui)
|
||||
add_subdirectory(glass)
|
||||
add_subdirectory(outlineviewer)
|
||||
add_subdirectory(sysid)
|
||||
if (LIBSSH_FOUND)
|
||||
if(LIBSSH_FOUND)
|
||||
add_subdirectory(roborioteamnumbersetter)
|
||||
add_subdirectory(datalogtool)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WITH_WPILIB OR WITH_SIMULATION_MODULES)
|
||||
if(WITH_WPILIB OR WITH_SIMULATION_MODULES)
|
||||
set(HAL_DEP_REPLACE ${HAL_DEP_REPLACE_IMPL})
|
||||
add_subdirectory(hal)
|
||||
endif()
|
||||
|
||||
if (WITH_CSCORE)
|
||||
if(WITH_CSCORE)
|
||||
set(CSCORE_DEP_REPLACE ${CSCORE_DEP_REPLACE_IMPL})
|
||||
set(CAMERASERVER_DEP_REPLACE ${CAMERASERVER_DEP_REPLACE_IMPL})
|
||||
add_subdirectory(cscore)
|
||||
add_subdirectory(cameraserver)
|
||||
endif()
|
||||
|
||||
if (WITH_WPILIB)
|
||||
if(WITH_WPILIB)
|
||||
set(WPILIBC_DEP_REPLACE ${WPILIBC_DEP_REPLACE_IMPL})
|
||||
add_subdirectory(apriltag)
|
||||
add_subdirectory(wpilibj)
|
||||
@@ -326,15 +400,15 @@ if (WITH_WPILIB)
|
||||
add_subdirectory(wpilibNewCommands)
|
||||
add_subdirectory(romiVendordep)
|
||||
add_subdirectory(xrpVendordep)
|
||||
if (WITH_EXAMPLES)
|
||||
if(WITH_EXAMPLES)
|
||||
add_subdirectory(wpilibcExamples)
|
||||
endif()
|
||||
add_subdirectory(myRobot)
|
||||
endif()
|
||||
|
||||
if (WITH_SIMULATION_MODULES AND NOT WITH_EXTERNAL_HAL)
|
||||
if(WITH_SIMULATION_MODULES AND NOT WITH_EXTERNAL_HAL)
|
||||
add_subdirectory(simulation)
|
||||
endif()
|
||||
|
||||
configure_file(wpilib-config.cmake.in ${WPILIB_BINARY_DIR}/wpilib-config.cmake )
|
||||
install(FILES ${WPILIB_BINARY_DIR}/wpilib-config.cmake DESTINATION ${wpilib_config_dir})
|
||||
configure_file(wpilib-config.cmake.in ${WPILIB_BINARY_DIR}/wpilib-config.cmake)
|
||||
install(FILES ${WPILIB_BINARY_DIR}/wpilib-config.cmake DESTINATION share/wpilib)
|
||||
|
||||
@@ -12,6 +12,7 @@ WPILib is normally built with Gradle, however for some systems, such as Linux ba
|
||||
* halsim
|
||||
* wpigui
|
||||
* wpimath
|
||||
* wpiunits
|
||||
* wpilibNewCommands
|
||||
|
||||
By default, all libraries except for the HAL and WPILib 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.
|
||||
@@ -34,6 +35,8 @@ The following build options are available:
|
||||
|
||||
* `WITH_JAVA` (ON Default)
|
||||
* This option will enable Java and JNI builds. If this is on, `WITH_SHARED_LIBS` must be on. Otherwise CMake will error.
|
||||
* `WITH_JAVA_SOURCE` (ON 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_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.
|
||||
* `WITH_CSCORE` (ON Default)
|
||||
@@ -42,6 +45,8 @@ The following build options are available:
|
||||
* This option will cause ntcore to be built. Turning this off will implicitly disable wpinet and wpilib as well, irrespective of their specific options.
|
||||
* `WITH_WPIMATH` (ON Default)
|
||||
* This option will build the wpimath library. This option must be on to build wpilib.
|
||||
* `WITH_WPIUNITS` (ON 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.
|
||||
* `WITH_WPILIB` (ON Default)
|
||||
* This option will build the hal and wpilibc/j during the build. The HAL is the simulator hal, unless the external hal options are used. The cmake build has no capability to build for the RoboRIO.
|
||||
* `WITH_EXAMPLES` (ON Default)
|
||||
|
||||
19
README.md
19
README.md
@@ -88,9 +88,24 @@ If opening from a fresh clone, generated java dependencies will not exist. Most
|
||||
|
||||
`./gradlew build` builds _everything_, which includes debug and release builds for desktop and all installed cross compilers. Many developers don't need or want to build all of this. Therefore, common tasks have shortcuts to only build necessary components for common development and testing tasks.
|
||||
|
||||
`./gradlew testDesktopCpp` and `./gradlew testDesktopJava` will build and run the tests for `wpilibc` and `wpilibj` respectively. They will only build the minimum components required to run the tests.
|
||||
`./gradlew testDesktopCpp` and `./gradlew testDesktopJava` will build and run the tests for `wpilibc` and `wpilibj` respectively. They will only build the minimum components required to run the tests. `./gradlew testDesktop` will run both `testDesktopJava` and `testDesktopCpp`.
|
||||
|
||||
`testDesktopCpp` and `testDesktopJava` tasks also exist for the projects `wpiutil`, `ntcore`, `cscore`, `hal` `wpilibNewCommands` and `cameraserver`. These can be ran with `./gradlew :projectName:task`.
|
||||
`testDesktopCpp`, `testDesktopJava`, and `testDesktop` tasks also exist for the following projects:
|
||||
|
||||
- `apriltag`
|
||||
- `cameraserver`
|
||||
- `cscore`
|
||||
- `hal`
|
||||
- `ntcore`
|
||||
- `wpilibNewCommands`
|
||||
- `wpimath`
|
||||
- `wpinet`
|
||||
- `wpiunits`
|
||||
- `wpiutil`
|
||||
- `romiVendordep`
|
||||
- `xrpVendordep`
|
||||
|
||||
These can be ran with `./gradlew :projectName:task`.
|
||||
|
||||
`./gradlew buildDesktopCpp` and `./gradlew buildDesktopJava` will compile `wpilibcExamples` and `wpilibjExamples` respectively. The results can't be ran, but they can compile.
|
||||
|
||||
|
||||
@@ -4,106 +4,146 @@ include(CompileWarnings)
|
||||
include(GenResources)
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
fetchcontent_declare(
|
||||
apriltaglib
|
||||
GIT_REPOSITORY https://github.com/wpilibsuite/apriltag.git
|
||||
GIT_TAG 64be6ab26abf5e995321997fd0752c609a7e30f4
|
||||
GIT_REPOSITORY https://github.com/wpilibsuite/apriltag.git
|
||||
GIT_TAG 64be6ab26abf5e995321997fd0752c609a7e30f4
|
||||
)
|
||||
|
||||
# Don't use apriltag's CMakeLists.txt due to conflicting naming and JNI
|
||||
FetchContent_GetProperties(apriltaglib)
|
||||
fetchcontent_getproperties(apriltaglib)
|
||||
if(NOT apriltaglib_POPULATED)
|
||||
FetchContent_Populate(apriltaglib)
|
||||
fetchcontent_populate(apriltaglib)
|
||||
endif()
|
||||
|
||||
aux_source_directory(${apriltaglib_SOURCE_DIR}/common APRILTAGLIB_COMMON_SRC)
|
||||
file(GLOB TAG_FILES ${apriltaglib_SOURCE_DIR}/tag*.c)
|
||||
set(APRILTAGLIB_SRCS ${apriltaglib_SOURCE_DIR}/apriltag.c ${apriltaglib_SOURCE_DIR}/apriltag_pose.c ${apriltaglib_SOURCE_DIR}/apriltag_quad_thresh.c)
|
||||
set(APRILTAGLIB_SRCS
|
||||
${apriltaglib_SOURCE_DIR}/apriltag.c
|
||||
${apriltaglib_SOURCE_DIR}/apriltag_pose.c
|
||||
${apriltaglib_SOURCE_DIR}/apriltag_quad_thresh.c
|
||||
)
|
||||
|
||||
file(GLOB apriltag_jni_src src/main/native/cpp/jni/AprilTagJNI.cpp)
|
||||
|
||||
if (WITH_JAVA)
|
||||
find_package(Java REQUIRED)
|
||||
find_package(JNI REQUIRED)
|
||||
include(UseJava)
|
||||
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked")
|
||||
if(WITH_JAVA)
|
||||
find_package(Java REQUIRED)
|
||||
find_package(JNI REQUIRED)
|
||||
include(UseJava)
|
||||
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked")
|
||||
|
||||
set(CMAKE_JNI_TARGET true)
|
||||
set(CMAKE_JNI_TARGET true)
|
||||
|
||||
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
|
||||
file(GLOB JACKSON_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/jackson/*.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
|
||||
NO_DEFAULT_PATH)
|
||||
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
|
||||
file(GLOB JACKSON_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/jackson/*.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
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
set(CMAKE_JAVA_INCLUDE_PATH apriltag.jar ${EJML_JARS} ${JACKSON_JARS})
|
||||
set(CMAKE_JAVA_INCLUDE_PATH apriltag.jar ${EJML_JARS} ${JACKSON_JARS})
|
||||
|
||||
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 "edu/wpi/first/apriltag" ${JAVA_RESOURCES}
|
||||
INCLUDE_JARS wpimath_jar ${EJML_JARS} wpiutil_jar ${OPENCV_JAR_FILE}
|
||||
OUTPUT_NAME apriltag
|
||||
GENERATE_NATIVE_HEADERS apriltag_jni_headers)
|
||||
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 "edu/wpi/first/apriltag" ${JAVA_RESOURCES}
|
||||
INCLUDE_JARS wpimath_jar wpiunits_jar ${EJML_JARS} wpiutil_jar ${OPENCV_JAR_FILE}
|
||||
OUTPUT_NAME apriltag
|
||||
GENERATE_NATIVE_HEADERS apriltag_jni_headers
|
||||
)
|
||||
|
||||
get_property(APRILTAG_JAR_FILE TARGET apriltag_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${APRILTAG_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
install_jar(apriltag_jar DESTINATION ${java_lib_dest})
|
||||
install_jar_exports(TARGETS apriltag_jar FILE apriltag_jar.cmake DESTINATION share/apriltag)
|
||||
|
||||
set_property(TARGET apriltag_jar PROPERTY FOLDER "java")
|
||||
add_library(apriltagjni ${apriltag_jni_src})
|
||||
wpilib_target_warnings(apriltagjni)
|
||||
target_link_libraries(apriltagjni PUBLIC apriltag)
|
||||
|
||||
add_library(apriltagjni ${apriltag_jni_src})
|
||||
wpilib_target_warnings(apriltagjni)
|
||||
target_link_libraries(apriltagjni PUBLIC apriltag)
|
||||
set_property(TARGET apriltagjni PROPERTY FOLDER "libraries")
|
||||
|
||||
set_property(TARGET apriltagjni PROPERTY FOLDER "libraries")
|
||||
target_link_libraries(apriltagjni PRIVATE apriltag_jni_headers)
|
||||
add_dependencies(apriltagjni apriltag_jar)
|
||||
|
||||
target_link_libraries(apriltagjni PRIVATE apriltag_jni_headers)
|
||||
add_dependencies(apriltagjni apriltag_jar)
|
||||
install(TARGETS apriltagjni EXPORT apriltagjni)
|
||||
endif()
|
||||
|
||||
install(TARGETS apriltagjni EXPORT apriltagjni)
|
||||
if(WITH_JAVA_SOURCE)
|
||||
find_package(Java REQUIRED)
|
||||
include(UseJava)
|
||||
file(GLOB APRILTAG_SOURCES src/main/java/edu/wpi/first/apriltag/*.java)
|
||||
add_jar(
|
||||
apriltag_src_jar
|
||||
RESOURCES
|
||||
NAMESPACE "edu/wpi/first/apriltag" ${APRILTAG_SOURCES}
|
||||
NAMESPACE
|
||||
"edu/wpi/first/apriltag/jni"
|
||||
src/main/java/edu/wpi/first/apriltag/jni/AprilTagJNI.java
|
||||
OUTPUT_NAME apriltag-sources
|
||||
)
|
||||
|
||||
get_property(APRILTAG_SRC_JAR_FILE TARGET apriltag_src_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${APRILTAG_SRC_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
|
||||
set_property(TARGET apriltag_src_jar PROPERTY FOLDER "java")
|
||||
endif()
|
||||
|
||||
generate_resources(src/main/native/resources/edu/wpi/first/apriltag generated/main/cpp APRILTAG frc apriltag_resources_src)
|
||||
|
||||
file(GLOB apriltag_native_src src/main/native/cpp/*.cpp)
|
||||
|
||||
add_library(apriltag ${apriltag_native_src} ${apriltag_resources_src} ${APRILTAGLIB_SRCS} ${APRILTAGLIB_COMMON_SRC} ${TAG_FILES})
|
||||
add_library(
|
||||
apriltag
|
||||
${apriltag_native_src}
|
||||
${apriltag_resources_src}
|
||||
${APRILTAGLIB_SRCS}
|
||||
${APRILTAGLIB_COMMON_SRC}
|
||||
${TAG_FILES}
|
||||
)
|
||||
set_target_properties(apriltag PROPERTIES DEBUG_POSTFIX "d")
|
||||
|
||||
set_property(TARGET apriltag PROPERTY FOLDER "libraries")
|
||||
target_compile_features(apriltag PUBLIC cxx_std_20)
|
||||
wpilib_target_warnings(apriltag)
|
||||
# disable warnings that apriltaglib can't handle
|
||||
if (MSVC)
|
||||
target_compile_options(apriltag PRIVATE /wd4018 /wd4005 /wd4996)
|
||||
if(MSVC)
|
||||
target_compile_options(apriltag PRIVATE /wd4018 /wd4005 /wd4996)
|
||||
else()
|
||||
target_compile_options(apriltag PRIVATE -Wno-sign-compare -Wno-gnu-zero-variadic-macro-arguments -Wno-type-limits)
|
||||
target_compile_options(
|
||||
apriltag
|
||||
PRIVATE -Wno-sign-compare -Wno-gnu-zero-variadic-macro-arguments -Wno-type-limits
|
||||
)
|
||||
endif()
|
||||
|
||||
target_link_libraries(apriltag wpimath)
|
||||
|
||||
target_include_directories(apriltag PUBLIC
|
||||
$<BUILD_INTERFACE:${apriltaglib_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/apriltag>)
|
||||
target_include_directories(
|
||||
apriltag
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${apriltaglib_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/apriltag>
|
||||
)
|
||||
|
||||
install(TARGETS apriltag EXPORT apriltag)
|
||||
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/apriltag")
|
||||
|
||||
if (WITH_FLAT_INSTALL)
|
||||
set (apriltag_config_dir ${wpilib_dest})
|
||||
else()
|
||||
set (apriltag_config_dir share/apriltag)
|
||||
endif()
|
||||
configure_file(apriltag-config.cmake.in ${WPILIB_BINARY_DIR}/apriltag-config.cmake)
|
||||
install(FILES ${WPILIB_BINARY_DIR}/apriltag-config.cmake DESTINATION share/apriltag)
|
||||
install(EXPORT apriltag DESTINATION share/apriltag)
|
||||
|
||||
configure_file(apriltag-config.cmake.in ${WPILIB_BINARY_DIR}/apriltag-config.cmake )
|
||||
install(FILES ${WPILIB_BINARY_DIR}/apriltag-config.cmake DESTINATION ${apriltag_config_dir})
|
||||
install(EXPORT apriltag DESTINATION ${apriltag_config_dir})
|
||||
|
||||
if (WITH_TESTS)
|
||||
if(WITH_TESTS)
|
||||
wpilib_add_test(apriltag src/test/native/cpp)
|
||||
target_include_directories(apriltag_test PRIVATE src/test/native/include)
|
||||
target_link_libraries(apriltag_test apriltag gmock_main)
|
||||
|
||||
@@ -5,3 +5,6 @@ include(CMakeFindDependencyMacro)
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/apriltag.cmake)
|
||||
if(@WITH_JAVA@)
|
||||
include(${SELF_DIR}/apriltag_jar.cmake)
|
||||
endif()
|
||||
|
||||
@@ -6,7 +6,9 @@ package edu.wpi.first.apriltag;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import edu.wpi.first.apriltag.jni.AprilTagJNI;
|
||||
import edu.wpi.first.math.geometry.Pose3d;
|
||||
import edu.wpi.first.util.RawFrame;
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
@@ -44,4 +46,28 @@ public class AprilTag {
|
||||
public String toString() {
|
||||
return "AprilTag(ID: " + ID + ", pose: " + pose + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a RawFrame containing the apriltag with the id with family 16h5 passed in.
|
||||
*
|
||||
* @param id id
|
||||
* @return A RawFrame containing the AprilTag image
|
||||
*/
|
||||
public static RawFrame generate16h5AprilTagImage(int id) {
|
||||
RawFrame generatedImage = new RawFrame();
|
||||
AprilTagJNI.generate16h5AprilTagImage(id, generatedImage.getDataPtr());
|
||||
return generatedImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a RawFrame containing the apriltag with the id with family 36h11 passed in.
|
||||
*
|
||||
* @param id id
|
||||
* @return A RawFrame containing the AprilTag image
|
||||
*/
|
||||
public static RawFrame generate36h11AprilTagImage(int id) {
|
||||
RawFrame generatedImage = new RawFrame();
|
||||
AprilTagJNI.generate36h11AprilTagImage(id, generatedImage.getDataPtr());
|
||||
return generatedImage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class AprilTagDetection {
|
||||
* @return Homography matrix
|
||||
*/
|
||||
public Matrix<N3, N3> getHomographyMatrix() {
|
||||
return new MatBuilder<>(Nat.N3(), Nat.N3()).fill(m_homography);
|
||||
return MatBuilder.fill(Nat.N3(), Nat.N3(), m_homography);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +95,7 @@ public class AprilTagDetection {
|
||||
|
||||
/**
|
||||
* Gets a corner of the tag in image pixel coordinates. These always wrap counter-clock wise
|
||||
* around the tag.
|
||||
* around the tag. Index 0 is the bottom left corner.
|
||||
*
|
||||
* @param ndx Corner index (range is 0-3, inclusive)
|
||||
* @return Corner point X coordinate
|
||||
@@ -106,7 +106,7 @@ public class AprilTagDetection {
|
||||
|
||||
/**
|
||||
* Gets a corner of the tag in image pixel coordinates. These always wrap counter-clock wise
|
||||
* around the tag.
|
||||
* around the tag. Index 0 is the bottom left corner.
|
||||
*
|
||||
* @param ndx Corner index (range is 0-3, inclusive)
|
||||
* @return Corner point Y coordinate
|
||||
@@ -117,7 +117,8 @@ public class AprilTagDetection {
|
||||
|
||||
/**
|
||||
* Gets the corners of the tag in image pixel coordinates. These always wrap counter-clock wise
|
||||
* around the tag.
|
||||
* around the tag. The first set of corner coordinates are the coordinates for the bottom left
|
||||
* corner.
|
||||
*
|
||||
* @return Corner point array (X and Y for each corner in order)
|
||||
*/
|
||||
|
||||
@@ -244,7 +244,7 @@ public class AprilTagDetector implements AutoCloseable {
|
||||
* Adds a family of tags to be detected.
|
||||
*
|
||||
* @param fam Family name, e.g. "tag16h5"
|
||||
* @param bitsCorrected maximum number of bits to correct
|
||||
* @param bitsCorrected Maximum number of bits to correct
|
||||
* @throws IllegalArgumentException if family name not recognized
|
||||
*/
|
||||
public void addFamily(String fam, int bitsCorrected) {
|
||||
@@ -270,6 +270,8 @@ public class AprilTagDetector implements AutoCloseable {
|
||||
/**
|
||||
* Detect tags from an 8-bit image.
|
||||
*
|
||||
* <p>The image must be grayscale.
|
||||
*
|
||||
* @param img 8-bit OpenCV Mat image
|
||||
* @return Results (array of AprilTagDetection)
|
||||
*/
|
||||
|
||||
@@ -113,6 +113,26 @@ public class AprilTagFieldLayout {
|
||||
return new ArrayList<>(m_apriltags.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of the field the layout is representing in meters.
|
||||
*
|
||||
* @return length, in meters
|
||||
*/
|
||||
@JsonIgnore
|
||||
public double getFieldLength() {
|
||||
return m_fieldDimensions.fieldLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of the field the layout is representing in meters.
|
||||
*
|
||||
* @return width, in meters
|
||||
*/
|
||||
@JsonIgnore
|
||||
public double getFieldWidth() {
|
||||
return m_fieldDimensions.fieldWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the origin based on a predefined enumeration of coordinate frame origins. The origins are
|
||||
* calculated from the field dimensions.
|
||||
@@ -123,7 +143,7 @@ public class AprilTagFieldLayout {
|
||||
* @param origin The predefined origin
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setOrigin(OriginPosition origin) {
|
||||
public final void setOrigin(OriginPosition origin) {
|
||||
switch (origin) {
|
||||
case kBlueAllianceWallRightSide:
|
||||
setOrigin(new Pose3d());
|
||||
@@ -148,10 +168,20 @@ public class AprilTagFieldLayout {
|
||||
* @param origin The new origin for tag transformations
|
||||
*/
|
||||
@JsonIgnore
|
||||
public void setOrigin(Pose3d origin) {
|
||||
public final void setOrigin(Pose3d origin) {
|
||||
m_origin = origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the origin used for tag pose transformation.
|
||||
*
|
||||
* @return the origin
|
||||
*/
|
||||
@JsonIgnore
|
||||
public Pose3d getOrigin() {
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an AprilTag pose by its ID.
|
||||
*
|
||||
|
||||
@@ -44,31 +44,119 @@ public class AprilTagJNI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an AprilTag detector engine.
|
||||
*
|
||||
* @return The detector engine handle
|
||||
*/
|
||||
public static native long createDetector();
|
||||
|
||||
/**
|
||||
* Destroys an AprilTag detector engine.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
*/
|
||||
public static native void destroyDetector(long det);
|
||||
|
||||
/**
|
||||
* Sets the detector engine configuration.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
* @param config A configuration
|
||||
*/
|
||||
public static native void setDetectorConfig(long det, AprilTagDetector.Config config);
|
||||
|
||||
/**
|
||||
* Gets the detector engine configuration.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
* @return The configuration
|
||||
*/
|
||||
public static native AprilTagDetector.Config getDetectorConfig(long det);
|
||||
|
||||
/**
|
||||
* Sets the detector engine quad threshold parameters.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
* @param params Quad threshold parameters
|
||||
*/
|
||||
public static native void setDetectorQTP(
|
||||
long det, AprilTagDetector.QuadThresholdParameters params);
|
||||
|
||||
/**
|
||||
* Gets the detector engine quad threshold parameters.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
* @return Quad threshold parameters
|
||||
*/
|
||||
public static native AprilTagDetector.QuadThresholdParameters getDetectorQTP(long det);
|
||||
|
||||
/**
|
||||
* Adds a family of tags to be detected by the detector engine.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
* @param fam Family name, e.g. "tag16h5"
|
||||
* @param bitsCorrected Maximum number of bits to correct
|
||||
* @return False if family can't be found
|
||||
*/
|
||||
public static native boolean addFamily(long det, String fam, int bitsCorrected);
|
||||
|
||||
/**
|
||||
* Removes a family of tags from the detector.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
* @param fam Family name, e.g. "tag16h5"
|
||||
*/
|
||||
public static native void removeFamily(long det, String fam);
|
||||
|
||||
/**
|
||||
* Unregister all families.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
*/
|
||||
public static native void clearFamilies(long det);
|
||||
|
||||
/**
|
||||
* Detect tags from an 8-bit image.
|
||||
*
|
||||
* @param det The detector engine handle
|
||||
* @param width The width of the image
|
||||
* @param height The height of the image
|
||||
* @param stride The number of bytes between image rows (often the same as width)
|
||||
* @param bufAddr The address of the image buffer
|
||||
* @return The results (array of AprilTagDetection)
|
||||
*/
|
||||
public static native AprilTagDetection[] detect(
|
||||
long det, int width, int height, int stride, long bufAddr);
|
||||
|
||||
/**
|
||||
* Estimates the pose of the tag using the homography method described in [1].
|
||||
*
|
||||
* @param homography Homography 3x3 matrix data
|
||||
* @param tagSize The tag size, in meters
|
||||
* @param fx The camera horizontal focal length, in pixels
|
||||
* @param fy The camera vertical focal length, in pixels
|
||||
* @param cx The camera horizontal focal center, in pixels
|
||||
* @param cy The camera vertical focal center, in pixels
|
||||
* @return Pose estimate
|
||||
*/
|
||||
public static native Transform3d estimatePoseHomography(
|
||||
double[] homography, double tagSize, double fx, double fy, double cx, double cy);
|
||||
|
||||
/**
|
||||
* Estimates the pose of the tag. This returns one or two possible poses for the tag, along with
|
||||
* the object-space error of each.
|
||||
*
|
||||
* @param homography Homography 3x3 matrix data
|
||||
* @param corners Corner point array (X and Y for each corner in order)
|
||||
* @param tagSize The tag size, in meters
|
||||
* @param fx The camera horizontal focal length, in pixels
|
||||
* @param fy The camera vertical focal length, in pixels
|
||||
* @param cx The camera horizontal focal center, in pixels
|
||||
* @param cy The camera vertical focal center, in pixels
|
||||
* @param nIters Number of iterations
|
||||
* @return Initial and (possibly) second pose estimates
|
||||
*/
|
||||
public static native AprilTagPoseEstimate estimatePoseOrthogonalIteration(
|
||||
double[] homography,
|
||||
double[] corners,
|
||||
@@ -79,6 +167,20 @@ public class AprilTagJNI {
|
||||
double cy,
|
||||
int nIters);
|
||||
|
||||
/**
|
||||
* Estimates tag pose. This method is an easier to use interface to
|
||||
* EstimatePoseOrthogonalIteration(), running 50 iterations and returning the pose with the lower
|
||||
* object-space error.
|
||||
*
|
||||
* @param homography Homography 3x3 matrix data
|
||||
* @param corners Corner point array (X and Y for each corner in order)
|
||||
* @param tagSize The tag size, in meters
|
||||
* @param fx The camera horizontal focal length, in pixels
|
||||
* @param fy The camera vertical focal length, in pixels
|
||||
* @param cx The camera horizontal focal center, in pixels
|
||||
* @param cy The camera vertical focal center, in pixels
|
||||
* @return Pose estimate
|
||||
*/
|
||||
public static native Transform3d estimatePose(
|
||||
double[] homography,
|
||||
double[] corners,
|
||||
@@ -87,4 +189,8 @@ public class AprilTagJNI {
|
||||
double fy,
|
||||
double cx,
|
||||
double cy);
|
||||
|
||||
public static native void generate16h5AprilTagImage(int id, long nativeAddr);
|
||||
|
||||
public static native void generate36h11AprilTagImage(int id, long nativeAddr);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,56 @@
|
||||
|
||||
#include <wpi/json.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable : 4200)
|
||||
#elif defined(__clang__)
|
||||
#pragma clang diagnostic ignored "-Wc99-extensions"
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#endif
|
||||
|
||||
#include "apriltag.h"
|
||||
#include "tag16h5.h"
|
||||
#include "tag36h11.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
wpi::RawFrame AprilTag::Generate36h11AprilTagImage(int id) {
|
||||
apriltag_family_t* tagFamily = tag36h11_create();
|
||||
image_u8_t* image = apriltag_to_image(tagFamily, id);
|
||||
wpi::RawFrame markerFrame{};
|
||||
size_t totalDataSize = image->height * image->stride * sizeof(char);
|
||||
markerFrame.data = static_cast<char*>(
|
||||
std::calloc(image->height * image->stride, sizeof(char)));
|
||||
std::memcpy(markerFrame.data, image->buf, totalDataSize);
|
||||
markerFrame.dataLength = image->width;
|
||||
markerFrame.height = image->height;
|
||||
markerFrame.pixelFormat = WPI_PIXFMT_GRAY;
|
||||
markerFrame.width = image->stride;
|
||||
markerFrame.totalData = totalDataSize;
|
||||
image_u8_destroy(image);
|
||||
tag36h11_destroy(tagFamily);
|
||||
return markerFrame;
|
||||
}
|
||||
|
||||
wpi::RawFrame AprilTag::Generate16h5AprilTagImage(int id) {
|
||||
apriltag_family_t* tagFamily = tag16h5_create();
|
||||
image_u8_t* image = apriltag_to_image(tagFamily, id);
|
||||
wpi::RawFrame markerFrame{};
|
||||
size_t totalDataSize = image->height * image->stride * sizeof(char);
|
||||
markerFrame.data = static_cast<char*>(
|
||||
std::calloc(image->height * image->stride, sizeof(char)));
|
||||
std::memcpy(markerFrame.data, image->buf, totalDataSize);
|
||||
markerFrame.dataLength = image->width;
|
||||
markerFrame.height = image->height;
|
||||
markerFrame.pixelFormat = WPI_PIXFMT_GRAY;
|
||||
markerFrame.width = image->stride;
|
||||
markerFrame.totalData = totalDataSize;
|
||||
image_u8_destroy(image);
|
||||
tag16h5_destroy(tagFamily);
|
||||
return markerFrame;
|
||||
}
|
||||
|
||||
void frc::to_json(wpi::json& json, const AprilTag& apriltag) {
|
||||
json = wpi::json{{"ID", apriltag.ID}, {"pose", apriltag.pose}};
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ AprilTagFieldLayout::AprilTagFieldLayout(std::string_view path) {
|
||||
throw std::runtime_error(fmt::format("Cannot open file: {}", path));
|
||||
}
|
||||
|
||||
wpi::json json = wpi::json::parse(fileBuffer->begin(), fileBuffer->end());
|
||||
wpi::json json = wpi::json::parse(fileBuffer->GetCharBuffer());
|
||||
|
||||
for (const auto& tag : json.at("tags").get<std::vector<AprilTag>>()) {
|
||||
m_apriltags[tag.ID] = tag;
|
||||
@@ -41,6 +41,23 @@ AprilTagFieldLayout::AprilTagFieldLayout(std::vector<AprilTag> apriltags,
|
||||
}
|
||||
}
|
||||
|
||||
units::meter_t AprilTagFieldLayout::GetFieldLength() const {
|
||||
return m_fieldLength;
|
||||
}
|
||||
|
||||
units::meter_t AprilTagFieldLayout::GetFieldWidth() const {
|
||||
return m_fieldWidth;
|
||||
}
|
||||
|
||||
std::vector<AprilTag> AprilTagFieldLayout::GetTags() const {
|
||||
std::vector<AprilTag> tags;
|
||||
tags.reserve(m_apriltags.size());
|
||||
for (const auto& tag : m_apriltags) {
|
||||
tags.emplace_back(tag.second);
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
void AprilTagFieldLayout::SetOrigin(OriginPosition origin) {
|
||||
switch (origin) {
|
||||
case OriginPosition::kBlueAllianceWallRightSide:
|
||||
@@ -59,6 +76,10 @@ void AprilTagFieldLayout::SetOrigin(const Pose3d& origin) {
|
||||
m_origin = origin;
|
||||
}
|
||||
|
||||
Pose3d AprilTagFieldLayout::GetOrigin() const {
|
||||
return m_origin;
|
||||
}
|
||||
|
||||
std::optional<frc::Pose3d> AprilTagFieldLayout::GetTagPose(int ID) const {
|
||||
const auto& it = m_apriltags.find(ID);
|
||||
if (it == m_apriltags.end()) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "edu_wpi_first_apriltag_jni_AprilTagJNI.h"
|
||||
#include "frc/apriltag/AprilTag.h"
|
||||
#include "frc/apriltag/AprilTagDetector.h"
|
||||
#include "frc/apriltag/AprilTagPoseEstimator.h"
|
||||
|
||||
@@ -587,4 +588,30 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePose
|
||||
return MakeJObject(env, estimator.Estimate(harr, carr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_apriltag_jni_AprilTagJNI
|
||||
* Method: generate16h5AprilTagImage
|
||||
* Signature: (IJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_apriltag_jni_AprilTagJNI_generate16h5AprilTagImage
|
||||
(JNIEnv* env, jclass, jint id, jlong framePtr)
|
||||
{
|
||||
wpi::RawFrame* javaRawFrame = (wpi::RawFrame*)framePtr;
|
||||
*javaRawFrame = AprilTag::Generate16h5AprilTagImage(id);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_apriltag_jni_AprilTagJNI
|
||||
* Method: generate36h11AprilTagImage
|
||||
* Signature: (IJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_apriltag_jni_AprilTagJNI_generate36h11AprilTagImage
|
||||
(JNIEnv* env, jclass, jint id, jlong framePtr)
|
||||
{
|
||||
wpi::RawFrame* javaRawFrame = (wpi::RawFrame*)framePtr;
|
||||
*javaRawFrame = AprilTag::Generate36h11AprilTagImage(id);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/RawFrame.h>
|
||||
#include <wpi/SymbolExports.h>
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
@@ -20,6 +21,9 @@ struct WPILIB_DLLEXPORT AprilTag {
|
||||
* Checks equality between this AprilTag and another object.
|
||||
*/
|
||||
bool operator==(const AprilTag&) const = default;
|
||||
|
||||
static wpi::RawFrame Generate36h11AprilTagImage(int id);
|
||||
static wpi::RawFrame Generate16h5AprilTagImage(int id);
|
||||
};
|
||||
|
||||
WPILIB_DLLEXPORT
|
||||
|
||||
@@ -93,7 +93,7 @@ class WPILIB_DLLEXPORT AprilTagDetection final {
|
||||
|
||||
/**
|
||||
* Gets a corner of the tag in image pixel coordinates. These always
|
||||
* wrap counter-clock wise around the tag.
|
||||
* wrap counter-clock wise around the tag. Index 0 is the bottom left corner.
|
||||
*
|
||||
* @param ndx Corner index (range is 0-3, inclusive)
|
||||
* @return Corner point
|
||||
@@ -104,7 +104,8 @@ class WPILIB_DLLEXPORT AprilTagDetection final {
|
||||
|
||||
/**
|
||||
* Gets the corners of the tag in image pixel coordinates. These always
|
||||
* wrap counter-clock wise around the tag.
|
||||
* wrap counter-clock wise around the tag. The first set of corner coordinates
|
||||
* are the coordinates for the bottom left corner.
|
||||
*
|
||||
* @param cornersBuf Corner point array (X and Y for each corner in order)
|
||||
* @return Corner point array (copy of cornersBuf span)
|
||||
|
||||
@@ -205,7 +205,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {
|
||||
* Adds a family of tags to be detected.
|
||||
*
|
||||
* @param fam Family name, e.g. "tag16h5"
|
||||
* @param bitsCorrected
|
||||
* @param bitsCorrected Maximum number of bits to correct
|
||||
* @return False if family can't be found
|
||||
*/
|
||||
bool AddFamily(std::string_view fam, int bitsCorrected = 2);
|
||||
@@ -226,6 +226,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {
|
||||
|
||||
/**
|
||||
* Detect tags from an 8-bit image.
|
||||
* The image must be grayscale.
|
||||
*
|
||||
* @param width width of the image
|
||||
* @param height height of the image
|
||||
@@ -237,6 +238,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {
|
||||
|
||||
/**
|
||||
* Detect tags from an 8-bit image.
|
||||
* The image must be grayscale.
|
||||
*
|
||||
* @param width width of the image
|
||||
* @param height height of the image
|
||||
|
||||
@@ -62,6 +62,24 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
|
||||
AprilTagFieldLayout(std::vector<AprilTag> apriltags,
|
||||
units::meter_t fieldLength, units::meter_t fieldWidth);
|
||||
|
||||
/**
|
||||
* Returns the length of the field the layout is representing.
|
||||
* @return length
|
||||
*/
|
||||
units::meter_t GetFieldLength() const;
|
||||
|
||||
/**
|
||||
* Returns the length of the field the layout is representing.
|
||||
* @return width
|
||||
*/
|
||||
units::meter_t GetFieldWidth() const;
|
||||
|
||||
/**
|
||||
* Returns a vector of all the april tags used in this layout.
|
||||
* @return list of tags
|
||||
*/
|
||||
std::vector<AprilTag> GetTags() const;
|
||||
|
||||
/**
|
||||
* Sets the origin based on a predefined enumeration of coordinate frame
|
||||
* origins. The origins are calculated from the field dimensions.
|
||||
@@ -83,6 +101,12 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
|
||||
*/
|
||||
void SetOrigin(const Pose3d& origin);
|
||||
|
||||
/**
|
||||
* Returns the origin used for tag pose transformation.
|
||||
* @return the origin
|
||||
*/
|
||||
Pose3d GetOrigin() const;
|
||||
|
||||
/**
|
||||
* Gets an AprilTag pose by its ID.
|
||||
*
|
||||
|
||||
@@ -12,7 +12,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import edu.wpi.first.math.geometry.Pose3d;
|
||||
import edu.wpi.first.math.geometry.Rotation3d;
|
||||
import edu.wpi.first.math.util.Units;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -28,7 +27,7 @@ class LoadConfigTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void test2022RapidReact() throws IOException {
|
||||
void test2022RapidReact() {
|
||||
AprilTagFieldLayout layout = AprilTagFields.k2022RapidReact.loadAprilTagLayoutField();
|
||||
|
||||
// Blue Hangar Truss - Hub
|
||||
|
||||
@@ -23,7 +23,7 @@ plugins {
|
||||
id 'net.ltgt.errorprone' version '3.1.0' apply false
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||
id 'com.diffplug.spotless' version '6.20.0' apply false
|
||||
id 'com.github.spotbugs' version '5.1.3' apply false
|
||||
id 'com.github.spotbugs' version '6.0.2' apply false
|
||||
id 'com.google.protobuf' version '0.9.3' apply false
|
||||
}
|
||||
|
||||
@@ -50,6 +50,9 @@ buildScan {
|
||||
publishAlways()
|
||||
}
|
||||
|
||||
import com.github.spotbugs.snom.Effort
|
||||
ext.spotbugsEffort = Effort.MAX
|
||||
|
||||
ext.licenseFile = files("$rootDir/LICENSE.md", "$rootDir/ThirdPartyNotices.txt")
|
||||
|
||||
if (project.hasProperty("publishVersion")) {
|
||||
@@ -171,5 +174,5 @@ ext.getCurrentArch = {
|
||||
}
|
||||
|
||||
wrapper {
|
||||
gradleVersion = '8.4'
|
||||
gradleVersion = '8.5'
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ repositories {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation "edu.wpi.first:native-utils:2024.3.1"
|
||||
implementation "edu.wpi.first:native-utils:2024.5.2"
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class WPIJREArtifact extends MavenArtifact {
|
||||
|
||||
private boolean checkJreVersion = true;
|
||||
|
||||
private final String artifactLocation = "edu.wpi.first.jdk:roborio-2023:17.0.5u7-1"
|
||||
private final String artifactLocation = "edu.wpi.first.jdk:roborio-2024:17.0.9u7-1"
|
||||
|
||||
@Inject
|
||||
public WPIJREArtifact(String name, RemoteTarget target) {
|
||||
|
||||
@@ -3,10 +3,10 @@ project(cameraserver)
|
||||
include(CompileWarnings)
|
||||
include(AddTest)
|
||||
|
||||
find_package( OpenCV REQUIRED )
|
||||
find_package(OpenCV REQUIRED)
|
||||
|
||||
# Java bindings
|
||||
if (WITH_JAVA)
|
||||
if(WITH_JAVA)
|
||||
find_package(Java REQUIRED)
|
||||
include(UseJava)
|
||||
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked")
|
||||
@@ -15,26 +15,58 @@ if (WITH_JAVA)
|
||||
|
||||
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/OpenCV/java/)
|
||||
|
||||
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 NO_DEFAULT_PATH)
|
||||
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
|
||||
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)
|
||||
|
||||
get_property(CAMERASERVER_JAR_FILE TARGET cameraserver_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${CAMERASERVER_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
|
||||
set_property(TARGET cameraserver_jar PROPERTY FOLDER "java")
|
||||
add_jar(
|
||||
cameraserver_jar
|
||||
${JAVA_SOURCES}
|
||||
INCLUDE_JARS wpiutil_jar cscore_jar ntcore_jar ${OPENCV_JAR_FILE}
|
||||
OUTPUT_NAME cameraserver
|
||||
)
|
||||
|
||||
install_jar(cameraserver_jar DESTINATION ${java_lib_dest})
|
||||
install_jar_exports(
|
||||
TARGETS cameraserver_jar
|
||||
FILE cameraserver_jar.cmake
|
||||
DESTINATION share/cameraserver
|
||||
)
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE
|
||||
cameraserver_native_src src/main/native/cpp/*.cpp)
|
||||
if(WITH_JAVA_SOURCE)
|
||||
find_package(Java REQUIRED)
|
||||
include(UseJava)
|
||||
file(GLOB CAMERASERVER_SOURCES src/main/java/edu/wpi/first/cameraserver/*.java)
|
||||
file(GLOB VISION_SOURCES src/main/java/edu/wpi/first/vision/*.java)
|
||||
add_jar(
|
||||
cameraserver_src_jar
|
||||
RESOURCES
|
||||
NAMESPACE "edu/wpi/first/cameraserver" ${CAMERASERVER_SOURCES}
|
||||
NAMESPACE "edu/wpi/first/vision" ${VISION_SOURCES}
|
||||
OUTPUT_NAME cameraserver-sources
|
||||
)
|
||||
|
||||
get_property(CAMERASERVER_SRC_JAR_FILE TARGET cameraserver_src_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${CAMERASERVER_SRC_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
|
||||
set_property(TARGET cameraserver_src_jar PROPERTY FOLDER "java")
|
||||
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")
|
||||
target_include_directories(cameraserver PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/cameraserver>)
|
||||
target_include_directories(
|
||||
cameraserver
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/cameraserver>
|
||||
)
|
||||
wpilib_target_warnings(cameraserver)
|
||||
target_link_libraries(cameraserver PUBLIC ntcore cscore wpiutil ${OpenCV_LIBS})
|
||||
|
||||
@@ -43,15 +75,9 @@ set_property(TARGET cameraserver PROPERTY FOLDER "libraries")
|
||||
install(TARGETS cameraserver EXPORT cameraserver)
|
||||
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cameraserver")
|
||||
|
||||
if (WITH_FLAT_INSTALL)
|
||||
set (cameraserver_config_dir ${wpilib_dest})
|
||||
else()
|
||||
set (cameraserver_config_dir share/cameraserver)
|
||||
endif()
|
||||
|
||||
configure_file(cameraserver-config.cmake.in ${WPILIB_BINARY_DIR}/cameraserver-config.cmake )
|
||||
install(FILES ${WPILIB_BINARY_DIR}/cameraserver-config.cmake DESTINATION ${cameraserver_config_dir})
|
||||
install(EXPORT cameraserver DESTINATION ${cameraserver_config_dir})
|
||||
configure_file(cameraserver-config.cmake.in ${WPILIB_BINARY_DIR}/cameraserver-config.cmake)
|
||||
install(FILES ${WPILIB_BINARY_DIR}/cameraserver-config.cmake DESTINATION share/cameraserver)
|
||||
install(EXPORT cameraserver DESTINATION share/cameraserver)
|
||||
|
||||
file(GLOB multiCameraServer_src multiCameraServer/src/main/native/cpp/*.cpp)
|
||||
add_executable(multiCameraServer ${multiCameraServer_src})
|
||||
@@ -60,7 +86,7 @@ target_link_libraries(multiCameraServer cameraserver)
|
||||
|
||||
set_property(TARGET multiCameraServer PROPERTY FOLDER "examples")
|
||||
|
||||
if (WITH_TESTS)
|
||||
if(WITH_TESTS)
|
||||
wpilib_add_test(cameraserver src/test/native/cpp)
|
||||
target_link_libraries(cameraserver_test cameraserver gtest)
|
||||
endif()
|
||||
|
||||
@@ -7,3 +7,6 @@ find_dependency(OpenCV)
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/cameraserver.cmake)
|
||||
if(@WITH_JAVA@)
|
||||
include(${SELF_DIR}/cameraserver_jar.cmake)
|
||||
endif()
|
||||
|
||||
@@ -98,7 +98,7 @@ public final class Main {
|
||||
// parse file
|
||||
JsonElement top;
|
||||
try {
|
||||
top = new JsonParser().parse(Files.newBufferedReader(Paths.get(configFile)));
|
||||
top = JsonParser.parseReader(Files.newBufferedReader(Paths.get(configFile)));
|
||||
} catch (IOException ex) {
|
||||
System.err.println("could not open '" + configFile + "': " + ex);
|
||||
return false;
|
||||
|
||||
@@ -105,7 +105,7 @@ bool ReadConfig() {
|
||||
// parse file
|
||||
wpi::json j;
|
||||
try {
|
||||
j = wpi::json::parse(fileBuffer->begin(), fileBuffer->end());
|
||||
j = wpi::json::parse(fileBuffer->GetCharBuffer());
|
||||
} catch (const wpi::json::parse_error& e) {
|
||||
fmt::print(stderr, "config error in '{}': byte {}: {}\n", configFile,
|
||||
e.byte, e.what());
|
||||
|
||||
@@ -114,7 +114,7 @@ public final class CameraServer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
public void close() {
|
||||
if (m_booleanValueEntry != null) {
|
||||
m_booleanValueEntry.close();
|
||||
}
|
||||
@@ -745,6 +745,34 @@ public final class CameraServer {
|
||||
return newsink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OpenCV access to the specified camera. This allows you to get images from the camera for
|
||||
* image processing on the roboRIO.
|
||||
*
|
||||
* @param camera Camera (e.g. as returned by startAutomaticCapture).
|
||||
* @param pixelFormat Desired pixelFormat of the camera
|
||||
* @return OpenCV sink for the specified camera
|
||||
*/
|
||||
public static CvSink getVideo(VideoSource camera, PixelFormat pixelFormat) {
|
||||
String name = "opencv_" + camera.getName();
|
||||
|
||||
synchronized (CameraServer.class) {
|
||||
VideoSink sink = m_sinks.get(name);
|
||||
if (sink != null) {
|
||||
VideoSink.Kind kind = sink.getKind();
|
||||
if (kind != VideoSink.Kind.kCv) {
|
||||
throw new VideoException("expected OpenCV sink, but got " + kind);
|
||||
}
|
||||
return (CvSink) sink;
|
||||
}
|
||||
}
|
||||
|
||||
CvSink newsink = new CvSink(name, pixelFormat);
|
||||
newsink.setSource(camera);
|
||||
addServer(newsink);
|
||||
return newsink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get OpenCV access to the specified camera. This allows you to get images from the camera for
|
||||
* image processing on the roboRIO.
|
||||
|
||||
@@ -21,6 +21,7 @@ public class VisionThread extends Thread {
|
||||
*
|
||||
* @param visionRunner the runner for a vision pipeline
|
||||
*/
|
||||
@SuppressWarnings("this-escape")
|
||||
public VisionThread(VisionRunner<?> visionRunner) {
|
||||
super(visionRunner::runForever, "WPILib Vision Thread");
|
||||
setDaemon(true);
|
||||
|
||||
@@ -622,6 +622,33 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
|
||||
return newsink;
|
||||
}
|
||||
|
||||
cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera,
|
||||
cs::VideoMode::PixelFormat pixelFormat) {
|
||||
auto& inst = ::GetInstance();
|
||||
wpi::SmallString<64> name{"opencv_"};
|
||||
name += camera.GetName();
|
||||
|
||||
{
|
||||
std::scoped_lock lock(inst.m_mutex);
|
||||
auto it = inst.m_sinks.find(name);
|
||||
if (it != inst.m_sinks.end()) {
|
||||
auto kind = it->second.GetKind();
|
||||
if (kind != cs::VideoSink::kCv) {
|
||||
auto csShared = GetCameraServerShared();
|
||||
csShared->SetCameraServerError("expected OpenCV sink, but got {}",
|
||||
static_cast<int>(kind));
|
||||
return cs::CvSink{};
|
||||
}
|
||||
return *static_cast<cs::CvSink*>(&it->second);
|
||||
}
|
||||
}
|
||||
|
||||
cs::CvSink newsink{name.str(), pixelFormat};
|
||||
newsink.SetSource(camera);
|
||||
AddServer(newsink);
|
||||
return newsink;
|
||||
}
|
||||
|
||||
cs::CvSink CameraServer::GetVideo(std::string_view name) {
|
||||
auto& inst = ::GetInstance();
|
||||
cs::VideoSource source;
|
||||
@@ -638,6 +665,23 @@ cs::CvSink CameraServer::GetVideo(std::string_view name) {
|
||||
return GetVideo(source);
|
||||
}
|
||||
|
||||
cs::CvSink CameraServer::GetVideo(std::string_view name,
|
||||
cs::VideoMode::PixelFormat pixelFormat) {
|
||||
auto& inst = ::GetInstance();
|
||||
cs::VideoSource source;
|
||||
{
|
||||
std::scoped_lock lock(inst.m_mutex);
|
||||
auto it = inst.m_sources.find(name);
|
||||
if (it == inst.m_sources.end()) {
|
||||
auto csShared = GetCameraServerShared();
|
||||
csShared->SetCameraServerError("could not find camera {}", name);
|
||||
return cs::CvSink{};
|
||||
}
|
||||
source = it->second;
|
||||
}
|
||||
return GetVideo(source, pixelFormat);
|
||||
}
|
||||
|
||||
cs::CvSource CameraServer::PutVideo(std::string_view name, int width,
|
||||
int height) {
|
||||
::GetInstance();
|
||||
|
||||
@@ -191,6 +191,17 @@ class CameraServer {
|
||||
*/
|
||||
static cs::CvSink GetVideo(const cs::VideoSource& camera);
|
||||
|
||||
/**
|
||||
* Get OpenCV access to the specified camera. This allows you to get
|
||||
* images from the camera for image processing on the roboRIO.
|
||||
*
|
||||
* @param camera Camera (e.g. as returned by startAutomaticCapture).
|
||||
* @param pixelFormat The desired pixelFormat of captured frames from the
|
||||
* camera
|
||||
*/
|
||||
static cs::CvSink GetVideo(const cs::VideoSource& camera,
|
||||
cs::VideoMode::PixelFormat pixelFormat);
|
||||
|
||||
/**
|
||||
* Get OpenCV access to the specified camera. This allows you to get
|
||||
* images from the camera for image processing on the roboRIO.
|
||||
@@ -199,6 +210,17 @@ class CameraServer {
|
||||
*/
|
||||
static cs::CvSink GetVideo(std::string_view name);
|
||||
|
||||
/**
|
||||
* Get OpenCV access to the specified camera. This allows you to get
|
||||
* images from the camera for image processing on the roboRIO.
|
||||
*
|
||||
* @param name Camera name
|
||||
* @param pixelFormat The desired pixelFormat of captured frames from the
|
||||
* camera
|
||||
*/
|
||||
static cs::CvSink GetVideo(std::string_view name,
|
||||
cs::VideoMode::PixelFormat pixelFormat);
|
||||
|
||||
/**
|
||||
* Create a MJPEG stream with OpenCV input. This can be called to pass custom
|
||||
* annotated images to the dashboard.
|
||||
|
||||
@@ -4,10 +4,10 @@ macro(wpilib_add_test name srcdir)
|
||||
file(GLOB_RECURSE test_src ${srcdir}/*.cpp)
|
||||
add_executable(${name}_test ${test_src})
|
||||
wpilib_target_warnings(${name}_test)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(${name}_test PRIVATE -DGTEST_LINKED_AS_SHARED_LIBRARY)
|
||||
endif()
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
target_compile_options(${name}_test PRIVATE /wd4101 /wd4251)
|
||||
endif()
|
||||
add_test(NAME ${name} COMMAND ${name}_test)
|
||||
|
||||
@@ -1,28 +1,48 @@
|
||||
macro(wpilib_target_warnings target)
|
||||
if(NOT MSVC)
|
||||
target_compile_options(${target} PRIVATE -Wall -pedantic -Wextra -Werror -Wno-unused-parameter ${WPILIB_TARGET_WARNINGS})
|
||||
target_compile_options(
|
||||
${target}
|
||||
PRIVATE -Wall -pedantic -Wextra -Werror -Wno-unused-parameter ${WPILIB_TARGET_WARNINGS}
|
||||
)
|
||||
else()
|
||||
target_compile_options(${target} PRIVATE /wd4146 /wd4244 /wd4251 /wd4267 /WX /D_CRT_SECURE_NO_WARNINGS ${WPILIB_TARGET_WARNINGS})
|
||||
target_compile_options(
|
||||
${target}
|
||||
PRIVATE
|
||||
/wd4146
|
||||
/wd4244
|
||||
/wd4251
|
||||
/wd4267
|
||||
/WX
|
||||
/D_CRT_SECURE_NO_WARNINGS
|
||||
${WPILIB_TARGET_WARNINGS}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Suppress C++-specific OpenCV warning; C compiler rejects it with an error
|
||||
# https://github.com/opencv/opencv/issues/20269
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>)
|
||||
target_compile_options(
|
||||
${target}
|
||||
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>
|
||||
)
|
||||
elseif(UNIX AND APPLE)
|
||||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-anon-enum-enum-conversion>)
|
||||
target_compile_options(
|
||||
${target}
|
||||
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-anon-enum-enum-conversion>
|
||||
)
|
||||
endif()
|
||||
|
||||
# Suppress warning "enumeration types with a fixed underlying type are a
|
||||
# Clang extension"
|
||||
if(APPLE)
|
||||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-fixed-enum-extension>)
|
||||
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-fixed-enum-extension>)
|
||||
endif()
|
||||
|
||||
# Compress debug info with GCC
|
||||
if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR
|
||||
${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo") AND
|
||||
${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
||||
target_compile_options(${target} PRIVATE -gz=zlib)
|
||||
if(
|
||||
(${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
|
||||
AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"
|
||||
)
|
||||
target_compile_options(${target} PRIVATE -gz=zlib)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
macro(download_and_check source destination)
|
||||
file(DOWNLOAD ${source} ${destination} STATUS download_status)
|
||||
list(GET download_status 0 status_code)
|
||||
list(GET download_status 1 status_message)
|
||||
file(DOWNLOAD ${source} ${destination} STATUS download_status)
|
||||
list(GET download_status 0 status_code)
|
||||
list(GET download_status 1 status_message)
|
||||
|
||||
if(${status_code} EQUAL 0)
|
||||
message(VERBOSE "Download of \"${source}\" successful.")
|
||||
else()
|
||||
message(FATAL_ERROR "Download of \"${source}\" failed: ${status_message}")
|
||||
endif()
|
||||
if(${status_code} EQUAL 0)
|
||||
message(VERBOSE "Download of \"${source}\" successful.")
|
||||
else()
|
||||
message(FATAL_ERROR "Download of \"${source}\" failed: ${status_message}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -38,30 +38,28 @@ if(LIBSSH_LIBRARIES AND LIBSSH_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
set(LIBSSH_FOUND TRUE)
|
||||
else()
|
||||
find_path(LIBSSH_INCLUDE_DIR
|
||||
NAMES
|
||||
libssh/libssh.h
|
||||
find_path(
|
||||
LIBSSH_INCLUDE_DIR
|
||||
NAMES libssh/libssh.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
${CMAKE_INCLUDE_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
${CMAKE_INCLUDE_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/include
|
||||
)
|
||||
|
||||
find_library(LIBSSH_LIBRARY
|
||||
NAMES
|
||||
ssh.so
|
||||
libssh.so
|
||||
libssh.dylib
|
||||
find_library(
|
||||
LIBSSH_LIBRARY
|
||||
NAMES ssh.so libssh.so libssh.dylib
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
${CMAKE_LIBRARY_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
${CMAKE_LIBRARY_PATH}
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
)
|
||||
|
||||
if(LIBSSH_INCLUDE_DIR AND LIBSSH_LIBRARY)
|
||||
@@ -71,34 +69,60 @@ else()
|
||||
else()
|
||||
set(LIBSSH_HEADER_PATH ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h)
|
||||
endif()
|
||||
file(STRINGS ${LIBSSH_HEADER_PATH} LIBSSH_VERSION_MAJOR
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MAJOR[ ]+[0-9]+")
|
||||
file(
|
||||
STRINGS
|
||||
${LIBSSH_HEADER_PATH}
|
||||
LIBSSH_VERSION_MAJOR
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MAJOR[ ]+[0-9]+"
|
||||
)
|
||||
if(NOT LIBSSH_VERSION_MAJOR)
|
||||
message(STATUS "LIBSSH_VERSION_MAJOR not found, assuming libssh is too old and cannot be used!")
|
||||
message(
|
||||
STATUS
|
||||
"LIBSSH_VERSION_MAJOR not found, assuming libssh is too old and cannot be used!"
|
||||
)
|
||||
set(LIBSSH_INCLUDE_DIR "LIBSSH_INCLUDE_DIR-NOTFOUND")
|
||||
set(LIBSSH_LIBRARY "LIBSSH_LIBRARY-NOTFOUND")
|
||||
else()
|
||||
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MAJOR ${LIBSSH_VERSION_MAJOR})
|
||||
file(STRINGS ${LIBSSH_HEADER_PATH} LIBSSH_VERSION_MINOR
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MINOR[ ]+[0-9]+")
|
||||
file(
|
||||
STRINGS
|
||||
${LIBSSH_HEADER_PATH}
|
||||
LIBSSH_VERSION_MINOR
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MINOR[ ]+[0-9]+"
|
||||
)
|
||||
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MINOR ${LIBSSH_VERSION_MINOR})
|
||||
file(STRINGS ${LIBSSH_HEADER_PATH} LIBSSH_VERSION_PATCH
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MICRO[ ]+[0-9]+")
|
||||
file(
|
||||
STRINGS
|
||||
${LIBSSH_HEADER_PATH}
|
||||
LIBSSH_VERSION_PATCH
|
||||
REGEX "#define[ ]+LIBSSH_VERSION_MICRO[ ]+[0-9]+"
|
||||
)
|
||||
string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_PATCH ${LIBSSH_VERSION_PATCH})
|
||||
|
||||
set(LIBSSH_VERSION ${LIBSSH_VERSION_MAJOR}.${LIBSSH_VERSION_MINOR}.${LIBSSH_VERSION_PATCH})
|
||||
set(LIBSSH_VERSION
|
||||
${LIBSSH_VERSION_MAJOR}.${LIBSSH_VERSION_MINOR}.${LIBSSH_VERSION_PATCH}
|
||||
)
|
||||
|
||||
if(LIBSSH_VERSION VERSION_LESS 0.8.0)
|
||||
# libssh_threads also needs to be linked for these versions
|
||||
string(REPLACE "libssh.so" "libssh_threads.so"
|
||||
string(
|
||||
REPLACE
|
||||
"libssh.so"
|
||||
"libssh_threads.so"
|
||||
LIBSSH_THREADS_LIBRARY
|
||||
${LIBSSH_LIBRARY}
|
||||
)
|
||||
string(REPLACE "libssh.dylib" "libssh_threads.dylib"
|
||||
string(
|
||||
REPLACE
|
||||
"libssh.dylib"
|
||||
"libssh_threads.dylib"
|
||||
LIBSSH_THREADS_LIBRARY
|
||||
${LIBSSH_THREADS_LIBRARY}
|
||||
)
|
||||
string(REPLACE "ssh.so" "ssh_threads.so"
|
||||
string(
|
||||
REPLACE
|
||||
"ssh.so"
|
||||
"ssh_threads.so"
|
||||
LIBSSH_THREADS_LIBRARY
|
||||
${LIBSSH_THREADS_LIBRARY}
|
||||
)
|
||||
@@ -110,7 +134,10 @@ else()
|
||||
set(LIBSSH_LIBRARIES ${LIBSSH_LIBRARY} ${LIBSSH_THREADS_LIBRARY})
|
||||
mark_as_advanced(LIBSSH_INCLUDE_DIRS LIBSSH_LIBRARIES)
|
||||
|
||||
find_package_handle_standard_args(LIBSSH FOUND_VAR LIBSSH_FOUND
|
||||
find_package_handle_standard_args(
|
||||
LIBSSH
|
||||
FOUND_VAR LIBSSH_FOUND
|
||||
REQUIRED_VARS LIBSSH_INCLUDE_DIRS LIBSSH_LIBRARIES
|
||||
VERSION_VAR LIBSSH_VERSION)
|
||||
VERSION_VAR LIBSSH_VERSION
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -1,26 +1,30 @@
|
||||
set(scripts_dir "${CMAKE_CURRENT_LIST_DIR}/../scripts")
|
||||
macro(generate_resources inputDir outputDir prefix namespace outputFiles)
|
||||
file(GLOB inputFiles ${inputDir}/*)
|
||||
set(${outputFiles})
|
||||
foreach(input ${inputFiles})
|
||||
get_filename_component(inputBase ${input} NAME)
|
||||
if("${inputBase}" MATCHES "^\\.")
|
||||
continue()
|
||||
endif()
|
||||
set(output "${outputDir}/${inputBase}.cpp")
|
||||
list(APPEND ${outputFiles} "${output}")
|
||||
macro(
|
||||
generate_resources
|
||||
inputDir
|
||||
outputDir
|
||||
prefix
|
||||
namespace
|
||||
outputFiles
|
||||
)
|
||||
file(GLOB inputFiles ${inputDir}/*)
|
||||
set(${outputFiles})
|
||||
foreach(input ${inputFiles})
|
||||
get_filename_component(inputBase ${input} NAME)
|
||||
if("${inputBase}" MATCHES "^\\.")
|
||||
continue()
|
||||
endif()
|
||||
set(output "${outputDir}/${inputBase}.cpp")
|
||||
list(APPEND ${outputFiles} "${output}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${output}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-Dinput=${input}"
|
||||
"-Doutput=${output}"
|
||||
"-Dprefix=${prefix}"
|
||||
"-Dnamespace=${namespace}"
|
||||
-P "${scripts_dir}/GenResource.cmake"
|
||||
MAIN_DEPENDENCY ${input}
|
||||
DEPENDS ${scripts_dir}/GenResource.cmake
|
||||
VERBATIM
|
||||
)
|
||||
endforeach()
|
||||
add_custom_command(
|
||||
OUTPUT ${output}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} "-Dinput=${input}" "-Doutput=${output}" "-Dprefix=${prefix}"
|
||||
"-Dnamespace=${namespace}" -P "${scripts_dir}/GenResource.cmake"
|
||||
MAIN_DEPENDENCY ${input}
|
||||
DEPENDS ${scripts_dir}/GenResource.cmake
|
||||
VERBATIM
|
||||
)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
macro(wpilib_link_macos_gui target)
|
||||
if (APPLE)
|
||||
set_target_properties(${target} PROPERTIES LINK_FLAGS "-framework Metal -framework QuartzCore")
|
||||
if(APPLE)
|
||||
set_target_properties(
|
||||
${target}
|
||||
PROPERTIES LINK_FLAGS "-framework Metal -framework QuartzCore"
|
||||
)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
macro(subdir_list result curdir)
|
||||
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
|
||||
set(dirlist "")
|
||||
foreach(child ${children})
|
||||
if(IS_DIRECTORY ${curdir}/${child})
|
||||
list(APPEND dirlist ${child})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${result} ${dirlist})
|
||||
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
|
||||
set(dirlist "")
|
||||
foreach(child ${children})
|
||||
if(IS_DIRECTORY ${curdir}/${child})
|
||||
list(APPEND dirlist ${child})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${result} ${dirlist})
|
||||
endmacro()
|
||||
|
||||
macro(add_all_subdirectories curdir)
|
||||
subdir_list(_SUBPROJECTS ${curdir})
|
||||
foreach(dir ${_SUBPROJECTS})
|
||||
add_subdirectory(${dir})
|
||||
endforeach()
|
||||
subdir_list(_SUBPROJECTS ${curdir})
|
||||
foreach(dir ${_SUBPROJECTS})
|
||||
add_subdirectory(${dir})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
@@ -1,23 +1,35 @@
|
||||
# Parameters: input output prefix namespace
|
||||
FILE(READ ${input} fileHex HEX)
|
||||
STRING(LENGTH "${fileHex}" fileHexSize)
|
||||
MATH(EXPR fileSize "${fileHexSize} / 2")
|
||||
file(READ ${input} fileHex HEX)
|
||||
string(LENGTH "${fileHex}" fileHexSize)
|
||||
math(EXPR fileSize "${fileHexSize} / 2")
|
||||
|
||||
GET_FILENAME_COMPONENT(inputBase ${input} NAME)
|
||||
STRING(REGEX REPLACE "[^a-zA-Z0-9]" "_" funcName "${inputBase}")
|
||||
SET(funcName "GetResource_${funcName}")
|
||||
get_filename_component(inputBase ${input} NAME)
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9]" "_" funcName "${inputBase}")
|
||||
set(funcName "GetResource_${funcName}")
|
||||
|
||||
FILE(WRITE "${output}" "#include <stddef.h>\n#include <string_view>\nextern \"C\" {\nstatic const unsigned char contents[] = {")
|
||||
file(
|
||||
WRITE
|
||||
"${output}"
|
||||
"#include <stddef.h>\n#include <string_view>\nextern \"C\" {\nstatic const unsigned char contents[] = {"
|
||||
)
|
||||
|
||||
STRING(REGEX MATCHALL ".." outputData "${fileHex}")
|
||||
STRING(REGEX REPLACE ";" ", 0x" outputData "${outputData}")
|
||||
FILE(APPEND "${output}" " 0x${outputData} };\n")
|
||||
FILE(APPEND "${output}" "const unsigned char* ${prefix}${funcName}(size_t* len) {\n *len = ${fileSize};\n return contents;\n}\n}\n")
|
||||
string(REGEX MATCHALL ".." outputData "${fileHex}")
|
||||
string(REGEX REPLACE ";" ", 0x" outputData "${outputData}")
|
||||
file(APPEND "${output}" " 0x${outputData} };\n")
|
||||
file(
|
||||
APPEND
|
||||
"${output}"
|
||||
"const unsigned char* ${prefix}${funcName}(size_t* len) {\n *len = ${fileSize};\n return contents;\n}\n}\n"
|
||||
)
|
||||
|
||||
IF(NOT namespace STREQUAL "")
|
||||
FILE(APPEND "${output}" "namespace ${namespace} {\n")
|
||||
ENDIF()
|
||||
FILE(APPEND "${output}" "std::string_view ${funcName}() {\n return std::string_view(reinterpret_cast<const char*>(contents), ${fileSize});\n}\n")
|
||||
IF(NOT namespace STREQUAL "")
|
||||
FILE(APPEND "${output}" "}\n")
|
||||
ENDIF()
|
||||
if(NOT namespace STREQUAL "")
|
||||
file(APPEND "${output}" "namespace ${namespace} {\n")
|
||||
endif()
|
||||
file(
|
||||
APPEND
|
||||
"${output}"
|
||||
"std::string_view ${funcName}() {\n return std::string_view(reinterpret_cast<const char*>(contents), ${fileSize});\n}\n"
|
||||
)
|
||||
if(NOT namespace STREQUAL "")
|
||||
file(APPEND "${output}" "}\n")
|
||||
endif()
|
||||
|
||||
@@ -190,12 +190,12 @@ struct RelayHandle {
|
||||
HAL_RelayHandle handle = 0;
|
||||
};
|
||||
|
||||
#define ASSERT_LAST_ERROR_STATUS(status, x) \
|
||||
do { \
|
||||
ASSERT_EQ(status, HAL_USE_LAST_ERROR); \
|
||||
const char* lastErrorMessageInMacro = HAL_GetLastError(&status); \
|
||||
static_cast<void>(lastErrorMessageInMacro); \
|
||||
ASSERT_EQ(status, x); \
|
||||
#define ASSERT_LAST_ERROR_STATUS(status, x) \
|
||||
do { \
|
||||
ASSERT_EQ(status, HAL_USE_LAST_ERROR); \
|
||||
[[maybe_unused]] const char* lastErrorMessageInMacro = \
|
||||
HAL_GetLastError(&status); \
|
||||
ASSERT_EQ(status, x); \
|
||||
} while (0)
|
||||
|
||||
} // namespace hlt
|
||||
|
||||
@@ -5,10 +5,9 @@ include(CompileWarnings)
|
||||
include(AddTest)
|
||||
include(LinkMacOSGUI)
|
||||
|
||||
find_package( OpenCV REQUIRED )
|
||||
find_package(OpenCV REQUIRED)
|
||||
|
||||
file(GLOB
|
||||
cscore_native_src src/main/native/cpp/*.cpp)
|
||||
file(GLOB cscore_native_src src/main/native/cpp/*.cpp)
|
||||
file(GLOB cscore_linux_src src/main/native/linux/*.cpp)
|
||||
file(GLOB cscore_osx_src src/main/native/osx/*.cpp)
|
||||
file(GLOB cscore_osx_objc_src src/main/native/objcpp/*.mm)
|
||||
@@ -18,10 +17,15 @@ add_library(cscore ${cscore_native_src})
|
||||
set_target_properties(cscore PROPERTIES DEBUG_POSTFIX "d")
|
||||
|
||||
if(NOT MSVC)
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
target_sources(cscore PRIVATE ${cscore_osx_src} ${cscore_osx_objc_src})
|
||||
target_compile_options(cscore PRIVATE "-fobjc-arc")
|
||||
set_target_properties(cscore PROPERTIES LINK_FLAGS "-framework CoreFoundation -framework AVFoundation -framework Foundation -framework CoreMedia -framework CoreVideo")
|
||||
set_target_properties(
|
||||
cscore
|
||||
PROPERTIES
|
||||
LINK_FLAGS
|
||||
"-framework CoreFoundation -framework AVFoundation -framework Foundation -framework CoreMedia -framework CoreVideo"
|
||||
)
|
||||
else()
|
||||
target_sources(cscore PRIVATE ${cscore_linux_src})
|
||||
endif()
|
||||
@@ -31,9 +35,12 @@ else()
|
||||
target_compile_definitions(cscore PRIVATE -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
target_include_directories(cscore PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/cscore>)
|
||||
target_include_directories(
|
||||
cscore
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/cscore>
|
||||
)
|
||||
target_include_directories(cscore PRIVATE src/main/native/cpp)
|
||||
wpilib_target_warnings(cscore)
|
||||
target_link_libraries(cscore PUBLIC wpinet wpiutil ${OpenCV_LIBS})
|
||||
@@ -43,15 +50,9 @@ set_property(TARGET cscore PROPERTY FOLDER "libraries")
|
||||
install(TARGETS cscore EXPORT cscore)
|
||||
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cscore")
|
||||
|
||||
if (WITH_FLAT_INSTALL)
|
||||
set (cscore_config_dir ${wpilib_dest})
|
||||
else()
|
||||
set (cscore_config_dir share/cscore)
|
||||
endif()
|
||||
|
||||
configure_file(cscore-config.cmake.in ${WPILIB_BINARY_DIR}/cscore-config.cmake )
|
||||
install(FILES ${WPILIB_BINARY_DIR}/cscore-config.cmake DESTINATION ${cscore_config_dir})
|
||||
install(EXPORT cscore DESTINATION ${cscore_config_dir})
|
||||
configure_file(cscore-config.cmake.in ${WPILIB_BINARY_DIR}/cscore-config.cmake)
|
||||
install(FILES ${WPILIB_BINARY_DIR}/cscore-config.cmake DESTINATION share/cscore)
|
||||
install(EXPORT cscore DESTINATION share/cscore)
|
||||
|
||||
subdir_list(cscore_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples")
|
||||
foreach(example ${cscore_examples})
|
||||
@@ -68,7 +69,7 @@ foreach(example ${cscore_examples})
|
||||
add_executable(cscore_${example} ${cscore_example_src})
|
||||
wpilib_target_warnings(cscore_${example})
|
||||
|
||||
if (${example} STREQUAL "usbviewer")
|
||||
if(${example} STREQUAL "usbviewer")
|
||||
wpilib_link_macos_gui(cscore_${example})
|
||||
endif()
|
||||
|
||||
@@ -78,7 +79,7 @@ foreach(example ${cscore_examples})
|
||||
endforeach()
|
||||
|
||||
# Java bindings
|
||||
if (WITH_JAVA)
|
||||
if(WITH_JAVA)
|
||||
find_package(Java REQUIRED)
|
||||
find_package(JNI REQUIRED)
|
||||
include(UseJava)
|
||||
@@ -90,36 +91,68 @@ if (WITH_JAVA)
|
||||
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/OpenCV/java/)
|
||||
endif()
|
||||
|
||||
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 NO_DEFAULT_PATH)
|
||||
find_file(OPENCV_JNI_FILE NAMES libopencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.so
|
||||
libopencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dylib
|
||||
opencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll
|
||||
PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin ${OpenCV_INSTALL_PATH}/bin/Release ${OpenCV_INSTALL_PATH}/bin/Debug ${OpenCV_INSTALL_PATH}/lib ${OpenCV_INSTALL_PATH}/lib/jni NO_DEFAULT_PATH)
|
||||
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
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
find_file(
|
||||
OPENCV_JNI_FILE
|
||||
NAMES
|
||||
libopencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.so
|
||||
libopencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dylib
|
||||
opencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll
|
||||
PATHS
|
||||
${OPENCV_JAVA_INSTALL_DIR}
|
||||
${OpenCV_INSTALL_PATH}/bin
|
||||
${OpenCV_INSTALL_PATH}/bin/Release
|
||||
${OpenCV_INSTALL_PATH}/bin/Debug
|
||||
${OpenCV_INSTALL_PATH}/lib
|
||||
${OpenCV_INSTALL_PATH}/lib/jni
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
file(GLOB
|
||||
cscore_jni_src src/main/native/cpp/jni/CameraServerJNI.cpp)
|
||||
file(GLOB cscore_jni_src src/main/native/cpp/jni/CameraServerJNI.cpp)
|
||||
|
||||
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
|
||||
set(CMAKE_JNI_TARGET true)
|
||||
|
||||
add_jar(cscore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar ${OPENCV_JAR_FILE} OUTPUT_NAME cscore GENERATE_NATIVE_HEADERS cscore_jni_headers)
|
||||
add_jar(
|
||||
cscore_jar
|
||||
${JAVA_SOURCES}
|
||||
INCLUDE_JARS wpiutil_jar ${OPENCV_JAR_FILE}
|
||||
OUTPUT_NAME cscore
|
||||
GENERATE_NATIVE_HEADERS cscore_jni_headers
|
||||
)
|
||||
|
||||
get_property(CSCORE_JAR_FILE TARGET cscore_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${CSCORE_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
install_jar(cscore_jar DESTINATION ${java_lib_dest})
|
||||
install_jar_exports(TARGETS cscore_jar FILE cscore_jar.cmake DESTINATION share/cscore)
|
||||
install(FILES ${OPENCV_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
install(FILES ${OPENCV_JNI_FILE} DESTINATION "${jni_lib_dest}")
|
||||
|
||||
foreach(cvFile ${OpenCV_LIBS})
|
||||
find_file(${cvFile}Loc NAMES ${cvFile}${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll
|
||||
PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin ${OpenCV_INSTALL_PATH}/bin/Release ${OpenCV_INSTALL_PATH}/bin/Debug ${OpenCV_INSTALL_PATH}/lib NO_DEFAULT_PATH)
|
||||
find_file(
|
||||
${cvFile}Loc
|
||||
NAMES
|
||||
${cvFile}${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll
|
||||
PATHS
|
||||
${OPENCV_JAVA_INSTALL_DIR}
|
||||
${OpenCV_INSTALL_PATH}/bin
|
||||
${OpenCV_INSTALL_PATH}/bin/Release
|
||||
${OpenCV_INSTALL_PATH}/bin/Debug
|
||||
${OpenCV_INSTALL_PATH}/lib
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
install(FILES ${${cvFile}Loc} DESTINATION "${jni_lib_dest}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set_property(TARGET cscore_jar PROPERTY FOLDER "java")
|
||||
|
||||
add_library(cscorejni ${cscore_jni_src})
|
||||
wpilib_target_warnings(cscorejni)
|
||||
target_link_libraries(cscorejni PUBLIC cscore wpiutil ${OpenCV_LIBS})
|
||||
@@ -130,10 +163,28 @@ if (WITH_JAVA)
|
||||
add_dependencies(cscorejni cscore_jar)
|
||||
|
||||
install(TARGETS cscorejni EXPORT cscorejni)
|
||||
|
||||
endif()
|
||||
|
||||
if (WITH_TESTS)
|
||||
if(WITH_JAVA_SOURCE)
|
||||
find_package(Java REQUIRED)
|
||||
include(UseJava)
|
||||
file(GLOB CSCORE_SOURCES src/main/java/edu/wpi/first/cscore/*.java)
|
||||
file(GLOB CSCORE_RAW_SOURCES src/main/java/edu/wpi/first/cscore/raw/*.java)
|
||||
add_jar(
|
||||
cscore_src_jar
|
||||
RESOURCES
|
||||
NAMESPACE "edu/wpi/first/cscore" ${CSCORE_SOURCES}
|
||||
NAMESPACE "edu/wpi/first/cscore/raw" ${CSCORE_RAW_SOURCES}
|
||||
OUTPUT_NAME cscore-sources
|
||||
)
|
||||
|
||||
get_property(CSCORE_SRC_JAR_FILE TARGET cscore_src_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${CSCORE_SRC_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
|
||||
set_property(TARGET cscore_src_jar PROPERTY FOLDER "java")
|
||||
endif()
|
||||
|
||||
if(WITH_TESTS)
|
||||
wpilib_add_test(cscore src/test/native/cpp)
|
||||
target_link_libraries(cscore_test cscore gmock)
|
||||
endif()
|
||||
|
||||
@@ -5,3 +5,6 @@ find_dependency(OpenCV)
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/cscore.cmake)
|
||||
if(@WITH_JAVA@)
|
||||
include(${SELF_DIR}/cscore_jar.cmake)
|
||||
endif()
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CameraServerCvJNI {
|
||||
|
||||
public static native void putSourceFrame(int source, long imageNativeObj);
|
||||
|
||||
public static native int createCvSink(String name);
|
||||
public static native int createCvSink(String name, int pixelFormat);
|
||||
|
||||
// public static native int createCvSinkCallback(String name,
|
||||
// void (*processFrame)(long time));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package edu.wpi.first.cscore;
|
||||
|
||||
import edu.wpi.first.cscore.raw.RawFrame;
|
||||
import edu.wpi.first.util.RawFrame;
|
||||
import edu.wpi.first.util.RuntimeLoader;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -387,10 +387,6 @@ public class CameraServerJNI {
|
||||
|
||||
public static native String[] getNetworkInterfaces();
|
||||
|
||||
public static native long allocateRawFrame();
|
||||
|
||||
public static native void freeRawFrame(long frame);
|
||||
|
||||
public static native void runMainRunLoop();
|
||||
|
||||
public static native int runMainRunLoopTimeout(double timeoutSeconds);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
package edu.wpi.first.cscore;
|
||||
|
||||
import edu.wpi.first.cscore.VideoMode.PixelFormat;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
/**
|
||||
@@ -16,9 +17,20 @@ public class CvSink extends ImageSink {
|
||||
* get each new image.
|
||||
*
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
* @param pixelFormat Source pixel format
|
||||
*/
|
||||
public CvSink(String name, PixelFormat pixelFormat) {
|
||||
super(CameraServerCvJNI.createCvSink(name, pixelFormat.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a sink for accepting OpenCV images. WaitForFrame() must be called on the created sink to
|
||||
* get each new image. Defaults to kBGR for pixelFormat
|
||||
*
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
*/
|
||||
public CvSink(String name) {
|
||||
super(CameraServerCvJNI.createCvSink(name));
|
||||
this(name, PixelFormat.kBGR);
|
||||
}
|
||||
|
||||
/// Create a sink for accepting OpenCV images in a separate thread.
|
||||
|
||||
@@ -102,7 +102,7 @@ public class VideoListener implements AutoCloseable {
|
||||
listener.accept(event);
|
||||
} catch (Throwable throwable) {
|
||||
System.err.println(
|
||||
"Unhandled exception during listener callback: " + throwable.toString());
|
||||
"Unhandled exception during listener callback: " + throwable);
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package edu.wpi.first.cscore.raw;
|
||||
|
||||
import edu.wpi.first.cscore.CameraServerJNI;
|
||||
import edu.wpi.first.cscore.ImageSink;
|
||||
import edu.wpi.first.util.RawFrame;
|
||||
|
||||
/**
|
||||
* A sink for user code to accept video frames as raw bytes.
|
||||
|
||||
@@ -7,6 +7,7 @@ package edu.wpi.first.cscore.raw;
|
||||
import edu.wpi.first.cscore.CameraServerJNI;
|
||||
import edu.wpi.first.cscore.ImageSource;
|
||||
import edu.wpi.first.cscore.VideoMode;
|
||||
import edu.wpi.first.util.RawFrame;
|
||||
|
||||
/**
|
||||
* A source for user code to provide video frames as raw bytes.
|
||||
|
||||
@@ -19,16 +19,18 @@
|
||||
using namespace cs;
|
||||
|
||||
CvSinkImpl::CvSinkImpl(std::string_view name, wpi::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry)
|
||||
: SinkImpl{name, logger, notifier, telemetry} {
|
||||
Notifier& notifier, Telemetry& telemetry,
|
||||
VideoMode::PixelFormat pixelFormat)
|
||||
: SinkImpl{name, logger, notifier, telemetry}, m_pixelFormat{pixelFormat} {
|
||||
m_active = true;
|
||||
// m_thread = std::thread(&CvSinkImpl::ThreadMain, this);
|
||||
}
|
||||
|
||||
CvSinkImpl::CvSinkImpl(std::string_view name, wpi::Logger& logger,
|
||||
Notifier& notifier, Telemetry& telemetry,
|
||||
VideoMode::PixelFormat pixelFormat,
|
||||
std::function<void(uint64_t time)> processFrame)
|
||||
: SinkImpl{name, logger, notifier, telemetry} {}
|
||||
: SinkImpl{name, logger, notifier, telemetry}, m_pixelFormat{pixelFormat} {}
|
||||
|
||||
CvSinkImpl::~CvSinkImpl() {
|
||||
Stop();
|
||||
@@ -65,7 +67,7 @@ uint64_t CvSinkImpl::GrabFrame(cv::Mat& image) {
|
||||
return 0; // signal error
|
||||
}
|
||||
|
||||
if (!frame.GetCv(image)) {
|
||||
if (!frame.GetCv(image, m_pixelFormat)) {
|
||||
// Shouldn't happen, but just in case...
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
return 0;
|
||||
@@ -91,7 +93,7 @@ uint64_t CvSinkImpl::GrabFrame(cv::Mat& image, double timeout) {
|
||||
return 0; // signal error
|
||||
}
|
||||
|
||||
if (!frame.GetCv(image)) {
|
||||
if (!frame.GetCv(image, m_pixelFormat)) {
|
||||
// Shouldn't happen, but just in case...
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||
return 0;
|
||||
@@ -127,20 +129,23 @@ void CvSinkImpl::ThreadMain() {
|
||||
|
||||
namespace cs {
|
||||
|
||||
CS_Sink CreateCvSink(std::string_view name, CS_Status* status) {
|
||||
CS_Sink CreateCvSink(std::string_view name, VideoMode::PixelFormat pixelFormat,
|
||||
CS_Status* status) {
|
||||
auto& inst = Instance::GetInstance();
|
||||
return inst.CreateSink(
|
||||
CS_SINK_CV, std::make_shared<CvSinkImpl>(name, inst.logger, inst.notifier,
|
||||
inst.telemetry));
|
||||
inst.telemetry, pixelFormat));
|
||||
}
|
||||
|
||||
CS_Sink CreateCvSinkCallback(std::string_view name,
|
||||
VideoMode::PixelFormat pixelFormat,
|
||||
std::function<void(uint64_t time)> processFrame,
|
||||
CS_Status* status) {
|
||||
auto& inst = Instance::GetInstance();
|
||||
return inst.CreateSink(
|
||||
CS_SINK_CV, std::make_shared<CvSinkImpl>(name, inst.logger, inst.notifier,
|
||||
inst.telemetry, processFrame));
|
||||
CS_SINK_CV,
|
||||
std::make_shared<CvSinkImpl>(name, inst.logger, inst.notifier,
|
||||
inst.telemetry, pixelFormat, processFrame));
|
||||
}
|
||||
|
||||
static constexpr unsigned SinkMask = CS_SINK_CV | CS_SINK_RAW;
|
||||
@@ -206,15 +211,19 @@ void SetSinkEnabled(CS_Sink sink, bool enabled, CS_Status* status) {
|
||||
|
||||
extern "C" {
|
||||
|
||||
CS_Sink CS_CreateCvSink(const char* name, CS_Status* status) {
|
||||
return cs::CreateCvSink(name, status);
|
||||
CS_Sink CS_CreateCvSink(const char* name, enum WPI_PixelFormat pixelFormat,
|
||||
CS_Status* status) {
|
||||
return cs::CreateCvSink(
|
||||
name, static_cast<VideoMode::PixelFormat>(pixelFormat), status);
|
||||
}
|
||||
|
||||
CS_Sink CS_CreateCvSinkCallback(const char* name, void* data,
|
||||
CS_Sink CS_CreateCvSinkCallback(const char* name,
|
||||
enum WPI_PixelFormat pixelFormat, void* data,
|
||||
void (*processFrame)(void* data, uint64_t time),
|
||||
CS_Status* status) {
|
||||
return cs::CreateCvSinkCallback(
|
||||
name, [=](uint64_t time) { processFrame(data, time); }, status);
|
||||
name, static_cast<VideoMode::PixelFormat>(pixelFormat),
|
||||
[=](uint64_t time) { processFrame(data, time); }, status);
|
||||
}
|
||||
|
||||
void CS_SetSinkDescription(CS_Sink sink, const char* description,
|
||||
|
||||
@@ -25,9 +25,9 @@ class SourceImpl;
|
||||
class CvSinkImpl : public SinkImpl {
|
||||
public:
|
||||
CvSinkImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry);
|
||||
Telemetry& telemetry, VideoMode::PixelFormat pixelFormat);
|
||||
CvSinkImpl(std::string_view name, wpi::Logger& logger, Notifier& notifier,
|
||||
Telemetry& telemetry,
|
||||
Telemetry& telemetry, VideoMode::PixelFormat pixelFormat,
|
||||
std::function<void(uint64_t time)> processFrame);
|
||||
~CvSinkImpl() override;
|
||||
|
||||
@@ -42,6 +42,7 @@ class CvSinkImpl : public SinkImpl {
|
||||
std::atomic_bool m_active; // set to false to terminate threads
|
||||
std::thread m_thread;
|
||||
std::function<void(uint64_t time)> m_processFrame;
|
||||
VideoMode::PixelFormat m_pixelFormat;
|
||||
};
|
||||
|
||||
} // namespace cs
|
||||
|
||||
@@ -709,8 +709,9 @@ Image* Frame::GetImageImpl(int width, int height,
|
||||
return ConvertImpl(cur, pixelFormat, requiredJpegQuality, defaultJpegQuality);
|
||||
}
|
||||
|
||||
bool Frame::GetCv(cv::Mat& image, int width, int height) {
|
||||
Image* rawImage = GetImage(width, height, VideoMode::kBGR);
|
||||
bool Frame::GetCv(cv::Mat& image, int width, int height,
|
||||
VideoMode::PixelFormat pixelFormat) {
|
||||
Image* rawImage = GetImage(width, height, pixelFormat);
|
||||
if (!rawImage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -219,10 +219,11 @@ class Frame {
|
||||
defaultQuality);
|
||||
}
|
||||
|
||||
bool GetCv(cv::Mat& image) {
|
||||
return GetCv(image, GetOriginalWidth(), GetOriginalHeight());
|
||||
bool GetCv(cv::Mat& image, VideoMode::PixelFormat pixelFormat) {
|
||||
return GetCv(image, GetOriginalWidth(), GetOriginalHeight(), pixelFormat);
|
||||
}
|
||||
bool GetCv(cv::Mat& image, int width, int height);
|
||||
bool GetCv(cv::Mat& image, int width, int height,
|
||||
VideoMode::PixelFormat pixelFormat);
|
||||
|
||||
private:
|
||||
Image* ConvertImpl(Image* image, VideoMode::PixelFormat pixelFormat,
|
||||
|
||||
@@ -40,7 +40,7 @@ void RawSinkImpl::Stop() {
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t RawSinkImpl::GrabFrame(CS_RawFrame& image) {
|
||||
uint64_t RawSinkImpl::GrabFrame(WPI_RawFrame& image) {
|
||||
SetEnabled(true);
|
||||
|
||||
auto source = GetSource();
|
||||
@@ -60,7 +60,7 @@ uint64_t RawSinkImpl::GrabFrame(CS_RawFrame& image) {
|
||||
return GrabFrameImpl(image, frame);
|
||||
}
|
||||
|
||||
uint64_t RawSinkImpl::GrabFrame(CS_RawFrame& image, double timeout) {
|
||||
uint64_t RawSinkImpl::GrabFrame(WPI_RawFrame& image, double timeout) {
|
||||
SetEnabled(true);
|
||||
|
||||
auto source = GetSource();
|
||||
@@ -80,11 +80,11 @@ uint64_t RawSinkImpl::GrabFrame(CS_RawFrame& image, double timeout) {
|
||||
return GrabFrameImpl(image, frame);
|
||||
}
|
||||
|
||||
uint64_t RawSinkImpl::GrabFrameImpl(CS_RawFrame& rawFrame,
|
||||
uint64_t RawSinkImpl::GrabFrameImpl(WPI_RawFrame& rawFrame,
|
||||
Frame& incomingFrame) {
|
||||
Image* newImage = nullptr;
|
||||
|
||||
if (rawFrame.pixelFormat == CS_PixelFormat::CS_PIXFMT_UNKNOWN) {
|
||||
if (rawFrame.pixelFormat == WPI_PixelFormat::WPI_PIXFMT_UNKNOWN) {
|
||||
// Always get incoming image directly on unknown
|
||||
newImage = incomingFrame.GetExistingImage(0);
|
||||
} else {
|
||||
@@ -106,7 +106,7 @@ uint64_t RawSinkImpl::GrabFrameImpl(CS_RawFrame& rawFrame,
|
||||
return 0;
|
||||
}
|
||||
|
||||
CS_AllocateRawFrameData(&rawFrame, newImage->size());
|
||||
WPI_AllocateRawFrameData(&rawFrame, newImage->size());
|
||||
rawFrame.height = newImage->height;
|
||||
rawFrame.width = newImage->width;
|
||||
rawFrame.pixelFormat = newImage->pixelFormat;
|
||||
@@ -159,7 +159,7 @@ CS_Sink CreateRawSinkCallback(std::string_view name,
|
||||
inst.telemetry, processFrame));
|
||||
}
|
||||
|
||||
uint64_t GrabSinkFrame(CS_Sink sink, CS_RawFrame& image, CS_Status* status) {
|
||||
uint64_t GrabSinkFrame(CS_Sink sink, WPI_RawFrame& image, CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSink(sink);
|
||||
if (!data || data->kind != CS_SINK_RAW) {
|
||||
*status = CS_INVALID_HANDLE;
|
||||
@@ -168,7 +168,7 @@ uint64_t GrabSinkFrame(CS_Sink sink, CS_RawFrame& image, CS_Status* status) {
|
||||
return static_cast<RawSinkImpl&>(*data->sink).GrabFrame(image);
|
||||
}
|
||||
|
||||
uint64_t GrabSinkFrameTimeout(CS_Sink sink, CS_RawFrame& image, double timeout,
|
||||
uint64_t GrabSinkFrameTimeout(CS_Sink sink, WPI_RawFrame& image, double timeout,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSink(sink);
|
||||
if (!data || data->kind != CS_SINK_RAW) {
|
||||
@@ -192,12 +192,12 @@ CS_Sink CS_CreateRawSinkCallback(const char* name, void* data,
|
||||
name, [=](uint64_t time) { processFrame(data, time); }, status);
|
||||
}
|
||||
|
||||
uint64_t CS_GrabRawSinkFrame(CS_Sink sink, struct CS_RawFrame* image,
|
||||
uint64_t CS_GrabRawSinkFrame(CS_Sink sink, struct WPI_RawFrame* image,
|
||||
CS_Status* status) {
|
||||
return cs::GrabSinkFrame(sink, *image, status);
|
||||
}
|
||||
|
||||
uint64_t CS_GrabRawSinkFrameTimeout(CS_Sink sink, struct CS_RawFrame* image,
|
||||
uint64_t CS_GrabRawSinkFrameTimeout(CS_Sink sink, struct WPI_RawFrame* image,
|
||||
double timeout, CS_Status* status) {
|
||||
return cs::GrabSinkFrameTimeout(sink, *image, timeout, status);
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ class RawSinkImpl : public SinkImpl {
|
||||
|
||||
void Stop();
|
||||
|
||||
uint64_t GrabFrame(CS_RawFrame& frame);
|
||||
uint64_t GrabFrame(CS_RawFrame& frame, double timeout);
|
||||
uint64_t GrabFrame(WPI_RawFrame& frame);
|
||||
uint64_t GrabFrame(WPI_RawFrame& frame, double timeout);
|
||||
|
||||
private:
|
||||
void ThreadMain();
|
||||
|
||||
uint64_t GrabFrameImpl(CS_RawFrame& rawFrame, Frame& incomingFrame);
|
||||
uint64_t GrabFrameImpl(WPI_RawFrame& rawFrame, Frame& incomingFrame);
|
||||
|
||||
std::atomic_bool m_active; // set to false to terminate threads
|
||||
std::thread m_thread;
|
||||
|
||||
@@ -21,7 +21,7 @@ RawSourceImpl::RawSourceImpl(std::string_view name, wpi::Logger& logger,
|
||||
|
||||
RawSourceImpl::~RawSourceImpl() = default;
|
||||
|
||||
void RawSourceImpl::PutFrame(const CS_RawFrame& image) {
|
||||
void RawSourceImpl::PutFrame(const WPI_RawFrame& image) {
|
||||
int type;
|
||||
switch (image.pixelFormat) {
|
||||
case VideoMode::kYUYV:
|
||||
@@ -57,7 +57,7 @@ CS_Source CreateRawSource(std::string_view name, const VideoMode& mode,
|
||||
inst.telemetry, mode));
|
||||
}
|
||||
|
||||
void PutSourceFrame(CS_Source source, const CS_RawFrame& image,
|
||||
void PutSourceFrame(CS_Source source, const WPI_RawFrame& image,
|
||||
CS_Status* status) {
|
||||
auto data = Instance::GetInstance().GetSource(source);
|
||||
if (!data || data->kind != CS_SOURCE_RAW) {
|
||||
@@ -75,7 +75,7 @@ CS_Source CS_CreateRawSource(const char* name, const CS_VideoMode* mode,
|
||||
status);
|
||||
}
|
||||
|
||||
void CS_PutRawSourceFrame(CS_Source source, const struct CS_RawFrame* image,
|
||||
void CS_PutRawSourceFrame(CS_Source source, const struct WPI_RawFrame* image,
|
||||
CS_Status* status) {
|
||||
return cs::PutSourceFrame(source, *image, status);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class RawSourceImpl : public ConfigurableSourceImpl {
|
||||
~RawSourceImpl() override;
|
||||
|
||||
// Raw-specific functions
|
||||
void PutFrame(const CS_RawFrame& image);
|
||||
void PutFrame(const WPI_RawFrame& image);
|
||||
|
||||
private:
|
||||
std::atomic_bool m_connected{true};
|
||||
|
||||
@@ -181,7 +181,7 @@ CS_Bool CS_SetSourceVideoMode(CS_Source source, const CS_VideoMode* mode,
|
||||
}
|
||||
|
||||
CS_Bool CS_SetSourceVideoModeDiscrete(CS_Source source,
|
||||
enum CS_PixelFormat pixelFormat,
|
||||
enum WPI_PixelFormat pixelFormat,
|
||||
int width, int height, int fps,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourceVideoMode(
|
||||
@@ -193,7 +193,7 @@ CS_Bool CS_SetSourceVideoModeDiscrete(CS_Source source,
|
||||
}
|
||||
|
||||
CS_Bool CS_SetSourcePixelFormat(CS_Source source,
|
||||
enum CS_PixelFormat pixelFormat,
|
||||
enum WPI_PixelFormat pixelFormat,
|
||||
CS_Status* status) {
|
||||
return cs::SetSourcePixelFormat(
|
||||
source,
|
||||
@@ -541,25 +541,4 @@ void CS_FreeNetworkInterfaces(char** interfaces, int count) {
|
||||
std::free(interfaces);
|
||||
}
|
||||
|
||||
void CS_AllocateRawFrameData(CS_RawFrame* frame, int requestedSize) {
|
||||
if (frame->dataLength >= requestedSize) {
|
||||
return;
|
||||
}
|
||||
if (frame->data) {
|
||||
frame->data =
|
||||
static_cast<char*>(wpi::safe_realloc(frame->data, requestedSize));
|
||||
} else {
|
||||
frame->data = static_cast<char*>(wpi::safe_malloc(requestedSize));
|
||||
}
|
||||
frame->dataLength = requestedSize;
|
||||
}
|
||||
|
||||
void CS_FreeRawFrameData(CS_RawFrame* frame) {
|
||||
if (frame->data) {
|
||||
std::free(frame->data);
|
||||
frame->data = nullptr;
|
||||
frame->dataLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/jni_util.h>
|
||||
|
||||
#include "cscore_cpp.h"
|
||||
#include "cscore_cv.h"
|
||||
#include "cscore_raw.h"
|
||||
#include "cscore_runloop.h"
|
||||
@@ -43,8 +42,7 @@ static JNIEnv* listenerEnv = nullptr;
|
||||
static const JClassInit classes[] = {
|
||||
{"edu/wpi/first/cscore/UsbCameraInfo", &usbCameraInfoCls},
|
||||
{"edu/wpi/first/cscore/VideoMode", &videoModeCls},
|
||||
{"edu/wpi/first/cscore/VideoEvent", &videoEventCls},
|
||||
{"edu/wpi/first/cscore/raw/RawFrame", &rawFrameCls}};
|
||||
{"edu/wpi/first/cscore/VideoEvent", &videoEventCls}};
|
||||
|
||||
static const JExceptionInit exceptions[] = {
|
||||
{"edu/wpi/first/cscore/VideoException", &videoEx},
|
||||
@@ -1233,7 +1231,7 @@ Java_edu_wpi_first_cscore_CameraServerJNI_putRawSourceFrameBB
|
||||
(JNIEnv* env, jclass, jint source, jobject byteBuffer, jint width,
|
||||
jint height, jint pixelFormat, jint totalData)
|
||||
{
|
||||
CS_RawFrame rawFrame;
|
||||
WPI_RawFrame rawFrame;
|
||||
rawFrame.data =
|
||||
reinterpret_cast<char*>(env->GetDirectBufferAddress(byteBuffer));
|
||||
rawFrame.totalData = totalData;
|
||||
@@ -1255,7 +1253,7 @@ Java_edu_wpi_first_cscore_CameraServerJNI_putRawSourceFrame
|
||||
(JNIEnv* env, jclass, jint source, jlong ptr, jint width, jint height,
|
||||
jint pixelFormat, jint totalData)
|
||||
{
|
||||
CS_RawFrame rawFrame;
|
||||
WPI_RawFrame rawFrame;
|
||||
rawFrame.data = reinterpret_cast<char*>(static_cast<intptr_t>(ptr));
|
||||
rawFrame.totalData = totalData;
|
||||
rawFrame.pixelFormat = pixelFormat;
|
||||
@@ -1392,18 +1390,20 @@ Java_edu_wpi_first_cscore_CameraServerJNI_createMjpegServer
|
||||
/*
|
||||
* Class: edu_wpi_first_cscore_CameraServerCvJNI
|
||||
* Method: createCvSink
|
||||
* Signature: (Ljava/lang/String;)I
|
||||
* Signature: (Ljava/lang/String;I)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_edu_wpi_first_cscore_CameraServerCvJNI_createCvSink
|
||||
(JNIEnv* env, jclass, jstring name)
|
||||
(JNIEnv* env, jclass, jstring name, jint pixelFormat)
|
||||
{
|
||||
if (!name) {
|
||||
nullPointerEx.Throw(env, "name cannot be null");
|
||||
return 0;
|
||||
}
|
||||
CS_Status status = 0;
|
||||
auto val = cs::CreateCvSink(JStringRef{env, name}.str(), &status);
|
||||
auto val = cs::CreateCvSink(
|
||||
JStringRef{env, name}.str(),
|
||||
static_cast<cs::VideoMode::PixelFormat>(pixelFormat), &status);
|
||||
CheckStatus(env, status);
|
||||
return val;
|
||||
}
|
||||
@@ -1723,7 +1723,7 @@ Java_edu_wpi_first_cscore_CameraServerCvJNI_grabSinkFrameTimeout
|
||||
|
||||
static void SetRawFrameData(JNIEnv* env, jobject rawFrameObj,
|
||||
jobject byteBuffer, bool didChangeDataPtr,
|
||||
const CS_RawFrame& frame) {
|
||||
const WPI_RawFrame& frame) {
|
||||
static jmethodID setMethod =
|
||||
env->GetMethodID(rawFrameCls, "setData", "(Ljava/nio/ByteBuffer;JIIII)V");
|
||||
jlong framePtr = static_cast<jlong>(reinterpret_cast<intptr_t>(frame.data));
|
||||
@@ -1748,8 +1748,8 @@ Java_edu_wpi_first_cscore_CameraServerJNI_grabRawSinkFrameImpl
|
||||
(JNIEnv* env, jclass, jint sink, jobject rawFrameObj, jlong rawFramePtr,
|
||||
jobject byteBuffer, jint width, jint height, jint pixelFormat)
|
||||
{
|
||||
CS_RawFrame* ptr =
|
||||
reinterpret_cast<CS_RawFrame*>(static_cast<intptr_t>(rawFramePtr));
|
||||
WPI_RawFrame* ptr =
|
||||
reinterpret_cast<WPI_RawFrame*>(static_cast<intptr_t>(rawFramePtr));
|
||||
auto origDataPtr = ptr->data;
|
||||
ptr->width = width;
|
||||
ptr->height = height;
|
||||
@@ -1774,8 +1774,8 @@ Java_edu_wpi_first_cscore_CameraServerJNI_grabRawSinkFrameTimeoutImpl
|
||||
jobject byteBuffer, jint width, jint height, jint pixelFormat,
|
||||
jdouble timeout)
|
||||
{
|
||||
CS_RawFrame* ptr =
|
||||
reinterpret_cast<CS_RawFrame*>(static_cast<intptr_t>(rawFramePtr));
|
||||
WPI_RawFrame* ptr =
|
||||
reinterpret_cast<WPI_RawFrame*>(static_cast<intptr_t>(rawFramePtr));
|
||||
auto origDataPtr = ptr->data;
|
||||
ptr->width = width;
|
||||
ptr->height = height;
|
||||
@@ -2199,34 +2199,6 @@ Java_edu_wpi_first_cscore_CameraServerJNI_setLogger
|
||||
minLevel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_cscore_CameraServerJNI
|
||||
* Method: allocateRawFrame
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_edu_wpi_first_cscore_CameraServerJNI_allocateRawFrame
|
||||
(JNIEnv*, jclass)
|
||||
{
|
||||
cs::RawFrame* rawFrame = new cs::RawFrame{};
|
||||
intptr_t rawFrameIntPtr = reinterpret_cast<intptr_t>(rawFrame);
|
||||
return static_cast<jlong>(rawFrameIntPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_cscore_CameraServerJNI
|
||||
* Method: freeRawFrame
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_edu_wpi_first_cscore_CameraServerJNI_freeRawFrame
|
||||
(JNIEnv*, jclass, jlong rawFrame)
|
||||
{
|
||||
cs::RawFrame* ptr =
|
||||
reinterpret_cast<cs::RawFrame*>(static_cast<intptr_t>(rawFrame));
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: edu_wpi_first_cscore_CameraServerJNI
|
||||
* Method: runMainRunLoop
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <wpi/RawFrame.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstddef>
|
||||
#else
|
||||
@@ -84,20 +86,6 @@ enum CS_LogLevel {
|
||||
CS_LOG_DEBUG4 = 6
|
||||
};
|
||||
|
||||
/**
|
||||
* Pixel formats
|
||||
*/
|
||||
enum CS_PixelFormat {
|
||||
CS_PIXFMT_UNKNOWN = 0,
|
||||
CS_PIXFMT_MJPEG,
|
||||
CS_PIXFMT_YUYV,
|
||||
CS_PIXFMT_RGB565,
|
||||
CS_PIXFMT_BGR,
|
||||
CS_PIXFMT_GRAY,
|
||||
CS_PIXFMT_Y16,
|
||||
CS_PIXFMT_UYVY
|
||||
};
|
||||
|
||||
/**
|
||||
* Video mode
|
||||
*/
|
||||
@@ -302,11 +290,11 @@ void CS_GetSourceVideoMode(CS_Source source, CS_VideoMode* mode,
|
||||
CS_Bool CS_SetSourceVideoMode(CS_Source source, const CS_VideoMode* mode,
|
||||
CS_Status* status);
|
||||
CS_Bool CS_SetSourceVideoModeDiscrete(CS_Source source,
|
||||
enum CS_PixelFormat pixelFormat,
|
||||
enum WPI_PixelFormat pixelFormat,
|
||||
int width, int height, int fps,
|
||||
CS_Status* status);
|
||||
CS_Bool CS_SetSourcePixelFormat(CS_Source source,
|
||||
enum CS_PixelFormat pixelFormat,
|
||||
enum WPI_PixelFormat pixelFormat,
|
||||
CS_Status* status);
|
||||
CS_Bool CS_SetSourceResolution(CS_Source source, int width, int height,
|
||||
CS_Status* status);
|
||||
@@ -382,8 +370,10 @@ void CS_SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
|
||||
*/
|
||||
CS_Sink CS_CreateMjpegServer(const char* name, const char* listenAddress,
|
||||
int port, CS_Status* status);
|
||||
CS_Sink CS_CreateCvSink(const char* name, CS_Status* status);
|
||||
CS_Sink CS_CreateCvSinkCallback(const char* name, void* data,
|
||||
CS_Sink CS_CreateCvSink(const char* name, enum WPI_PixelFormat pixelFormat,
|
||||
CS_Status* status);
|
||||
CS_Sink CS_CreateCvSinkCallback(const char* name,
|
||||
enum WPI_PixelFormat pixelFormat, void* data,
|
||||
void (*processFrame)(void* data, uint64_t time),
|
||||
CS_Status* status);
|
||||
/** @} */
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <wpi/RawFrame.h>
|
||||
#include <wpi/SmallVector.h>
|
||||
#include <wpi/json_fwd.h>
|
||||
|
||||
@@ -60,14 +61,14 @@ struct UsbCameraInfo {
|
||||
*/
|
||||
struct VideoMode : public CS_VideoMode {
|
||||
enum PixelFormat {
|
||||
kUnknown = CS_PIXFMT_UNKNOWN,
|
||||
kMJPEG = CS_PIXFMT_MJPEG,
|
||||
kYUYV = CS_PIXFMT_YUYV,
|
||||
kRGB565 = CS_PIXFMT_RGB565,
|
||||
kBGR = CS_PIXFMT_BGR,
|
||||
kGray = CS_PIXFMT_GRAY,
|
||||
kY16 = CS_PIXFMT_Y16,
|
||||
kUYVY = CS_PIXFMT_UYVY
|
||||
kUnknown = WPI_PIXFMT_UNKNOWN,
|
||||
kMJPEG = WPI_PIXFMT_MJPEG,
|
||||
kYUYV = WPI_PIXFMT_YUYV,
|
||||
kRGB565 = WPI_PIXFMT_RGB565,
|
||||
kBGR = WPI_PIXFMT_BGR,
|
||||
kGray = WPI_PIXFMT_GRAY,
|
||||
kY16 = WPI_PIXFMT_Y16,
|
||||
kUYVY = WPI_PIXFMT_UYVY
|
||||
};
|
||||
VideoMode() {
|
||||
pixelFormat = 0;
|
||||
@@ -316,8 +317,10 @@ void SetSourceEnumPropertyChoices(CS_Source source, CS_Property property,
|
||||
*/
|
||||
CS_Sink CreateMjpegServer(std::string_view name, std::string_view listenAddress,
|
||||
int port, CS_Status* status);
|
||||
CS_Sink CreateCvSink(std::string_view name, CS_Status* status);
|
||||
CS_Sink CreateCvSink(std::string_view name, VideoMode::PixelFormat pixelFormat,
|
||||
CS_Status* status);
|
||||
CS_Sink CreateCvSinkCallback(std::string_view name,
|
||||
VideoMode::PixelFormat pixelFormat,
|
||||
std::function<void(uint64_t time)> processFrame,
|
||||
CS_Status* status);
|
||||
|
||||
|
||||
@@ -127,8 +127,10 @@ class CvSink : public ImageSink {
|
||||
* image.
|
||||
*
|
||||
* @param name Source name (arbitrary unique identifier)
|
||||
* @param pixelFormat Source pixel format
|
||||
*/
|
||||
explicit CvSink(std::string_view name);
|
||||
explicit CvSink(std::string_view name, VideoMode::PixelFormat pixelFormat =
|
||||
VideoMode::PixelFormat::kBGR);
|
||||
|
||||
/**
|
||||
* Create a sink for accepting OpenCV images in a separate thread.
|
||||
@@ -141,9 +143,10 @@ class CvSink : public ImageSink {
|
||||
* time=0 if an error occurred. processFrame should call GetImage()
|
||||
* or GetError() as needed, but should not call (except in very
|
||||
* unusual circumstances) WaitForImage().
|
||||
* @param pixelFormat Source pixel format
|
||||
*/
|
||||
CvSink(std::string_view name,
|
||||
std::function<void(uint64_t time)> processFrame);
|
||||
CvSink(std::string_view name, std::function<void(uint64_t time)> processFrame,
|
||||
VideoMode::PixelFormat pixelFormat = VideoMode::PixelFormat::kBGR);
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image.
|
||||
@@ -184,13 +187,15 @@ inline void CvSource::PutFrame(cv::Mat& image) {
|
||||
PutSourceFrame(m_handle, image, &m_status);
|
||||
}
|
||||
|
||||
inline CvSink::CvSink(std::string_view name) {
|
||||
m_handle = CreateCvSink(name, &m_status);
|
||||
inline CvSink::CvSink(std::string_view name,
|
||||
VideoMode::PixelFormat pixelFormat) {
|
||||
m_handle = CreateCvSink(name, pixelFormat, &m_status);
|
||||
}
|
||||
|
||||
inline CvSink::CvSink(std::string_view name,
|
||||
std::function<void(uint64_t time)> processFrame) {
|
||||
m_handle = CreateCvSinkCallback(name, processFrame, &m_status);
|
||||
std::function<void(uint64_t time)> processFrame,
|
||||
VideoMode::PixelFormat pixelFormat) {
|
||||
m_handle = CreateCvSinkCallback(name, pixelFormat, processFrame, &m_status);
|
||||
}
|
||||
|
||||
inline uint64_t CvSink::GrabFrame(cv::Mat& image, double timeout) const {
|
||||
|
||||
@@ -9,36 +9,23 @@
|
||||
|
||||
#include "cscore_c.h"
|
||||
|
||||
// NOLINTBEGIN
|
||||
#ifdef __cplusplus
|
||||
#include "cscore_oo.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Raw Frame
|
||||
*/
|
||||
typedef struct CS_RawFrame { // NOLINT
|
||||
char* data;
|
||||
int dataLength;
|
||||
int pixelFormat;
|
||||
int width;
|
||||
int height;
|
||||
int totalData;
|
||||
} CS_RawFrame;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
// NOLINTEND
|
||||
|
||||
/**
|
||||
* @defgroup cscore_raw_cfunc Raw Image Functions
|
||||
* @{
|
||||
*/
|
||||
void CS_AllocateRawFrameData(CS_RawFrame* frame, int requestedSize);
|
||||
void CS_FreeRawFrameData(CS_RawFrame* frame);
|
||||
|
||||
uint64_t CS_GrabRawSinkFrame(CS_Sink sink, struct CS_RawFrame* rawImage,
|
||||
uint64_t CS_GrabRawSinkFrame(CS_Sink sink, struct WPI_RawFrame* rawImage,
|
||||
CS_Status* status);
|
||||
uint64_t CS_GrabRawSinkFrameTimeout(CS_Sink sink, struct CS_RawFrame* rawImage,
|
||||
uint64_t CS_GrabRawSinkFrameTimeout(CS_Sink sink, struct WPI_RawFrame* rawImage,
|
||||
double timeout, CS_Status* status);
|
||||
|
||||
CS_Sink CS_CreateRawSink(const char* name, CS_Status* status);
|
||||
@@ -48,7 +35,7 @@ CS_Sink CS_CreateRawSinkCallback(const char* name, void* data,
|
||||
uint64_t time),
|
||||
CS_Status* status);
|
||||
|
||||
void CS_PutRawSourceFrame(CS_Source source, const struct CS_RawFrame* image,
|
||||
void CS_PutRawSourceFrame(CS_Source source, const struct WPI_RawFrame* image,
|
||||
CS_Status* status);
|
||||
|
||||
CS_Source CS_CreateRawSource(const char* name, const CS_VideoMode* mode,
|
||||
@@ -62,19 +49,6 @@ CS_Source CS_CreateRawSource(const char* name, const CS_VideoMode* mode,
|
||||
#ifdef __cplusplus
|
||||
namespace cs {
|
||||
|
||||
struct RawFrame : public CS_RawFrame {
|
||||
RawFrame() {
|
||||
data = nullptr;
|
||||
dataLength = 0;
|
||||
pixelFormat = CS_PIXFMT_UNKNOWN;
|
||||
width = 0;
|
||||
height = 0;
|
||||
totalData = 0;
|
||||
}
|
||||
|
||||
~RawFrame() { CS_FreeRawFrameData(this); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @defgroup cscore_raw_func Raw Image Functions
|
||||
* @{
|
||||
@@ -88,10 +62,10 @@ CS_Sink CreateRawSinkCallback(std::string_view name,
|
||||
std::function<void(uint64_t time)> processFrame,
|
||||
CS_Status* status);
|
||||
|
||||
void PutSourceFrame(CS_Source source, const CS_RawFrame& image,
|
||||
void PutSourceFrame(CS_Source source, const WPI_RawFrame& image,
|
||||
CS_Status* status);
|
||||
uint64_t GrabSinkFrame(CS_Sink sink, CS_RawFrame& image, CS_Status* status);
|
||||
uint64_t GrabSinkFrameTimeout(CS_Sink sink, CS_RawFrame& image, double timeout,
|
||||
uint64_t GrabSinkFrame(CS_Sink sink, WPI_RawFrame& image, CS_Status* status);
|
||||
uint64_t GrabSinkFrameTimeout(CS_Sink sink, WPI_RawFrame& image, double timeout,
|
||||
CS_Status* status);
|
||||
|
||||
/**
|
||||
@@ -129,7 +103,7 @@ class RawSource : public ImageSource {
|
||||
*
|
||||
* @param image raw frame image
|
||||
*/
|
||||
void PutFrame(RawFrame& image);
|
||||
void PutFrame(wpi::RawFrame& image);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -177,7 +151,7 @@ class RawSink : public ImageSink {
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
uint64_t GrabFrame(RawFrame& image, double timeout = 0.225) const;
|
||||
uint64_t GrabFrame(wpi::RawFrame& image, double timeout = 0.225) const;
|
||||
|
||||
/**
|
||||
* Wait for the next frame and get the image. May block forever.
|
||||
@@ -188,7 +162,7 @@ class RawSink : public ImageSink {
|
||||
* and is in 1 us increments.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
uint64_t GrabFrameNoTimeout(RawFrame& image) const;
|
||||
uint64_t GrabFrameNoTimeout(wpi::RawFrame& image) const;
|
||||
};
|
||||
|
||||
inline RawSource::RawSource(std::string_view name, const VideoMode& mode) {
|
||||
@@ -202,7 +176,7 @@ inline RawSource::RawSource(std::string_view name,
|
||||
CreateRawSource(name, VideoMode{format, width, height, fps}, &m_status);
|
||||
}
|
||||
|
||||
inline void RawSource::PutFrame(RawFrame& image) {
|
||||
inline void RawSource::PutFrame(wpi::RawFrame& image) {
|
||||
m_status = 0;
|
||||
PutSourceFrame(m_handle, image, &m_status);
|
||||
}
|
||||
@@ -216,12 +190,12 @@ inline RawSink::RawSink(std::string_view name,
|
||||
m_handle = CreateRawSinkCallback(name, processFrame, &m_status);
|
||||
}
|
||||
|
||||
inline uint64_t RawSink::GrabFrame(RawFrame& image, double timeout) const {
|
||||
inline uint64_t RawSink::GrabFrame(wpi::RawFrame& image, double timeout) const {
|
||||
m_status = 0;
|
||||
return GrabSinkFrameTimeout(m_handle, image, timeout, &m_status);
|
||||
}
|
||||
|
||||
inline uint64_t RawSink::GrabFrameNoTimeout(RawFrame& image) const {
|
||||
inline uint64_t RawSink::GrabFrameNoTimeout(wpi::RawFrame& image) const {
|
||||
m_status = 0;
|
||||
return GrabSinkFrame(m_handle, image, &m_status);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class RawCvSource : public RawSource {
|
||||
void PutFrame(cv::Mat& image);
|
||||
|
||||
private:
|
||||
RawFrame rawFrame;
|
||||
wpi::RawFrame rawFrame;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -151,7 +151,7 @@ class RawCvSink : public RawSink {
|
||||
uint64_t GrabFrameNoTimeoutDirect(cv::Mat& image);
|
||||
|
||||
private:
|
||||
RawFrame rawFrame;
|
||||
wpi::RawFrame rawFrame;
|
||||
};
|
||||
|
||||
inline RawCvSource::RawCvSource(std::string_view name, const VideoMode& mode)
|
||||
@@ -168,7 +168,8 @@ inline void RawCvSource::PutFrame(cv::Mat& image) {
|
||||
rawFrame.width = image.cols;
|
||||
rawFrame.height = image.rows;
|
||||
rawFrame.totalData = image.total() * image.channels();
|
||||
rawFrame.pixelFormat = image.channels() == 3 ? CS_PIXFMT_BGR : CS_PIXFMT_GRAY;
|
||||
rawFrame.pixelFormat =
|
||||
image.channels() == 3 ? WPI_PIXFMT_BGR : WPI_PIXFMT_GRAY;
|
||||
PutSourceFrame(m_handle, rawFrame, &m_status);
|
||||
}
|
||||
|
||||
@@ -201,7 +202,7 @@ inline uint64_t RawCvSink::GrabFrameNoTimeout(cv::Mat& image) {
|
||||
inline uint64_t RawCvSink::GrabFrameDirect(cv::Mat& image, double timeout) {
|
||||
rawFrame.height = 0;
|
||||
rawFrame.width = 0;
|
||||
rawFrame.pixelFormat = CS_PixelFormat::CS_PIXFMT_BGR;
|
||||
rawFrame.pixelFormat = WPI_PixelFormat::WPI_PIXFMT_BGR;
|
||||
m_status = RawSink::GrabFrame(rawFrame, timeout);
|
||||
if (m_status <= 0) {
|
||||
return m_status;
|
||||
@@ -213,7 +214,7 @@ inline uint64_t RawCvSink::GrabFrameDirect(cv::Mat& image, double timeout) {
|
||||
inline uint64_t RawCvSink::GrabFrameNoTimeoutDirect(cv::Mat& image) {
|
||||
rawFrame.height = 0;
|
||||
rawFrame.width = 0;
|
||||
rawFrame.pixelFormat = CS_PixelFormat::CS_PIXFMT_BGR;
|
||||
rawFrame.pixelFormat = WPI_PixelFormat::WPI_PIXFMT_BGR;
|
||||
m_status = RawSink::GrabFrameNoTimeout(rawFrame);
|
||||
if (m_status <= 0) {
|
||||
return m_status;
|
||||
|
||||
@@ -89,6 +89,7 @@ void NetworkListener::Impl::Thread::Main() {
|
||||
std::memset(&addr, 0, sizeof(addr));
|
||||
addr.nl_family = AF_NETLINK;
|
||||
addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR;
|
||||
// NOLINTNEXTLINE(modernize-avoid-bind)
|
||||
if (bind(sd, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) < 0) {
|
||||
ERROR("NetworkListener: could not create socket: {}", std::strerror(errno));
|
||||
::close(sd);
|
||||
|
||||
@@ -595,7 +595,7 @@ void UsbCameraImpl::DeviceConnect() {
|
||||
}
|
||||
|
||||
if (m_connectVerbose) {
|
||||
SINFO("Connecting to USB camera on {}", m_path);
|
||||
SINFO("Attempting to connect to USB camera on {}", m_path);
|
||||
}
|
||||
|
||||
// Try to open the device
|
||||
@@ -606,6 +606,10 @@ void UsbCameraImpl::DeviceConnect() {
|
||||
}
|
||||
m_fd = fd;
|
||||
|
||||
if (m_connectVerbose) {
|
||||
SINFO("Connected to USB camera on {}", m_path);
|
||||
}
|
||||
|
||||
// Get capabilities
|
||||
SDEBUG3("getting capabilities");
|
||||
struct v4l2_capability vcap;
|
||||
|
||||
@@ -554,7 +554,7 @@ static cs::VideoMode::PixelFormat FourCCToPixelFormat(FourCharCode fourcc) {
|
||||
}
|
||||
|
||||
std::string pathStr = [self.path UTF8String];
|
||||
OBJCINFO("Connecting to USB camera on {}", pathStr);
|
||||
OBJCINFO("Attempting to connect to USB camera on {}", pathStr);
|
||||
|
||||
self.videoDevice = [AVCaptureDevice deviceWithUniqueID:self.path];
|
||||
if (self.videoDevice == nil) {
|
||||
@@ -594,6 +594,8 @@ static cs::VideoMode::PixelFormat FourCCToPixelFormat(FourCharCode fourcc) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
OBJCINFO("Connected to USB camera on {}", pathStr);
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(sessionRuntimeError:)
|
||||
|
||||
@@ -499,7 +499,7 @@ bool UsbCameraImpl::DeviceConnect() {
|
||||
}
|
||||
|
||||
if (m_connectVerbose) {
|
||||
SINFO("Connecting to USB camera on {}", m_path);
|
||||
SINFO("Attempting to connect to USB camera on {}", m_path);
|
||||
}
|
||||
|
||||
SDEBUG3("opening device");
|
||||
@@ -526,6 +526,10 @@ bool UsbCameraImpl::DeviceConnect() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_connectVerbose) {
|
||||
SINFO("Connected to USB camera on {}", m_path);
|
||||
}
|
||||
|
||||
CS_Status st = 0;
|
||||
auto devices = EnumerateUsbCameras(&st);
|
||||
|
||||
|
||||
@@ -99,8 +99,9 @@ WindowsMessagePump::WindowsMessagePump(
|
||||
|
||||
WindowsMessagePump::~WindowsMessagePump() {
|
||||
auto res = SendMessageA(hwnd, WM_CLOSE, NULL, NULL);
|
||||
if (m_mainThread.joinable())
|
||||
if (m_mainThread.joinable()) {
|
||||
m_mainThread.join();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsMessagePump::ThreadMain(HANDLE eventHandle) {
|
||||
|
||||
@@ -32,7 +32,7 @@ class UsbCameraTest {
|
||||
|
||||
assertTimeoutPreemptively(
|
||||
Duration.ofSeconds(5),
|
||||
() -> assertTrue(result.get().contains("Connecting to USB camera on ")));
|
||||
() -> assertTrue(result.get().contains("Attempting to connect to USB camera on ")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ generate_resources(src/main/native/resources generated/main/cpp DLT dlt datalogt
|
||||
|
||||
file(GLOB datalogtool_src src/main/native/cpp/*.cpp ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp)
|
||||
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
set(datalogtool_rc src/main/native/win/datalogtool.rc)
|
||||
elseif(APPLE)
|
||||
set(MACOSX_BUNDLE_ICON_FILE datalogtool.icns)
|
||||
@@ -17,12 +17,18 @@ elseif(APPLE)
|
||||
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
|
||||
endif()
|
||||
|
||||
add_executable(datalogtool ${datalogtool_src} ${datalogtool_resources_src} ${datalogtool_rc} ${APP_ICON_MACOSX})
|
||||
add_executable(
|
||||
datalogtool
|
||||
${datalogtool_src}
|
||||
${datalogtool_resources_src}
|
||||
${datalogtool_rc}
|
||||
${APP_ICON_MACOSX}
|
||||
)
|
||||
wpilib_link_macos_gui(datalogtool)
|
||||
target_link_libraries(datalogtool libglass ${LIBSSH_LIBRARIES})
|
||||
target_include_directories(datalogtool SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
|
||||
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
set_target_properties(datalogtool PROPERTIES WIN32_EXECUTABLE YES)
|
||||
elseif(APPLE)
|
||||
set_target_properties(datalogtool PROPERTIES MACOSX_BUNDLE YES OUTPUT_NAME "datalogTool")
|
||||
|
||||
@@ -144,6 +144,10 @@ doxygen {
|
||||
|
||||
exclude '*.pb.h'
|
||||
|
||||
// Save space by excluding protobuf and eigen
|
||||
exclude 'Eigen/**'
|
||||
exclude 'google/protobuf/**'
|
||||
|
||||
aliases 'effects=\\par <i>Effects:</i>^^',
|
||||
'notes=\\par <i>Notes:</i>^^',
|
||||
'requires=\\par <i>Requires:</i>^^',
|
||||
@@ -222,10 +226,7 @@ task generateJavaDocs(type: Javadoc) {
|
||||
options.addBooleanOption("Xdoclint:html,missing,reference,syntax", true)
|
||||
options.addBooleanOption('html5', true)
|
||||
options.linkSource(true)
|
||||
dependsOn project(':hal').generateUsageReporting
|
||||
dependsOn project(':ntcore').ntcoreGenerateJavaTypes
|
||||
dependsOn project(':wpilibj').generateJavaVersion
|
||||
dependsOn project(':wpimath').generateNat
|
||||
source project(':apriltag').sourceSets.main.java
|
||||
source project(':cameraserver').sourceSets.main.java
|
||||
source project(':cscore').sourceSets.main.java
|
||||
@@ -235,6 +236,7 @@ task generateJavaDocs(type: Javadoc) {
|
||||
source project(':wpilibj').sourceSets.main.java
|
||||
source project(':wpimath').sourceSets.main.java
|
||||
source project(':wpinet').sourceSets.main.java
|
||||
source project(':wpiunits').sourceSets.main.java
|
||||
source project(':wpiutil').sourceSets.main.java
|
||||
source configurations.javaSource.collect { zipTree(it) }
|
||||
include '**/*.java'
|
||||
|
||||
@@ -3,7 +3,7 @@ project(fieldImages)
|
||||
include(CompileWarnings)
|
||||
include(GenResources)
|
||||
|
||||
if (WITH_JAVA)
|
||||
if(WITH_JAVA)
|
||||
find_package(Java REQUIRED)
|
||||
include(UseJava)
|
||||
|
||||
@@ -11,30 +11,42 @@ if (WITH_JAVA)
|
||||
set(CMAKE_JAVA_INCLUDE_PATH fieldImages.jar ${JACKSON_JARS})
|
||||
|
||||
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
|
||||
file(GLOB_RECURSE JAVA_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/main/native/resources/*.json src/main/native/resources/*.png src/main/native/resources/*.jpg)
|
||||
add_jar(field_images_jar SOURCES ${JAVA_SOURCES} RESOURCES NAMESPACE "edu/wpi/first/fields" ${JAVA_RESOURCES} OUTPUT_NAME fieldImages)
|
||||
file(
|
||||
GLOB_RECURSE JAVA_RESOURCES
|
||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
src/main/native/resources/*.json
|
||||
src/main/native/resources/*.png
|
||||
src/main/native/resources/*.jpg
|
||||
)
|
||||
add_jar(
|
||||
field_images_jar
|
||||
SOURCES ${JAVA_SOURCES}
|
||||
RESOURCES
|
||||
NAMESPACE "edu/wpi/first/fields" ${JAVA_RESOURCES}
|
||||
OUTPUT_NAME fieldImages
|
||||
)
|
||||
|
||||
get_property(FIELD_IMAGES_JAR_FILE TARGET field_images_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${FIELD_IMAGES_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
|
||||
set_property(TARGET field_images_jar PROPERTY FOLDER "java")
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
generate_resources(src/main/native/resources/edu/wpi/first/fields generated/main/cpp FIELDS fields field_images_resources_src)
|
||||
|
||||
|
||||
add_library(fieldImages src/main/native/cpp/fields.cpp ${field_images_resources_src})
|
||||
set_target_properties(fieldImages PROPERTIES DEBUG_POSTFIX "d")
|
||||
|
||||
set_property(TARGET fieldImages PROPERTY FOLDER "libraries")
|
||||
target_compile_features(fieldImages PUBLIC cxx_std_20)
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
target_compile_options(fieldImages PUBLIC /bigobj)
|
||||
endif()
|
||||
wpilib_target_warnings(fieldImages)
|
||||
|
||||
target_include_directories(fieldImages PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/fields>)
|
||||
target_include_directories(
|
||||
fieldImages
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/fields>
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ apply plugin: 'maven-publish'
|
||||
|
||||
def baseArtifactId = project.nativeName
|
||||
def artifactGroupId = project.groupId
|
||||
def cppZipBaseName = "_GROUP_edu_wpi_first_fieldIimages_ID_${baseArtifactId}-cpp_CLS"
|
||||
def cppZipBaseName = "_GROUP_edu_wpi_first_fieldImages_ID_${baseArtifactId}-cpp_CLS"
|
||||
|
||||
def outputsFolder = file("$project.buildDir/outputs")
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ include(LinkMacOSGUI)
|
||||
#
|
||||
file(GLOB_RECURSE libglass_src src/lib/native/cpp/*.cpp)
|
||||
|
||||
add_library(libglass STATIC ${libglass_src})
|
||||
add_library(libglass ${libglass_src})
|
||||
set_target_properties(libglass PROPERTIES DEBUG_POSTFIX "d" OUTPUT_NAME "glass")
|
||||
set_property(TARGET libglass PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
@@ -18,9 +18,12 @@ set_property(TARGET libglass PROPERTY FOLDER "libraries")
|
||||
wpilib_target_warnings(libglass)
|
||||
target_link_libraries(libglass PUBLIC wpigui wpimath wpiutil fieldImages)
|
||||
|
||||
target_include_directories(libglass PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/lib/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/glass>)
|
||||
target_include_directories(
|
||||
libglass
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/lib/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/glass>
|
||||
)
|
||||
|
||||
install(TARGETS libglass EXPORT libglass)
|
||||
install(DIRECTORY src/lib/native/include/ DESTINATION "${include_dest}/glass")
|
||||
@@ -30,7 +33,7 @@ install(DIRECTORY src/lib/native/include/ DESTINATION "${include_dest}/glass")
|
||||
#
|
||||
file(GLOB_RECURSE libglassnt_src src/libnt/native/cpp/*.cpp)
|
||||
|
||||
add_library(libglassnt STATIC ${libglassnt_src})
|
||||
add_library(libglassnt ${libglassnt_src})
|
||||
set_target_properties(libglassnt PROPERTIES DEBUG_POSTFIX "d" OUTPUT_NAME "glassnt")
|
||||
set_property(TARGET libglassnt PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
@@ -39,9 +42,12 @@ set_property(TARGET libglassnt PROPERTY FOLDER "libraries")
|
||||
wpilib_target_warnings(libglassnt)
|
||||
target_link_libraries(libglassnt PUBLIC ntcore libglass)
|
||||
|
||||
target_include_directories(libglassnt PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/libnt/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/glass>)
|
||||
target_include_directories(
|
||||
libglassnt
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/libnt/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/glass>
|
||||
)
|
||||
|
||||
install(TARGETS libglassnt EXPORT libglassnt)
|
||||
install(DIRECTORY src/libnt/native/include/ DESTINATION "${include_dest}/glass")
|
||||
@@ -55,7 +61,7 @@ generate_resources(src/app/native/resources generated/app/cpp GLASS glass glass_
|
||||
|
||||
file(GLOB glass_src src/app/native/cpp/*.cpp ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp)
|
||||
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
set(glass_rc src/app/native/win/glass.rc)
|
||||
elseif(APPLE)
|
||||
set(MACOSX_BUNDLE_ICON_FILE glass.icns)
|
||||
@@ -68,18 +74,8 @@ wpilib_link_macos_gui(glass)
|
||||
wpilib_target_warnings(glass)
|
||||
target_link_libraries(glass libglassnt libglass)
|
||||
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
set_target_properties(glass PROPERTIES WIN32_EXECUTABLE YES)
|
||||
elseif(APPLE)
|
||||
set_target_properties(glass PROPERTIES MACOSX_BUNDLE YES OUTPUT_NAME "Glass")
|
||||
endif()
|
||||
|
||||
#if (MSVC OR FLAT_INSTALL_WPILIB)
|
||||
# set (wpigui_config_dir ${wpilib_dest})
|
||||
#else()
|
||||
# set (wpigui_config_dir share/wpigui)
|
||||
#endif()
|
||||
|
||||
#configure_file(wpigui-config.cmake.in ${CMAKE_BINARY_DIR}/wpigui-config.cmake )
|
||||
#install(FILES ${CMAKE_BINARY_DIR}/wpigui-config.cmake DESTINATION ${wpigui_config_dir})
|
||||
#install(EXPORT wpigui DESTINATION ${wpigui_config_dir})
|
||||
|
||||
@@ -137,9 +137,8 @@ static bool LoadWindowStorageImpl(const std::string& filename) {
|
||||
return false;
|
||||
} else {
|
||||
try {
|
||||
return JsonToWindow(
|
||||
wpi::json::parse(fileBuffer->begin(), fileBuffer->end()),
|
||||
filename.c_str());
|
||||
return JsonToWindow(wpi::json::parse(fileBuffer->GetCharBuffer()),
|
||||
filename.c_str());
|
||||
} catch (wpi::json::parse_error& e) {
|
||||
ImGui::LogText("Error loading %s: %s", filename.c_str(), e.what());
|
||||
return false;
|
||||
@@ -164,9 +163,8 @@ static bool LoadStorageRootImpl(Context* ctx, const std::string& filename,
|
||||
createdStorage = true;
|
||||
}
|
||||
try {
|
||||
storage->FromJson(
|
||||
wpi::json::parse(fileBuffer->begin(), fileBuffer->end()),
|
||||
filename.c_str());
|
||||
storage->FromJson(wpi::json::parse(fileBuffer->GetCharBuffer()),
|
||||
filename.c_str());
|
||||
} catch (wpi::json::parse_error& e) {
|
||||
ImGui::LogText("Error loading %s: %s", filename.c_str(), e.what());
|
||||
if (createdStorage) {
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
using namespace glass;
|
||||
|
||||
static const char* stations[] = {"Red 1", "Red 2", "Red 3",
|
||||
"Blue 1", "Blue 2", "Blue 3"};
|
||||
static const char* stations[] = {"Invalid", "Red 1", "Red 2", "Red 3",
|
||||
"Blue 1", "Blue 2", "Blue 3"};
|
||||
|
||||
void glass::DisplayFMS(FMSModel* model) {
|
||||
if (!model->Exists() || model->IsReadOnly()) {
|
||||
@@ -41,7 +41,7 @@ void glass::DisplayFMS(FMSModel* model) {
|
||||
if (auto data = model->GetAllianceStationIdData()) {
|
||||
int val = data->GetValue();
|
||||
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8);
|
||||
if (ImGui::Combo("Alliance Station", &val, stations, 6)) {
|
||||
if (ImGui::Combo("Alliance Station", &val, stations, 7)) {
|
||||
model->SetAllianceStationId(val);
|
||||
}
|
||||
data->EmitDrag();
|
||||
|
||||
@@ -895,12 +895,16 @@ void NetworkTablesModel::Update() {
|
||||
entry->info.type_str == "proto:FileDescriptorProto") {
|
||||
// protobuf descriptor handling
|
||||
auto filename = wpi::drop_front(entry->info.name, 15);
|
||||
m_protoDb.Add(filename, entry->value.GetRaw());
|
||||
// loop over all protobuf entries and update (conservatively)
|
||||
for (auto&& entryPair : m_entries) {
|
||||
auto ts = entryPair.second->info.type_str;
|
||||
if (wpi::starts_with(ts, "proto:")) {
|
||||
entryPair.second->UpdateFromValue(*this);
|
||||
if (!m_protoDb.Add(filename, entry->value.GetRaw())) {
|
||||
fmt::print("could not decode protobuf '{}' filename '{}'\n",
|
||||
entry->info.name, filename);
|
||||
} else {
|
||||
// loop over all protobuf entries and update (conservatively)
|
||||
for (auto&& entryPair : m_entries) {
|
||||
auto& ts = entryPair.second->info.type_str;
|
||||
if (wpi::starts_with(ts, "proto:")) {
|
||||
entryPair.second->UpdateFromValue(*this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1067,7 +1071,7 @@ void NetworkTablesModel::UpdateClients(std::span<const uint8_t> data) {
|
||||
m_clients = std::move(newClients);
|
||||
}
|
||||
|
||||
static bool SimplifyTypeString(std::string_view* ts) {
|
||||
static bool GetHeadingTypeString(std::string_view* ts) {
|
||||
if (wpi::starts_with(*ts, "proto:")) {
|
||||
*ts = wpi::drop_front(*ts, 6);
|
||||
auto lastdot = ts->rfind('.');
|
||||
@@ -1085,24 +1089,71 @@ static bool SimplifyTypeString(std::string_view* ts) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char* GetShortTypeString(std::string_view ts) {
|
||||
if (wpi::starts_with(ts, "proto:")) {
|
||||
return "protobuf";
|
||||
} else if (wpi::starts_with(ts, "struct:")) {
|
||||
return "struct";
|
||||
} else {
|
||||
return ts.data();
|
||||
}
|
||||
}
|
||||
|
||||
static const char* GetTypeString(NT_Type type, const char* overrideTypeStr) {
|
||||
if (overrideTypeStr) {
|
||||
return GetShortTypeString(overrideTypeStr);
|
||||
}
|
||||
switch (type) {
|
||||
case NT_BOOLEAN:
|
||||
return "boolean";
|
||||
case NT_INTEGER:
|
||||
return "int";
|
||||
case NT_FLOAT:
|
||||
return "float";
|
||||
case NT_DOUBLE:
|
||||
return "double";
|
||||
case NT_STRING:
|
||||
return "string";
|
||||
case NT_BOOLEAN_ARRAY:
|
||||
return "boolean[]";
|
||||
case NT_INTEGER_ARRAY:
|
||||
return "int[]";
|
||||
case NT_FLOAT_ARRAY:
|
||||
return "float[]";
|
||||
case NT_DOUBLE_ARRAY:
|
||||
return "double[]";
|
||||
case NT_STRING_ARRAY:
|
||||
return "string[]";
|
||||
case NT_RAW:
|
||||
return "raw";
|
||||
case NT_RPC:
|
||||
return "rpc";
|
||||
default:
|
||||
return "other";
|
||||
}
|
||||
}
|
||||
|
||||
static void EmitEntryValueReadonly(const NetworkTablesModel::ValueSource& entry,
|
||||
const char* typeStr,
|
||||
const char* overrideTypeStr,
|
||||
NetworkTablesFlags flags) {
|
||||
auto& val = entry.value;
|
||||
if (!val) {
|
||||
return;
|
||||
}
|
||||
|
||||
const char* typeStr = GetTypeString(val.type(), overrideTypeStr);
|
||||
ImGui::SetNextItemWidth(
|
||||
-1 * (ImGui::CalcTextSize(typeStr).x + ImGui::GetStyle().FramePadding.x));
|
||||
|
||||
switch (val.type()) {
|
||||
case NT_BOOLEAN:
|
||||
ImGui::LabelText(typeStr ? typeStr : "boolean", "%s",
|
||||
val.GetBoolean() ? "true" : "false");
|
||||
ImGui::LabelText(typeStr, "%s", val.GetBoolean() ? "true" : "false");
|
||||
break;
|
||||
case NT_INTEGER:
|
||||
ImGui::LabelText(typeStr ? typeStr : "int", "%" PRId64, val.GetInteger());
|
||||
ImGui::LabelText(typeStr, "%" PRId64, val.GetInteger());
|
||||
break;
|
||||
case NT_FLOAT:
|
||||
ImGui::LabelText(typeStr ? typeStr : "double", "%.6f", val.GetFloat());
|
||||
ImGui::LabelText(typeStr, "%.6f", val.GetFloat());
|
||||
break;
|
||||
case NT_DOUBLE: {
|
||||
unsigned char precision = (flags & NetworkTablesFlags_Precision) >>
|
||||
@@ -1111,8 +1162,7 @@ static void EmitEntryValueReadonly(const NetworkTablesModel::ValueSource& entry,
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
#endif
|
||||
ImGui::LabelText(typeStr ? typeStr : "double",
|
||||
fmt::format("%.{}f", precision).c_str(),
|
||||
ImGui::LabelText(typeStr, fmt::format("%.{}f", precision).c_str(),
|
||||
val.GetDouble());
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -1120,33 +1170,22 @@ static void EmitEntryValueReadonly(const NetworkTablesModel::ValueSource& entry,
|
||||
break;
|
||||
}
|
||||
case NT_STRING: {
|
||||
ImGui::LabelText(typeStr ? typeStr : "string", "%s",
|
||||
entry.valueStr.c_str());
|
||||
ImGui::LabelText(typeStr, "%s", entry.valueStr.c_str());
|
||||
break;
|
||||
}
|
||||
case NT_BOOLEAN_ARRAY:
|
||||
ImGui::LabelText(typeStr ? typeStr : "boolean[]", "[]");
|
||||
break;
|
||||
case NT_INTEGER_ARRAY:
|
||||
ImGui::LabelText(typeStr ? typeStr : "int[]", "[]");
|
||||
break;
|
||||
case NT_FLOAT_ARRAY:
|
||||
ImGui::LabelText(typeStr ? typeStr : "float[]", "[]");
|
||||
break;
|
||||
case NT_DOUBLE_ARRAY:
|
||||
ImGui::LabelText(typeStr ? typeStr : "double[]", "[]");
|
||||
break;
|
||||
case NT_STRING_ARRAY:
|
||||
ImGui::LabelText(typeStr ? typeStr : "string[]", "[]");
|
||||
ImGui::LabelText(typeStr, "[]");
|
||||
break;
|
||||
case NT_RAW: {
|
||||
std::string_view ts = typeStr ? typeStr : "raw";
|
||||
bool partial = SimplifyTypeString(&ts);
|
||||
ImGui::LabelText(val.GetRaw().empty() ? "[]" : "[...]", "%s", ts.data());
|
||||
ImGui::LabelText(typeStr, val.GetRaw().empty() ? "[]" : "[...]");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
if (partial) {
|
||||
ImGui::TextUnformatted(typeStr);
|
||||
if (overrideTypeStr) {
|
||||
ImGui::TextUnformatted(overrideTypeStr);
|
||||
}
|
||||
ImGui::Text("%u bytes", static_cast<unsigned int>(val.GetRaw().size()));
|
||||
ImGui::EndTooltip();
|
||||
@@ -1154,7 +1193,7 @@ static void EmitEntryValueReadonly(const NetworkTablesModel::ValueSource& entry,
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ImGui::LabelText(typeStr ? typeStr : "other", "?");
|
||||
ImGui::LabelText(typeStr, "?");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1316,14 +1355,18 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
return;
|
||||
}
|
||||
|
||||
const char* typeStr =
|
||||
entry.info.type_str.empty() ? nullptr : entry.info.type_str.c_str();
|
||||
const char* typeStr = GetTypeString(
|
||||
val.type(),
|
||||
entry.info.type_str.empty() ? nullptr : entry.info.type_str.c_str());
|
||||
ImGui::SetNextItemWidth(
|
||||
-1 * (ImGui::CalcTextSize(typeStr).x + ImGui::GetStyle().FramePadding.x));
|
||||
|
||||
ImGui::PushID(entry.info.name.c_str());
|
||||
switch (val.type()) {
|
||||
case NT_BOOLEAN: {
|
||||
static const char* boolOptions[] = {"false", "true"};
|
||||
int v = val.GetBoolean() ? 1 : 0;
|
||||
if (ImGui::Combo(typeStr ? typeStr : "boolean", &v, boolOptions, 2)) {
|
||||
if (ImGui::Combo(typeStr, &v, boolOptions, 2)) {
|
||||
if (entry.publisher == 0) {
|
||||
entry.publisher =
|
||||
nt::Publish(entry.info.topic, NT_BOOLEAN, "boolean");
|
||||
@@ -1334,9 +1377,8 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
}
|
||||
case NT_INTEGER: {
|
||||
int64_t v = val.GetInteger();
|
||||
if (ImGui::InputScalar(typeStr ? typeStr : "int", ImGuiDataType_S64, &v,
|
||||
nullptr, nullptr, nullptr,
|
||||
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
if (ImGui::InputScalar(typeStr, ImGuiDataType_S64, &v, nullptr, nullptr,
|
||||
nullptr, ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
if (entry.publisher == 0) {
|
||||
entry.publisher = nt::Publish(entry.info.topic, NT_INTEGER, "int");
|
||||
}
|
||||
@@ -1346,7 +1388,7 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
}
|
||||
case NT_FLOAT: {
|
||||
float v = val.GetFloat();
|
||||
if (ImGui::InputFloat(typeStr ? typeStr : "float", &v, 0, 0, "%.6f",
|
||||
if (ImGui::InputFloat(typeStr, &v, 0, 0, "%.6f",
|
||||
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
if (entry.publisher == 0) {
|
||||
entry.publisher = nt::Publish(entry.info.topic, NT_FLOAT, "float");
|
||||
@@ -1363,7 +1405,7 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
#endif
|
||||
if (ImGui::InputDouble(typeStr ? typeStr : "double", &v, 0, 0,
|
||||
if (ImGui::InputDouble(typeStr, &v, 0, 0,
|
||||
fmt::format("%.{}f", precision).c_str(),
|
||||
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
if (entry.publisher == 0) {
|
||||
@@ -1378,7 +1420,7 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
}
|
||||
case NT_STRING: {
|
||||
char* v = GetTextBuffer(entry.valueStr);
|
||||
if (ImGui::InputText(typeStr ? typeStr : "string", v, kTextBufferSize,
|
||||
if (ImGui::InputText(typeStr, v, kTextBufferSize,
|
||||
ImGuiInputTextFlags_EnterReturnsTrue)) {
|
||||
if (v[0] == '"') {
|
||||
if (entry.publisher == 0) {
|
||||
@@ -1393,7 +1435,7 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
break;
|
||||
}
|
||||
case NT_BOOLEAN_ARRAY:
|
||||
ImGui::LabelText("boolean[]", "[]");
|
||||
ImGui::LabelText(typeStr, "[]");
|
||||
if (ImGui::BeginPopupContextItem("boolean[]")) {
|
||||
if (ImGui::Selectable("Edit Array")) {
|
||||
gArrayEditor =
|
||||
@@ -1406,7 +1448,7 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
}
|
||||
break;
|
||||
case NT_INTEGER_ARRAY:
|
||||
ImGui::LabelText("int[]", "[]");
|
||||
ImGui::LabelText(typeStr, "[]");
|
||||
if (ImGui::BeginPopupContextItem("int[]")) {
|
||||
if (ImGui::Selectable("Edit Array")) {
|
||||
gArrayEditor =
|
||||
@@ -1419,7 +1461,7 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
}
|
||||
break;
|
||||
case NT_FLOAT_ARRAY:
|
||||
ImGui::LabelText("float[]", "[]");
|
||||
ImGui::LabelText(typeStr, "[]");
|
||||
if (ImGui::BeginPopupContextItem("float[]")) {
|
||||
if (ImGui::Selectable("Edit Array")) {
|
||||
gArrayEditor =
|
||||
@@ -1431,7 +1473,7 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
}
|
||||
break;
|
||||
case NT_DOUBLE_ARRAY:
|
||||
ImGui::LabelText("double[]", "[]");
|
||||
ImGui::LabelText(typeStr, "[]");
|
||||
if (ImGui::BeginPopupContextItem("double[]")) {
|
||||
if (ImGui::Selectable("Edit Array")) {
|
||||
gArrayEditor =
|
||||
@@ -1443,7 +1485,7 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
}
|
||||
break;
|
||||
case NT_STRING_ARRAY:
|
||||
ImGui::LabelText("string[]", "[]");
|
||||
ImGui::LabelText(typeStr, "[]");
|
||||
if (ImGui::BeginPopupContextItem("string[]")) {
|
||||
if (ImGui::Selectable("Edit Array")) {
|
||||
gArrayEditor =
|
||||
@@ -1456,13 +1498,11 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
}
|
||||
break;
|
||||
case NT_RAW: {
|
||||
std::string_view ts = typeStr ? typeStr : "raw";
|
||||
bool partial = SimplifyTypeString(&ts);
|
||||
ImGui::LabelText(val.GetRaw().empty() ? "[]" : "[...]", "%s", ts.data());
|
||||
ImGui::LabelText(typeStr, val.GetRaw().empty() ? "[]" : "[...]");
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::BeginTooltip();
|
||||
if (partial) {
|
||||
ImGui::TextUnformatted(typeStr);
|
||||
if (!entry.info.type_str.empty()) {
|
||||
ImGui::TextUnformatted(entry.info.type_str.c_str());
|
||||
}
|
||||
ImGui::Text("%u bytes", static_cast<unsigned int>(val.GetRaw().size()));
|
||||
ImGui::EndTooltip();
|
||||
@@ -1470,10 +1510,10 @@ static void EmitEntryValueEditable(NetworkTablesModel* model,
|
||||
break;
|
||||
}
|
||||
case NT_RPC:
|
||||
ImGui::LabelText(typeStr ? typeStr : "rpc", "[...]");
|
||||
ImGui::LabelText(typeStr, "[...]");
|
||||
break;
|
||||
default:
|
||||
ImGui::LabelText(typeStr ? typeStr : "other", "?");
|
||||
ImGui::LabelText(typeStr, "?");
|
||||
break;
|
||||
}
|
||||
ImGui::PopID();
|
||||
@@ -1610,7 +1650,7 @@ static void EmitValueTree(
|
||||
auto pos = ImGui::GetCursorPos();
|
||||
char label[128];
|
||||
std::string_view ts = child.typeStr;
|
||||
bool havePopup = SimplifyTypeString(&ts);
|
||||
bool havePopup = GetHeadingTypeString(&ts);
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "{}##v_{}", ts.data(),
|
||||
child.name.c_str());
|
||||
bool valueChildrenOpen =
|
||||
@@ -1652,7 +1692,7 @@ static void EmitEntry(NetworkTablesModel* model,
|
||||
auto pos = ImGui::GetCursorPos();
|
||||
char label[128];
|
||||
std::string_view ts = entry.info.type_str;
|
||||
bool havePopup = SimplifyTypeString(&ts);
|
||||
bool havePopup = GetHeadingTypeString(&ts);
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "{}##v_{}", ts.data(),
|
||||
entry.info.name.c_str());
|
||||
valueChildrenOpen =
|
||||
@@ -1666,8 +1706,13 @@ static void EmitEntry(NetworkTablesModel* model,
|
||||
}
|
||||
}
|
||||
// make it look like a normal label w/type
|
||||
const char* typeStr = GetTypeString(
|
||||
NT_RAW,
|
||||
entry.info.type_str.empty() ? nullptr : entry.info.type_str.c_str());
|
||||
ImGui::SetCursorPos(pos);
|
||||
ImGui::LabelText(entry.info.type_str.c_str(), "%s", "");
|
||||
ImGui::SetNextItemWidth(-1 * (ImGui::CalcTextSize(typeStr).x +
|
||||
ImGui::GetStyle().FramePadding.x));
|
||||
ImGui::LabelText(typeStr, "%s", "");
|
||||
if ((entry.value.IsBooleanArray() || entry.value.IsFloatArray() ||
|
||||
entry.value.IsDoubleArray() || entry.value.IsIntegerArray() ||
|
||||
entry.value.IsStringArray()) &&
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
fetchcontent_declare(
|
||||
googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # 1.12.1
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG
|
||||
58d77fa8070e8cec2dc1ed015d66b454c8d78850 # 1.12.1
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(googletest)
|
||||
fetchcontent_getproperties(googletest)
|
||||
if(NOT googletest_POPULATED)
|
||||
FetchContent_Populate(googletest)
|
||||
fetchcontent_populate(googletest)
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker
|
||||
# settings on Windows
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -3,33 +3,18 @@ project(hal)
|
||||
include(CompileWarnings)
|
||||
include(AddTest)
|
||||
|
||||
file(STRINGS src/generate/Instances.txt RAW_INSTANCES)
|
||||
file(STRINGS src/generate/ResourceType.txt RAW_RESOURCE_TYPES)
|
||||
|
||||
SET(usage_reporting_types_cpp "")
|
||||
SET(usage_reporting_instances_cpp "")
|
||||
SET(usage_reporting_types "")
|
||||
SET(usage_reporting_instances "")
|
||||
|
||||
foreach(ITEM ${RAW_INSTANCES})
|
||||
list(APPEND usage_reporting_instances_cpp " ${ITEM},")
|
||||
list(APPEND usage_reporting_instances "\n public static final int ${ITEM};")
|
||||
endforeach()
|
||||
|
||||
foreach(ITEM ${RAW_RESOURCE_TYPES})
|
||||
list(APPEND usage_reporting_types_cpp " ${ITEM},")
|
||||
list(APPEND usage_reporting_types "\n public static final int ${ITEM};")
|
||||
endforeach()
|
||||
|
||||
string(REPLACE ";" "\n" usage_reporting_types_cpp "${usage_reporting_types_cpp}")
|
||||
string(REPLACE ";" "\n" usage_reporting_instances_cpp "${usage_reporting_instances_cpp}")
|
||||
|
||||
file(GLOB
|
||||
hal_shared_native_src src/main/native/cpp/*.cpp
|
||||
hal_shared_native_src src/main/native/cpp/cpp/*.cpp
|
||||
hal_shared_native_src src/main/native/cpp/handles/*.cpp
|
||||
hal_sim_native_src src/main/native/sim/*.cpp
|
||||
hal_sim_native_src src/main/native/sim/mockdata/*.cpp)
|
||||
file(
|
||||
GLOB hal_shared_native_src
|
||||
src/main/native/cpp/*.cpp
|
||||
hal_shared_native_src
|
||||
src/main/native/cpp/cpp/*.cpp
|
||||
hal_shared_native_src
|
||||
src/main/native/cpp/handles/*.cpp
|
||||
hal_sim_native_src
|
||||
src/main/native/sim/*.cpp
|
||||
hal_sim_native_src
|
||||
src/main/native/sim/mockdata/*.cpp
|
||||
)
|
||||
add_library(hal ${hal_shared_native_src})
|
||||
wpilib_target_warnings(hal)
|
||||
set_target_properties(hal PROPERTIES DEBUG_POSTFIX "d")
|
||||
@@ -40,37 +25,35 @@ else()
|
||||
target_sources(hal PRIVATE ${hal_sim_native_src})
|
||||
endif()
|
||||
|
||||
configure_file(src/generate/FRCUsageReporting.h.in gen/hal/FRCUsageReporting.h)
|
||||
|
||||
set_target_properties(hal PROPERTIES OUTPUT_NAME "wpiHal")
|
||||
|
||||
target_include_directories(hal PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/hal>)
|
||||
target_include_directories(
|
||||
hal
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/hal>
|
||||
)
|
||||
|
||||
target_include_directories(hal PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/gen>
|
||||
$<INSTALL_INTERFACE:${include_dest}/hal>)
|
||||
target_include_directories(
|
||||
hal
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/hal>
|
||||
)
|
||||
target_link_libraries(hal PUBLIC wpiutil)
|
||||
|
||||
set_property(TARGET hal PROPERTY FOLDER "libraries")
|
||||
|
||||
install(TARGETS hal EXPORT hal)
|
||||
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/hal")
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen/ DESTINATION "${include_dest}/hal")
|
||||
install(DIRECTORY src/generated/main/native/include/ DESTINATION "${include_dest}/hal")
|
||||
|
||||
if (WITH_FLAT_INSTALL)
|
||||
set (hal_config_dir ${wpilib_dest})
|
||||
else()
|
||||
set (hal_config_dir share/hal)
|
||||
endif()
|
||||
|
||||
configure_file(hal-config.cmake.in ${WPILIB_BINARY_DIR}/hal-config.cmake )
|
||||
install(FILES ${WPILIB_BINARY_DIR}/hal-config.cmake DESTINATION ${hal_config_dir})
|
||||
install(EXPORT hal DESTINATION ${hal_config_dir})
|
||||
configure_file(hal-config.cmake.in ${WPILIB_BINARY_DIR}/hal-config.cmake)
|
||||
install(FILES ${WPILIB_BINARY_DIR}/hal-config.cmake DESTINATION share/hal)
|
||||
install(EXPORT hal DESTINATION share/hal)
|
||||
|
||||
# Java bindings
|
||||
if (WITH_JAVA)
|
||||
if(WITH_JAVA)
|
||||
find_package(Java REQUIRED)
|
||||
find_package(JNI REQUIRED)
|
||||
include(UseJava)
|
||||
@@ -80,17 +63,19 @@ if (WITH_JAVA)
|
||||
|
||||
file(GLOB_RECURSE hal_shared_jni_src src/main/native/cpp/jni/*.cpp)
|
||||
|
||||
file(GLOB_RECURSE JAVA_SOURCES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/FRCNetComm.java
|
||||
src/main/java/*.java)
|
||||
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
|
||||
set(CMAKE_JNI_TARGET true)
|
||||
|
||||
add_jar(hal_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME wpiHal GENERATE_NATIVE_HEADERS hal_jni_headers)
|
||||
add_jar(
|
||||
hal_jar
|
||||
${JAVA_SOURCES}
|
||||
INCLUDE_JARS wpiutil_jar
|
||||
OUTPUT_NAME wpiHal
|
||||
GENERATE_NATIVE_HEADERS hal_jni_headers
|
||||
)
|
||||
|
||||
get_property(HAL_JAR_FILE TARGET hal_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${HAL_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
|
||||
set_property(TARGET hal_jar PROPERTY FOLDER "java")
|
||||
install_jar(hal_jar DESTINATION ${java_lib_dest})
|
||||
install_jar_exports(TARGETS hal_jar FILE hal_jar.cmake DESTINATION share/hal)
|
||||
|
||||
add_library(haljni ${hal_shared_jni_src})
|
||||
|
||||
@@ -109,10 +94,35 @@ if (WITH_JAVA)
|
||||
add_dependencies(haljni hal_jar)
|
||||
|
||||
install(TARGETS haljni EXPORT haljni)
|
||||
|
||||
endif()
|
||||
|
||||
if (WITH_TESTS)
|
||||
if(WITH_JAVA_SOURCE)
|
||||
find_package(Java REQUIRED)
|
||||
include(UseJava)
|
||||
file(GLOB HAL_SOURCES src/main/java/edu/wpi/first/hal/*.java src/generated/main/java/*.java)
|
||||
file(GLOB HAL_CAN_SOURCES src/main/java/edu/wpi/first/hal/can/*.java)
|
||||
file(GLOB HAL_SIMULATION_SOURCES src/main/java/edu/wpi/first/hal/simulation/*.java)
|
||||
file(GLOB HAL_UTIL_SOURCES src/main/java/edu/wpi/first/hal/util/*.java)
|
||||
add_jar(
|
||||
hal_src_jar
|
||||
RESOURCES
|
||||
NAMESPACE "edu/wpi/first/hal" ${HAL_SOURCES}
|
||||
NAMESPACE "edu/wpi/first/hal/can" ${HAL_CAN_SOURCES}
|
||||
NAMESPACE
|
||||
"edu/wpi/first/hal/communication"
|
||||
src/main/java/edu/wpi/first/hal/communication/NIRioStatus.java
|
||||
NAMESPACE "edu/wpi/first/hal/simulation" ${HAL_SIMULATION_SOURCES}
|
||||
NAMESPACE "edu/wpi/first/hal/util" ${HAL_UTIL_SOURCES}
|
||||
OUTPUT_NAME wpiHal-sources
|
||||
)
|
||||
|
||||
get_property(HAL_SRC_JAR_FILE TARGET hal_src_jar PROPERTY JAR_FILE)
|
||||
install(FILES ${HAL_SRC_JAR_FILE} DESTINATION "${java_lib_dest}")
|
||||
|
||||
set_property(TARGET hal_src_jar PROPERTY FOLDER "java")
|
||||
endif()
|
||||
|
||||
if(WITH_TESTS)
|
||||
wpilib_add_test(hal src/test/native/cpp)
|
||||
target_link_libraries(hal_test hal gtest)
|
||||
endif()
|
||||
|
||||
@@ -1,60 +1,9 @@
|
||||
def javaResourceFile = file("$buildDir/generated/java/edu/wpi/first/hal/FRCNetComm.java")
|
||||
def cppResourceFile = file("$buildDir/generated/headers/hal/FRCUsageReporting.h")
|
||||
|
||||
def generateUsageReporting = tasks.register('generateUsageReporting') {
|
||||
def javaBase = file('src/generate/FRCNetComm.java.in')
|
||||
def cppBase = file('src/generate/FRCUsageReporting.h.in')
|
||||
|
||||
def instances = file('src/generate/Instances.txt')
|
||||
def resourceType = file('src/generate/ResourceType.txt')
|
||||
|
||||
inputs.file(javaBase)
|
||||
inputs.file(cppBase)
|
||||
inputs.file(instances)
|
||||
inputs.file(resourceType)
|
||||
|
||||
outputs.file(javaResourceFile)
|
||||
outputs.file(cppResourceFile)
|
||||
|
||||
doLast {
|
||||
def instanceTextJava = instances as String[]
|
||||
def instanceTextCpp = instances as String[]
|
||||
def resourceTextJava = resourceType as String[]
|
||||
def resourceTextCpp = resourceType as String[]
|
||||
|
||||
instanceTextJava = instanceTextJava.collect {
|
||||
" public static final int ${it};"
|
||||
}.join('\n')
|
||||
|
||||
instanceTextCpp = instanceTextCpp.collect {
|
||||
" ${it},"
|
||||
}.join('\n')
|
||||
|
||||
resourceTextJava = resourceTextJava.collect {
|
||||
" public static final int ${it};"
|
||||
}.join('\n')
|
||||
|
||||
resourceTextCpp = resourceTextCpp.collect {
|
||||
" ${it},"
|
||||
}.join('\n')
|
||||
|
||||
javaResourceFile.text = javaBase.text.replace('${usage_reporting_types}', resourceTextJava).replace('${usage_reporting_instances}', instanceTextJava)
|
||||
cppResourceFile.text = cppBase.text.replace('${usage_reporting_types_cpp}', resourceTextCpp).replace('${usage_reporting_instances_cpp}', instanceTextCpp)
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
addHalDependency = { binary, shared->
|
||||
binary.tasks.withType(AbstractNativeSourceCompileTask) {
|
||||
it.dependsOn generateUsageReporting
|
||||
}
|
||||
binary.lib project: ':hal', library: 'hal', linkage: shared
|
||||
}
|
||||
|
||||
addHalJniDependency = { binary->
|
||||
binary.tasks.withType(AbstractNativeSourceCompileTask) {
|
||||
it.dependsOn generateUsageReporting
|
||||
}
|
||||
binary.lib project: ':hal', library: 'halJNIShared', linkage: 'shared'
|
||||
}
|
||||
|
||||
@@ -62,16 +11,8 @@ ext {
|
||||
setBaseName = 'wpiHal'
|
||||
devMain = 'edu.wpi.first.hal.DevMain'
|
||||
niLibraries = true
|
||||
generatedHeaders = "$buildDir/generated/headers"
|
||||
jniSplitSetup = {
|
||||
it.tasks.withType(AbstractNativeSourceCompileTask) {
|
||||
it.dependsOn generateUsageReporting
|
||||
}
|
||||
}
|
||||
generatedHeaders = "src/generated/main/native/include"
|
||||
splitSetup = {
|
||||
it.tasks.withType(AbstractNativeSourceCompileTask) {
|
||||
it.dependsOn generateUsageReporting
|
||||
}
|
||||
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
||||
it.sources {
|
||||
athenaCpp(CppSourceSet) {
|
||||
@@ -109,11 +50,7 @@ ext {
|
||||
|
||||
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
|
||||
|
||||
sourceSets.main.java.srcDir "${buildDir}/generated/java/"
|
||||
|
||||
compileJava {
|
||||
dependsOn generateUsageReporting
|
||||
}
|
||||
sourceSets.main.java.srcDir "src/generated/main/java/edu/wpi/first/hal/"
|
||||
|
||||
cppSourcesZip {
|
||||
from('src/main/native/athena') {
|
||||
@@ -126,7 +63,6 @@ cppSourcesZip {
|
||||
}
|
||||
|
||||
cppHeadersZip {
|
||||
dependsOn generateUsageReporting
|
||||
from(generatedHeaders) {
|
||||
into '/'
|
||||
}
|
||||
@@ -160,9 +96,6 @@ nativeUtils.exportsConfigs {
|
||||
model {
|
||||
binaries {
|
||||
all {
|
||||
it.tasks.withType(AbstractNativeSourceCompileTask) {
|
||||
it.dependsOn generateUsageReporting
|
||||
}
|
||||
if (!(it instanceof NativeBinarySpec)) return
|
||||
if (it.component.name != 'hal' && it.component.name != 'halBase') return
|
||||
if (it.targetPlatform.name != nativeUtils.wpi.platforms.roborio) return
|
||||
|
||||
51
hal/generate_usage_reporting.py
Executable file
51
hal/generate_usage_reporting.py
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# 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.
|
||||
import pathlib
|
||||
|
||||
|
||||
def main():
|
||||
# Gets the folder this script is in (the hal/ directory)
|
||||
HAL_ROOT = pathlib.Path(__file__).parent
|
||||
java_package = "edu/wpi/first/hal"
|
||||
(HAL_ROOT/"src/generated/main/native/include/hal").mkdir(parents=True, exist_ok=True)
|
||||
(HAL_ROOT/f"src/generated/main/java/{java_package}").mkdir(parents=True, exist_ok=True)
|
||||
usage_reporting_types_cpp = []
|
||||
usage_reporting_instances_cpp = []
|
||||
usage_reporting_types = []
|
||||
usage_reporting_instances = []
|
||||
with open(HAL_ROOT/"src/generate/Instances.txt") as instances:
|
||||
for instance in instances:
|
||||
usage_reporting_instances_cpp.append(f" {instance.strip()},")
|
||||
usage_reporting_instances.append(
|
||||
f" /** {instance.strip()}. */\n"
|
||||
f" public static final int {instance.strip()};")
|
||||
|
||||
with open(HAL_ROOT/"src/generate/ResourceType.txt") as resource_types:
|
||||
for resource_type in resource_types:
|
||||
usage_reporting_types_cpp.append(f" {resource_type.strip()},")
|
||||
usage_reporting_types.append(
|
||||
f" /** {resource_type.strip()}. */\n"
|
||||
f" public static final int {resource_type.strip()};")
|
||||
|
||||
with open(HAL_ROOT/"src/generate/FRCNetComm.java.in") as java_usage_reporting:
|
||||
contents = (java_usage_reporting.read()
|
||||
.replace(r"${usage_reporting_types}", "\n".join(usage_reporting_types))
|
||||
.replace(r"${usage_reporting_instances}", "\n".join(usage_reporting_instances)))
|
||||
|
||||
with open(HAL_ROOT/f"src/generated/main/java/{java_package}/FRCNetComm.java", "w") as java_out:
|
||||
java_out.write(contents)
|
||||
|
||||
with open(HAL_ROOT/"src/generate/FRCUsageReporting.h.in") as cpp_usage_reporting:
|
||||
contents = (cpp_usage_reporting.read()
|
||||
.replace(r"${usage_reporting_types_cpp}", "\n".join(usage_reporting_types_cpp))
|
||||
.replace(r"${usage_reporting_instances_cpp}", "\n".join(usage_reporting_instances_cpp)))
|
||||
|
||||
with open(HAL_ROOT/"src/generated/main/native/include/hal/FRCUsageReporting.h", "w") as cpp_out:
|
||||
cpp_out.write(contents)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -4,3 +4,6 @@ include(CMakeFindDependencyMacro)
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/hal.cmake)
|
||||
if(@WITH_JAVA@)
|
||||
include(${SELF_DIR}/hal_jar.cmake)
|
||||
endif()
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*
|
||||
* Autogenerated file! Do not manually edit this file.
|
||||
*/
|
||||
// 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 ./hal/generate_usage_reporting.py. DO NOT MODIFY
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
// 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 ./hal/generate_usage_reporting.py. DO NOT MODIFY
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -12,6 +12,7 @@ kFramework_CommandControl = 3
|
||||
kFramework_Timed = 4
|
||||
kFramework_ROS = 5
|
||||
kFramework_RobotBuilder = 6
|
||||
kFramework_AdvantageKit = 7
|
||||
kRobotDrive_ArcadeStandard = 1
|
||||
kRobotDrive_ArcadeButtonSpin = 2
|
||||
kRobotDrive_ArcadeRatioCurve = 3
|
||||
|
||||
@@ -92,4 +92,25 @@ kResourceType_TrapezoidProfile = 90
|
||||
kResourceType_DutyCycle = 91
|
||||
kResourceType_AddressableLEDs = 92
|
||||
kResourceType_FusionVenom = 93
|
||||
kResourceType_PS4Controller = 94
|
||||
kResourceType_CTRE_future7 = 94
|
||||
kResourceType_CTRE_future8 = 95
|
||||
kResourceType_CTRE_future9 = 96
|
||||
kResourceType_CTRE_future10 = 97
|
||||
kResourceType_CTRE_future11 = 98
|
||||
kResourceType_CTRE_future12 = 99
|
||||
kResourceType_CTRE_future13 = 100
|
||||
kResourceType_CTRE_future14 = 101
|
||||
kResourceType_ExponentialProfile = 102
|
||||
kResourceType_PS4Controller = 103
|
||||
kResourceType_PhotonCamera = 104
|
||||
kResourceType_PhotonPoseEstimator = 105
|
||||
kResourceType_PathPlannerPath = 106
|
||||
kResourceType_PathPlannerAuto = 107
|
||||
kResourceType_PathFindingCommand = 108
|
||||
kResourceType_Redux_future1 = 109
|
||||
kResourceType_Redux_future2 = 110
|
||||
kResourceType_Redux_future3 = 111
|
||||
kResourceType_Redux_future4 = 112
|
||||
kResourceType_Redux_future5 = 113
|
||||
kResourceType_RevSparkFlexCAN = 114
|
||||
kResourceType_RevSparkFlexPWM = 115
|
||||
|
||||
370
hal/src/generated/main/java/edu/wpi/first/hal/FRCNetComm.java
generated
Normal file
370
hal/src/generated/main/java/edu/wpi/first/hal/FRCNetComm.java
generated
Normal file
@@ -0,0 +1,370 @@
|
||||
// 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 ./hal/generate_usage_reporting.py. DO NOT MODIFY
|
||||
|
||||
package edu.wpi.first.hal;
|
||||
|
||||
/**
|
||||
* JNI wrapper for library <b>FRC_NetworkCommunication</b><br>.
|
||||
*/
|
||||
public class FRCNetComm {
|
||||
/**
|
||||
* Resource type from UsageReporting.
|
||||
*/
|
||||
@SuppressWarnings("TypeName")
|
||||
public static final class tResourceType {
|
||||
private tResourceType() {
|
||||
}
|
||||
|
||||
/** kResourceType_Controller = 0. */
|
||||
public static final int kResourceType_Controller = 0;
|
||||
/** kResourceType_Module = 1. */
|
||||
public static final int kResourceType_Module = 1;
|
||||
/** kResourceType_Language = 2. */
|
||||
public static final int kResourceType_Language = 2;
|
||||
/** kResourceType_CANPlugin = 3. */
|
||||
public static final int kResourceType_CANPlugin = 3;
|
||||
/** kResourceType_Accelerometer = 4. */
|
||||
public static final int kResourceType_Accelerometer = 4;
|
||||
/** kResourceType_ADXL345 = 5. */
|
||||
public static final int kResourceType_ADXL345 = 5;
|
||||
/** kResourceType_AnalogChannel = 6. */
|
||||
public static final int kResourceType_AnalogChannel = 6;
|
||||
/** kResourceType_AnalogTrigger = 7. */
|
||||
public static final int kResourceType_AnalogTrigger = 7;
|
||||
/** kResourceType_AnalogTriggerOutput = 8. */
|
||||
public static final int kResourceType_AnalogTriggerOutput = 8;
|
||||
/** kResourceType_CANJaguar = 9. */
|
||||
public static final int kResourceType_CANJaguar = 9;
|
||||
/** kResourceType_Compressor = 10. */
|
||||
public static final int kResourceType_Compressor = 10;
|
||||
/** kResourceType_Counter = 11. */
|
||||
public static final int kResourceType_Counter = 11;
|
||||
/** kResourceType_Dashboard = 12. */
|
||||
public static final int kResourceType_Dashboard = 12;
|
||||
/** kResourceType_DigitalInput = 13. */
|
||||
public static final int kResourceType_DigitalInput = 13;
|
||||
/** kResourceType_DigitalOutput = 14. */
|
||||
public static final int kResourceType_DigitalOutput = 14;
|
||||
/** kResourceType_DriverStationCIO = 15. */
|
||||
public static final int kResourceType_DriverStationCIO = 15;
|
||||
/** kResourceType_DriverStationEIO = 16. */
|
||||
public static final int kResourceType_DriverStationEIO = 16;
|
||||
/** kResourceType_DriverStationLCD = 17. */
|
||||
public static final int kResourceType_DriverStationLCD = 17;
|
||||
/** kResourceType_Encoder = 18. */
|
||||
public static final int kResourceType_Encoder = 18;
|
||||
/** kResourceType_GearTooth = 19. */
|
||||
public static final int kResourceType_GearTooth = 19;
|
||||
/** kResourceType_Gyro = 20. */
|
||||
public static final int kResourceType_Gyro = 20;
|
||||
/** kResourceType_I2C = 21. */
|
||||
public static final int kResourceType_I2C = 21;
|
||||
/** kResourceType_Framework = 22. */
|
||||
public static final int kResourceType_Framework = 22;
|
||||
/** kResourceType_Jaguar = 23. */
|
||||
public static final int kResourceType_Jaguar = 23;
|
||||
/** kResourceType_Joystick = 24. */
|
||||
public static final int kResourceType_Joystick = 24;
|
||||
/** kResourceType_Kinect = 25. */
|
||||
public static final int kResourceType_Kinect = 25;
|
||||
/** kResourceType_KinectStick = 26. */
|
||||
public static final int kResourceType_KinectStick = 26;
|
||||
/** kResourceType_PIDController = 27. */
|
||||
public static final int kResourceType_PIDController = 27;
|
||||
/** kResourceType_Preferences = 28. */
|
||||
public static final int kResourceType_Preferences = 28;
|
||||
/** kResourceType_PWM = 29. */
|
||||
public static final int kResourceType_PWM = 29;
|
||||
/** kResourceType_Relay = 30. */
|
||||
public static final int kResourceType_Relay = 30;
|
||||
/** kResourceType_RobotDrive = 31. */
|
||||
public static final int kResourceType_RobotDrive = 31;
|
||||
/** kResourceType_SerialPort = 32. */
|
||||
public static final int kResourceType_SerialPort = 32;
|
||||
/** kResourceType_Servo = 33. */
|
||||
public static final int kResourceType_Servo = 33;
|
||||
/** kResourceType_Solenoid = 34. */
|
||||
public static final int kResourceType_Solenoid = 34;
|
||||
/** kResourceType_SPI = 35. */
|
||||
public static final int kResourceType_SPI = 35;
|
||||
/** kResourceType_Task = 36. */
|
||||
public static final int kResourceType_Task = 36;
|
||||
/** kResourceType_Ultrasonic = 37. */
|
||||
public static final int kResourceType_Ultrasonic = 37;
|
||||
/** kResourceType_Victor = 38. */
|
||||
public static final int kResourceType_Victor = 38;
|
||||
/** kResourceType_Button = 39. */
|
||||
public static final int kResourceType_Button = 39;
|
||||
/** kResourceType_Command = 40. */
|
||||
public static final int kResourceType_Command = 40;
|
||||
/** kResourceType_AxisCamera = 41. */
|
||||
public static final int kResourceType_AxisCamera = 41;
|
||||
/** kResourceType_PCVideoServer = 42. */
|
||||
public static final int kResourceType_PCVideoServer = 42;
|
||||
/** kResourceType_SmartDashboard = 43. */
|
||||
public static final int kResourceType_SmartDashboard = 43;
|
||||
/** kResourceType_Talon = 44. */
|
||||
public static final int kResourceType_Talon = 44;
|
||||
/** kResourceType_HiTechnicColorSensor = 45. */
|
||||
public static final int kResourceType_HiTechnicColorSensor = 45;
|
||||
/** kResourceType_HiTechnicAccel = 46. */
|
||||
public static final int kResourceType_HiTechnicAccel = 46;
|
||||
/** kResourceType_HiTechnicCompass = 47. */
|
||||
public static final int kResourceType_HiTechnicCompass = 47;
|
||||
/** kResourceType_SRF08 = 48. */
|
||||
public static final int kResourceType_SRF08 = 48;
|
||||
/** kResourceType_AnalogOutput = 49. */
|
||||
public static final int kResourceType_AnalogOutput = 49;
|
||||
/** kResourceType_VictorSP = 50. */
|
||||
public static final int kResourceType_VictorSP = 50;
|
||||
/** kResourceType_PWMTalonSRX = 51. */
|
||||
public static final int kResourceType_PWMTalonSRX = 51;
|
||||
/** kResourceType_CANTalonSRX = 52. */
|
||||
public static final int kResourceType_CANTalonSRX = 52;
|
||||
/** kResourceType_ADXL362 = 53. */
|
||||
public static final int kResourceType_ADXL362 = 53;
|
||||
/** kResourceType_ADXRS450 = 54. */
|
||||
public static final int kResourceType_ADXRS450 = 54;
|
||||
/** kResourceType_RevSPARK = 55. */
|
||||
public static final int kResourceType_RevSPARK = 55;
|
||||
/** kResourceType_MindsensorsSD540 = 56. */
|
||||
public static final int kResourceType_MindsensorsSD540 = 56;
|
||||
/** kResourceType_DigitalGlitchFilter = 57. */
|
||||
public static final int kResourceType_DigitalGlitchFilter = 57;
|
||||
/** kResourceType_ADIS16448 = 58. */
|
||||
public static final int kResourceType_ADIS16448 = 58;
|
||||
/** kResourceType_PDP = 59. */
|
||||
public static final int kResourceType_PDP = 59;
|
||||
/** kResourceType_PCM = 60. */
|
||||
public static final int kResourceType_PCM = 60;
|
||||
/** kResourceType_PigeonIMU = 61. */
|
||||
public static final int kResourceType_PigeonIMU = 61;
|
||||
/** kResourceType_NidecBrushless = 62. */
|
||||
public static final int kResourceType_NidecBrushless = 62;
|
||||
/** kResourceType_CANifier = 63. */
|
||||
public static final int kResourceType_CANifier = 63;
|
||||
/** kResourceType_TalonFX = 64. */
|
||||
public static final int kResourceType_TalonFX = 64;
|
||||
/** kResourceType_CTRE_future1 = 65. */
|
||||
public static final int kResourceType_CTRE_future1 = 65;
|
||||
/** kResourceType_CTRE_future2 = 66. */
|
||||
public static final int kResourceType_CTRE_future2 = 66;
|
||||
/** kResourceType_CTRE_future3 = 67. */
|
||||
public static final int kResourceType_CTRE_future3 = 67;
|
||||
/** kResourceType_CTRE_future4 = 68. */
|
||||
public static final int kResourceType_CTRE_future4 = 68;
|
||||
/** kResourceType_CTRE_future5 = 69. */
|
||||
public static final int kResourceType_CTRE_future5 = 69;
|
||||
/** kResourceType_CTRE_future6 = 70. */
|
||||
public static final int kResourceType_CTRE_future6 = 70;
|
||||
/** kResourceType_LinearFilter = 71. */
|
||||
public static final int kResourceType_LinearFilter = 71;
|
||||
/** kResourceType_XboxController = 72. */
|
||||
public static final int kResourceType_XboxController = 72;
|
||||
/** kResourceType_UsbCamera = 73. */
|
||||
public static final int kResourceType_UsbCamera = 73;
|
||||
/** kResourceType_NavX = 74. */
|
||||
public static final int kResourceType_NavX = 74;
|
||||
/** kResourceType_Pixy = 75. */
|
||||
public static final int kResourceType_Pixy = 75;
|
||||
/** kResourceType_Pixy2 = 76. */
|
||||
public static final int kResourceType_Pixy2 = 76;
|
||||
/** kResourceType_ScanseSweep = 77. */
|
||||
public static final int kResourceType_ScanseSweep = 77;
|
||||
/** kResourceType_Shuffleboard = 78. */
|
||||
public static final int kResourceType_Shuffleboard = 78;
|
||||
/** kResourceType_CAN = 79. */
|
||||
public static final int kResourceType_CAN = 79;
|
||||
/** kResourceType_DigilentDMC60 = 80. */
|
||||
public static final int kResourceType_DigilentDMC60 = 80;
|
||||
/** kResourceType_PWMVictorSPX = 81. */
|
||||
public static final int kResourceType_PWMVictorSPX = 81;
|
||||
/** kResourceType_RevSparkMaxPWM = 82. */
|
||||
public static final int kResourceType_RevSparkMaxPWM = 82;
|
||||
/** kResourceType_RevSparkMaxCAN = 83. */
|
||||
public static final int kResourceType_RevSparkMaxCAN = 83;
|
||||
/** kResourceType_ADIS16470 = 84. */
|
||||
public static final int kResourceType_ADIS16470 = 84;
|
||||
/** kResourceType_PIDController2 = 85. */
|
||||
public static final int kResourceType_PIDController2 = 85;
|
||||
/** kResourceType_ProfiledPIDController = 86. */
|
||||
public static final int kResourceType_ProfiledPIDController = 86;
|
||||
/** kResourceType_Kinematics = 87. */
|
||||
public static final int kResourceType_Kinematics = 87;
|
||||
/** kResourceType_Odometry = 88. */
|
||||
public static final int kResourceType_Odometry = 88;
|
||||
/** kResourceType_Units = 89. */
|
||||
public static final int kResourceType_Units = 89;
|
||||
/** kResourceType_TrapezoidProfile = 90. */
|
||||
public static final int kResourceType_TrapezoidProfile = 90;
|
||||
/** kResourceType_DutyCycle = 91. */
|
||||
public static final int kResourceType_DutyCycle = 91;
|
||||
/** kResourceType_AddressableLEDs = 92. */
|
||||
public static final int kResourceType_AddressableLEDs = 92;
|
||||
/** kResourceType_FusionVenom = 93. */
|
||||
public static final int kResourceType_FusionVenom = 93;
|
||||
/** kResourceType_CTRE_future7 = 94. */
|
||||
public static final int kResourceType_CTRE_future7 = 94;
|
||||
/** kResourceType_CTRE_future8 = 95. */
|
||||
public static final int kResourceType_CTRE_future8 = 95;
|
||||
/** kResourceType_CTRE_future9 = 96. */
|
||||
public static final int kResourceType_CTRE_future9 = 96;
|
||||
/** kResourceType_CTRE_future10 = 97. */
|
||||
public static final int kResourceType_CTRE_future10 = 97;
|
||||
/** kResourceType_CTRE_future11 = 98. */
|
||||
public static final int kResourceType_CTRE_future11 = 98;
|
||||
/** kResourceType_CTRE_future12 = 99. */
|
||||
public static final int kResourceType_CTRE_future12 = 99;
|
||||
/** kResourceType_CTRE_future13 = 100. */
|
||||
public static final int kResourceType_CTRE_future13 = 100;
|
||||
/** kResourceType_CTRE_future14 = 101. */
|
||||
public static final int kResourceType_CTRE_future14 = 101;
|
||||
/** kResourceType_ExponentialProfile = 102. */
|
||||
public static final int kResourceType_ExponentialProfile = 102;
|
||||
/** kResourceType_PS4Controller = 103. */
|
||||
public static final int kResourceType_PS4Controller = 103;
|
||||
/** kResourceType_PhotonCamera = 104. */
|
||||
public static final int kResourceType_PhotonCamera = 104;
|
||||
/** kResourceType_PhotonPoseEstimator = 105. */
|
||||
public static final int kResourceType_PhotonPoseEstimator = 105;
|
||||
/** kResourceType_PathPlannerPath = 106. */
|
||||
public static final int kResourceType_PathPlannerPath = 106;
|
||||
/** kResourceType_PathPlannerAuto = 107. */
|
||||
public static final int kResourceType_PathPlannerAuto = 107;
|
||||
/** kResourceType_PathFindingCommand = 108. */
|
||||
public static final int kResourceType_PathFindingCommand = 108;
|
||||
/** kResourceType_Redux_future1 = 109. */
|
||||
public static final int kResourceType_Redux_future1 = 109;
|
||||
/** kResourceType_Redux_future2 = 110. */
|
||||
public static final int kResourceType_Redux_future2 = 110;
|
||||
/** kResourceType_Redux_future3 = 111. */
|
||||
public static final int kResourceType_Redux_future3 = 111;
|
||||
/** kResourceType_Redux_future4 = 112. */
|
||||
public static final int kResourceType_Redux_future4 = 112;
|
||||
/** kResourceType_Redux_future5 = 113. */
|
||||
public static final int kResourceType_Redux_future5 = 113;
|
||||
/** kResourceType_RevSparkFlexCAN = 114. */
|
||||
public static final int kResourceType_RevSparkFlexCAN = 114;
|
||||
/** kResourceType_RevSparkFlexPWM = 115. */
|
||||
public static final int kResourceType_RevSparkFlexPWM = 115;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instances from UsageReporting.
|
||||
*/
|
||||
@SuppressWarnings("TypeName")
|
||||
public static final class tInstances {
|
||||
private tInstances() {
|
||||
}
|
||||
|
||||
/** kLanguage_LabVIEW = 1. */
|
||||
public static final int kLanguage_LabVIEW = 1;
|
||||
/** kLanguage_CPlusPlus = 2. */
|
||||
public static final int kLanguage_CPlusPlus = 2;
|
||||
/** kLanguage_Java = 3. */
|
||||
public static final int kLanguage_Java = 3;
|
||||
/** kLanguage_Python = 4. */
|
||||
public static final int kLanguage_Python = 4;
|
||||
/** kLanguage_DotNet = 5. */
|
||||
public static final int kLanguage_DotNet = 5;
|
||||
/** kLanguage_Kotlin = 6. */
|
||||
public static final int kLanguage_Kotlin = 6;
|
||||
/** kCANPlugin_BlackJagBridge = 1. */
|
||||
public static final int kCANPlugin_BlackJagBridge = 1;
|
||||
/** kCANPlugin_2CAN = 2. */
|
||||
public static final int kCANPlugin_2CAN = 2;
|
||||
/** kFramework_Iterative = 1. */
|
||||
public static final int kFramework_Iterative = 1;
|
||||
/** kFramework_Simple = 2. */
|
||||
public static final int kFramework_Simple = 2;
|
||||
/** kFramework_CommandControl = 3. */
|
||||
public static final int kFramework_CommandControl = 3;
|
||||
/** kFramework_Timed = 4. */
|
||||
public static final int kFramework_Timed = 4;
|
||||
/** kFramework_ROS = 5. */
|
||||
public static final int kFramework_ROS = 5;
|
||||
/** kFramework_RobotBuilder = 6. */
|
||||
public static final int kFramework_RobotBuilder = 6;
|
||||
/** kFramework_AdvantageKit = 7. */
|
||||
public static final int kFramework_AdvantageKit = 7;
|
||||
/** kRobotDrive_ArcadeStandard = 1. */
|
||||
public static final int kRobotDrive_ArcadeStandard = 1;
|
||||
/** kRobotDrive_ArcadeButtonSpin = 2. */
|
||||
public static final int kRobotDrive_ArcadeButtonSpin = 2;
|
||||
/** kRobotDrive_ArcadeRatioCurve = 3. */
|
||||
public static final int kRobotDrive_ArcadeRatioCurve = 3;
|
||||
/** kRobotDrive_Tank = 4. */
|
||||
public static final int kRobotDrive_Tank = 4;
|
||||
/** kRobotDrive_MecanumPolar = 5. */
|
||||
public static final int kRobotDrive_MecanumPolar = 5;
|
||||
/** kRobotDrive_MecanumCartesian = 6. */
|
||||
public static final int kRobotDrive_MecanumCartesian = 6;
|
||||
/** kRobotDrive2_DifferentialArcade = 7. */
|
||||
public static final int kRobotDrive2_DifferentialArcade = 7;
|
||||
/** kRobotDrive2_DifferentialTank = 8. */
|
||||
public static final int kRobotDrive2_DifferentialTank = 8;
|
||||
/** kRobotDrive2_DifferentialCurvature = 9. */
|
||||
public static final int kRobotDrive2_DifferentialCurvature = 9;
|
||||
/** kRobotDrive2_MecanumCartesian = 10. */
|
||||
public static final int kRobotDrive2_MecanumCartesian = 10;
|
||||
/** kRobotDrive2_MecanumPolar = 11. */
|
||||
public static final int kRobotDrive2_MecanumPolar = 11;
|
||||
/** kRobotDrive2_KilloughCartesian = 12. */
|
||||
public static final int kRobotDrive2_KilloughCartesian = 12;
|
||||
/** kRobotDrive2_KilloughPolar = 13. */
|
||||
public static final int kRobotDrive2_KilloughPolar = 13;
|
||||
/** kDriverStationCIO_Analog = 1. */
|
||||
public static final int kDriverStationCIO_Analog = 1;
|
||||
/** kDriverStationCIO_DigitalIn = 2. */
|
||||
public static final int kDriverStationCIO_DigitalIn = 2;
|
||||
/** kDriverStationCIO_DigitalOut = 3. */
|
||||
public static final int kDriverStationCIO_DigitalOut = 3;
|
||||
/** kDriverStationEIO_Acceleration = 1. */
|
||||
public static final int kDriverStationEIO_Acceleration = 1;
|
||||
/** kDriverStationEIO_AnalogIn = 2. */
|
||||
public static final int kDriverStationEIO_AnalogIn = 2;
|
||||
/** kDriverStationEIO_AnalogOut = 3. */
|
||||
public static final int kDriverStationEIO_AnalogOut = 3;
|
||||
/** kDriverStationEIO_Button = 4. */
|
||||
public static final int kDriverStationEIO_Button = 4;
|
||||
/** kDriverStationEIO_LED = 5. */
|
||||
public static final int kDriverStationEIO_LED = 5;
|
||||
/** kDriverStationEIO_DigitalIn = 6. */
|
||||
public static final int kDriverStationEIO_DigitalIn = 6;
|
||||
/** kDriverStationEIO_DigitalOut = 7. */
|
||||
public static final int kDriverStationEIO_DigitalOut = 7;
|
||||
/** kDriverStationEIO_FixedDigitalOut = 8. */
|
||||
public static final int kDriverStationEIO_FixedDigitalOut = 8;
|
||||
/** kDriverStationEIO_PWM = 9. */
|
||||
public static final int kDriverStationEIO_PWM = 9;
|
||||
/** kDriverStationEIO_Encoder = 10. */
|
||||
public static final int kDriverStationEIO_Encoder = 10;
|
||||
/** kDriverStationEIO_TouchSlider = 11. */
|
||||
public static final int kDriverStationEIO_TouchSlider = 11;
|
||||
/** kADXL345_SPI = 1. */
|
||||
public static final int kADXL345_SPI = 1;
|
||||
/** kADXL345_I2C = 2. */
|
||||
public static final int kADXL345_I2C = 2;
|
||||
/** kCommand_Scheduler = 1. */
|
||||
public static final int kCommand_Scheduler = 1;
|
||||
/** kCommand2_Scheduler = 2. */
|
||||
public static final int kCommand2_Scheduler = 2;
|
||||
/** kSmartDashboard_Instance = 1. */
|
||||
public static final int kSmartDashboard_Instance = 1;
|
||||
/** kKinematics_DifferentialDrive = 1. */
|
||||
public static final int kKinematics_DifferentialDrive = 1;
|
||||
/** kKinematics_MecanumDrive = 2. */
|
||||
public static final int kKinematics_MecanumDrive = 2;
|
||||
/** kKinematics_SwerveDrive = 3. */
|
||||
public static final int kKinematics_SwerveDrive = 3;
|
||||
/** kOdometry_DifferentialDrive = 1. */
|
||||
public static final int kOdometry_DifferentialDrive = 1;
|
||||
/** kOdometry_MecanumDrive = 2. */
|
||||
public static final int kOdometry_MecanumDrive = 2;
|
||||
/** kOdometry_SwerveDrive = 3. */
|
||||
public static final int kOdometry_SwerveDrive = 3;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user