Skip to content

Commit

Permalink
Merge branch 'solenoid-booleans' of https://github.com/narmstro2020/a…
Browse files Browse the repository at this point in the history
…llwpilib into solenoid-booleans
  • Loading branch information
narmstro2020 committed Oct 10, 2024
2 parents 83a0ab9 + 1f9687d commit 5ca9edb
Show file tree
Hide file tree
Showing 22 changed files with 359 additions and 132 deletions.
52 changes: 20 additions & 32 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ jobs:
- os: ubuntu-22.04
name: Linux
container: wpilib/roborio-cross-ubuntu:2024-22.04
flags: "--preset with-java-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
flags: "--preset with-java-and-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
- os: macOS-14
name: macOS
container: ""
env: "PATH=\"/opt/homebrew/opt/protobuf@3/bin:$PATH\""
flags: "--preset sccache -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DCMAKE_LIBRARY_PATH=/opt/homebrew/opt/protobuf@3/lib -DProtobuf_INCLUDE_DIR=/opt/homebrew/opt/protobuf@3/include -DProtobuf_PROTOC_EXECUTABLE=/opt/homebrew/opt/protobuf@3/bin/protoc"
flags: "--preset with-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DCMAKE_LIBRARY_PATH=/opt/homebrew/opt/protobuf@3/lib -DProtobuf_INCLUDE_DIR=/opt/homebrew/opt/protobuf@3/include -DProtobuf_PROTOC_EXECUTABLE=/opt/homebrew/opt/protobuf@3/bin/protoc"
- os: windows-2022
name: Windows
container: ""
flags: '--preset with-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=OFF -DCMAKE_TOOLCHAIN_FILE="$Env: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'

name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
Expand All @@ -35,52 +39,30 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java libprotobuf-dev protobuf-compiler ninja-build

- name: Install dependencies (macOS)
run: brew install opencv protobuf@3 ninja
if: runner.os == 'macOS'
run: brew install opencv protobuf@3 ninja

- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.5

- uses: actions/checkout@v4

- name: configure
run: cmake ${{ matrix.flags }}
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: build
run: cmake --build build-cmake --parallel $(nproc)
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: test
working-directory: build-cmake
run: ctest --output-on-failure

build-windows:
name: "Build - Windows"
runs-on: windows-2022
steps:
- uses: ilammy/msvc-dev-cmd@v1.13.0
if: runner.os == 'Windows'

- name: Install CMake
- name: Install CMake (Windows only)
if: runner.os == 'Windows'
uses: lukka/get-cmake@v3.29.3

- name: Run sccache-cache
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.5

- uses: actions/checkout@v4

- name: Run vcpkg
- name: Run vcpkg (Windows only)
if: runner.os == 'Windows'
uses: lukka/run-vcpkg@v11.5
with:
vcpkgDirectory: ${{ runner.workspace }}/vcpkg
vcpkgGitCommitId: 37c3e63a1306562f7f59c4c3c8892ddd50fdf992 # HEAD on 2024-02-24

- name: configure
run: cmake --preset sccache -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=OFF -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
run: cmake ${{ matrix.flags }}
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
Expand All @@ -92,6 +74,12 @@ jobs:
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: test
if: runner.os != 'Windows'
working-directory: build-cmake
run: ctest --output-on-failure

- name: test (windows)
if: runner.os == 'Windows'
working-directory: build-cmake
# UnitTest_test segfaults on exit occasionally
run: ctest --output-on-failure -E 'UnitTest'
2 changes: 1 addition & 1 deletion .github/workflows/comment-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
distribution: 'temurin'
java-version: 17
- name: Install wpiformat
run: pip3 install wpiformat==2024.41
run: pip3 install wpiformat==2024.42
- name: Run wpiformat
run: wpiformat
- name: Run spotlessApply
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
python-version: '3.10'
- name: Install wpiformat
run: pip3 install wpiformat==2024.41
run: pip3 install wpiformat==2024.42
- name: Run
run: wpiformat
- name: Check output
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
with:
python-version: '3.10'
- name: Install wpiformat
run: pip3 install wpiformat==2024.41
run: pip3 install wpiformat==2024.42
- name: Create compile_commands.json
run: |
./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
Expand Down
161 changes: 161 additions & 0 deletions .github/workflows/sentinel-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Sentinel Build (No Cache)

on:
workflow_dispatch:
schedule:
- cron: "15 3 * * Sat" # 11:15PM EST every Friday

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build-docker:
if: (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main') || github.event_name != 'schedule'
strategy:
fail-fast: false
matrix:
include:
- container: wpilib/roborio-cross-ubuntu:2024-22.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
artifact-name: Arm32
build-options: "-Ponlylinuxarm32"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/ubuntu-base:22.04
artifact-name: Linux
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ubuntu-22.04
steps:
- name: Free Disk Space
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
with:
fetch-depth: 0
- name: Build with Gradle
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/work -w /work -e GITHUB_REF -e CI
run: df . && rm -f semicolon_delimited_script && echo $GITHUB_REF && ./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
- name: Check free disk space
run: df .
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: build/allOutputs

build-host:
if: (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main') || github.event_name != 'schedule'
env:
MACOSX_DEPLOYMENT_TARGET: 13.3
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
artifact-name: Win64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win64Release
architecture: x64
build-options: "-PciReleaseOnly"
task: "copyAllOutputs"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: WinArm64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly -Pbuildwinarm64 -Ponlywindowsarm64"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: WinArm64Release
architecture: x64
build-options: "-PciReleaseOnly -Pbuildwinarm64 -Ponlywindowsarm64"
task: "copyAllOutputs"
outputs: "build/allOutputs"
- os: macOS-14
artifact-name: macOS
architecture: aarch64
task: "build"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win32
architecture: x86
task: ":ntcoreffi:build"
outputs: "ntcoreffi/build/outputs"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
architecture: ${{ matrix.architecture }}
- name: Import Developer ID Certificate
uses: wpilibsuite/import-signing-certificate@v2
with:
certificate-data: ${{ secrets.APPLE_CERTIFICATE_DATA }}
certificate-passphrase: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
keychain-password: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Set Keychain Lock Timeout
run: security set-keychain-settings -lut 3600
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Set Java Heap Size
run: sed -i 's/-Xmx2g/-Xmx1g/g' gradle.properties
if: matrix.artifact-name == 'Win32'
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Check disk free space pre-cleanup (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- name: Cleanup disk space
# CodeQL: 5G
# go: 748M
# Android: 12G
run: |
rm -rf /Users/runner/hostedtoolcache/CodeQL
rm -rf /Users/runner/hostedtoolcache/go
rm -rf /Users/runner/Library/Android
if: matrix.os == 'macOS-14'
- name: Check disk free space post-cleanup (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- name: Build with Gradle
run: ./gradlew ${{ matrix.task }} -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
- name: Sign Libraries with Developer ID
run: ./gradlew copyAllOutputs -PbuildServer -PskipJavaFormat -PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} ${{ matrix.build-options }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Check disk free space (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.outputs }}
6 changes: 3 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"cacheVariables": {}
},
{
"name": "sccache",
"name": "with-sccache",
"displayName": "",
"description": "Ninja config with sccache",
"generator": "Ninja",
Expand All @@ -36,11 +36,11 @@
}
},
{
"name": "with-java-sccache",
"name": "with-java-and-sccache",
"displayName": "",
"description": "Ninja config with Java and sccache",
"generator": "Ninja",
"inherits": "sccache",
"inherits": "with-sccache",
"binaryDir": "build-cmake",
"cacheVariables": {
"WITH_JAVA": "ON"
Expand Down
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/DigitalOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ void DigitalOutput::DisablePWM() {
int32_t status = 0;

// Disable the output by routing to a dead bit.
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator, SensorUtil::kDigitalChannels,
&status);
HAL_SetDigitalPWMOutputChannel(m_pwmGenerator,
SensorUtil::GetNumDigitalChannels(), &status);
FRC_CheckErrorStatus(status, "Channel {}", m_channel);

HAL_FreeDigitalPWM(m_pwmGenerator);
Expand Down
12 changes: 7 additions & 5 deletions wpilibc/src/main/native/cpp/LEDPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ LEDPattern LEDPattern::Blink(units::second_t onTime, units::second_t offTime) {
if (wpi::Now() % totalMicros < onMicros) {
self.ApplyTo(data, writer);
} else {
LEDPattern::kOff.ApplyTo(data, writer);
LEDPattern::Off().ApplyTo(data, writer);
}
}};
}
Expand All @@ -118,7 +118,7 @@ LEDPattern LEDPattern::SynchronizedBlink(std::function<bool()> signal) {
if (signal()) {
self.ApplyTo(data, writer);
} else {
LEDPattern::kOff.ApplyTo(data, writer);
LEDPattern::Off().ApplyTo(data, writer);
}
}};
}
Expand Down Expand Up @@ -198,7 +198,9 @@ LEDPattern LEDPattern::AtBrightness(double relativeBrightness) {

// Static constants and functions

LEDPattern LEDPattern::kOff = LEDPattern::Solid(Color::kBlack);
LEDPattern LEDPattern::Off() {
return LEDPattern::Solid(Color::kBlack);
}

LEDPattern LEDPattern::Solid(const Color color) {
return LEDPattern{[=](auto data, auto writer) {
Expand Down Expand Up @@ -228,7 +230,7 @@ LEDPattern LEDPattern::ProgressMaskLayer(
LEDPattern LEDPattern::Steps(std::span<const std::pair<double, Color>> steps) {
if (steps.size() == 0) {
// no colors specified
return LEDPattern::kOff;
return LEDPattern::Off();
}
if (steps.size() == 1 && steps[0].first == 0) {
// only one color specified, just show a static color
Expand Down Expand Up @@ -264,7 +266,7 @@ LEDPattern LEDPattern::Steps(
LEDPattern LEDPattern::Gradient(std::span<const Color> colors) {
if (colors.size() == 0) {
// no colors specified
return LEDPattern::kOff;
return LEDPattern::Off();
}
if (colors.size() == 1) {
// only one color specified, just show a static color
Expand Down
26 changes: 20 additions & 6 deletions wpilibc/src/main/native/cpp/SensorUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@

using namespace frc;

const int SensorUtil::kDigitalChannels = HAL_GetNumDigitalChannels();
const int SensorUtil::kAnalogInputs = HAL_GetNumAnalogInputs();
const int SensorUtil::kAnalogOutputs = HAL_GetNumAnalogOutputs();
const int SensorUtil::kPwmChannels = HAL_GetNumPWMChannels();
const int SensorUtil::kRelayChannels = HAL_GetNumRelayHeaders();

int SensorUtil::GetDefaultCTREPCMModule() {
return 0;
}
Expand Down Expand Up @@ -46,3 +40,23 @@ bool SensorUtil::CheckAnalogInputChannel(int channel) {
bool SensorUtil::CheckAnalogOutputChannel(int channel) {
return HAL_CheckAnalogOutputChannel(channel);
}

int SensorUtil::GetNumDigitalChannels() {
return HAL_GetNumDigitalChannels();
}

int SensorUtil::GetNumAnalogInputs() {
return HAL_GetNumAnalogInputs();
}

int SensorUtil::GetNumAnalogOuputs() {
return HAL_GetNumAnalogOutputs();
}

int SensorUtil::GetNumPwmChannels() {
return HAL_GetNumPWMChannels();
}

int SensorUtil::GetNumRelayChannels() {
return HAL_GetNumRelayHeaders();
}
Loading

0 comments on commit 5ca9edb

Please sign in to comment.