From 306a7ffc6ca6cbb5a8f0a1e0b6cfd6607c96e198 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 6 Sep 2024 09:01:29 -0500 Subject: [PATCH] WIP C++example rework. poseest working decently now. --- .../docs/contributing/building-photon.md | 16 +- .../apriltagExample/build.gradle | 116 --------- .../apriltagExample/gradlew.bat | 91 ------- .../apriltagExample/simgui-ds.json | 102 -------- .../apriltagExample/simgui-window.json | 81 ------ .../apriltagExample/simgui.json | 40 --- .../src/main/cpp/Drivetrain.cpp | 92 ------- .../apriltagExample/src/main/cpp/Robot.cpp | 61 ----- .../src/main/include/Drivetrain.h | 140 ---------- .../src/main/include/PhotonCameraWrapper.h | 53 ---- .../apriltagExample/src/main/include/Robot.h | 50 ---- photonlib-cpp-examples/getinrange/.gitignore | 1 - .../.wpilib/wpilib_preferences.json | 6 - .../getinrange/WPILib-License.md | 24 -- .../getinrange/build.gradle | 116 --------- photonlib-cpp-examples/getinrange/gradlew | 241 ------------------ photonlib-cpp-examples/getinrange/gradlew.bat | 91 ------- .../getinrange/settings.gradle | 30 --- .../getinrange/simgui-window.json | 60 ----- photonlib-cpp-examples/getinrange/simgui.json | 7 - .../getinrange/src/main/include/Robot.h | 67 ----- .../getinrange/src/test/cpp/main.cpp | 34 --- .../{apriltagExample => poseest}/.gitignore | 0 .../.wpilib/wpilib_preferences.json | 0 .../WPILib-License.md | 0 .../build.gradle | 0 .../{apriltagExample => poseest}/gradlew | 0 .../gradlew.bat | 0 .../networktables.json | 0 .../settings.gradle | 0 .../{getinrange => poseest}/simgui-ds.json | 7 +- .../simgui-window.json | 30 ++- photonlib-cpp-examples/poseest/simgui.json | 161 ++++++++++++ .../src/main/cpp/Robot.cpp | 60 ++--- .../cpp/subsystems/GamepieceLauncher.cpp} | 60 ++--- .../src/main/cpp/subsystems/SwerveDrive.cpp | 8 +- .../main/cpp/subsystems/SwerveDriveSim.cpp | 0 .../src/main/cpp/subsystems/SwerveModule.cpp | 0 .../src/main/deploy/example.txt | 0 .../src/main/include/Constants.h | 0 .../src/main/include/Robot.h | 9 +- .../src/main/include/Vision.h | 0 .../include/subsystems/GamepieceLauncher.h | 66 +++++ .../src/main/include/subsystems/SwerveDrive.h | 2 +- .../main/include/subsystems/SwerveDriveSim.h | 0 .../main/include/subsystems/SwerveModule.h | 0 .../src/test/cpp/main.cpp | 0 .../swerve_module.png | Bin .../tag-blue.png | Bin .../tag-green.png | Bin .../swervedriveposeestsim/.gitignore | 1 - .../.wpilib/wpilib_preferences.json | 6 - .../swervedriveposeestsim/WPILib-License.md | 24 -- .../swervedriveposeestsim/gradlew | 241 ------------------ .../swervedriveposeestsim/networktables.json | 1 - .../swervedriveposeestsim/settings.gradle | 30 --- .../swervedriveposeestsim/simgui-ds.json | 98 ------- .../swervedriveposeestsim/simgui.json | 57 ----- .../src/test/cpp/main.cpp | 34 --- photonlib-java-examples/poseest/simgui.json | 10 +- 60 files changed, 321 insertions(+), 2103 deletions(-) delete mode 100644 photonlib-cpp-examples/apriltagExample/build.gradle delete mode 100644 photonlib-cpp-examples/apriltagExample/gradlew.bat delete mode 100644 photonlib-cpp-examples/apriltagExample/simgui-ds.json delete mode 100644 photonlib-cpp-examples/apriltagExample/simgui-window.json delete mode 100644 photonlib-cpp-examples/apriltagExample/simgui.json delete mode 100644 photonlib-cpp-examples/apriltagExample/src/main/cpp/Drivetrain.cpp delete mode 100644 photonlib-cpp-examples/apriltagExample/src/main/cpp/Robot.cpp delete mode 100644 photonlib-cpp-examples/apriltagExample/src/main/include/Drivetrain.h delete mode 100644 photonlib-cpp-examples/apriltagExample/src/main/include/PhotonCameraWrapper.h delete mode 100644 photonlib-cpp-examples/apriltagExample/src/main/include/Robot.h delete mode 100644 photonlib-cpp-examples/getinrange/.gitignore delete mode 100644 photonlib-cpp-examples/getinrange/.wpilib/wpilib_preferences.json delete mode 100644 photonlib-cpp-examples/getinrange/WPILib-License.md delete mode 100644 photonlib-cpp-examples/getinrange/build.gradle delete mode 100755 photonlib-cpp-examples/getinrange/gradlew delete mode 100644 photonlib-cpp-examples/getinrange/gradlew.bat delete mode 100644 photonlib-cpp-examples/getinrange/settings.gradle delete mode 100644 photonlib-cpp-examples/getinrange/simgui-window.json delete mode 100644 photonlib-cpp-examples/getinrange/simgui.json delete mode 100644 photonlib-cpp-examples/getinrange/src/main/include/Robot.h delete mode 100644 photonlib-cpp-examples/getinrange/src/test/cpp/main.cpp rename photonlib-cpp-examples/{apriltagExample => poseest}/.gitignore (100%) rename photonlib-cpp-examples/{apriltagExample => poseest}/.wpilib/wpilib_preferences.json (100%) rename photonlib-cpp-examples/{apriltagExample => poseest}/WPILib-License.md (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/build.gradle (100%) rename photonlib-cpp-examples/{apriltagExample => poseest}/gradlew (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/gradlew.bat (100%) rename photonlib-cpp-examples/{apriltagExample => poseest}/networktables.json (100%) rename photonlib-cpp-examples/{apriltagExample => poseest}/settings.gradle (100%) rename photonlib-cpp-examples/{getinrange => poseest}/simgui-ds.json (94%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/simgui-window.json (68%) create mode 100644 photonlib-cpp-examples/poseest/simgui.json rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/cpp/Robot.cpp (74%) rename photonlib-cpp-examples/{getinrange/src/main/cpp/Robot.cpp => poseest/src/main/cpp/subsystems/GamepieceLauncher.cpp} (50%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/cpp/subsystems/SwerveDrive.cpp (97%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/cpp/subsystems/SwerveDriveSim.cpp (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/cpp/subsystems/SwerveModule.cpp (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/deploy/example.txt (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/include/Constants.h (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/include/Robot.h (85%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/include/Vision.h (100%) create mode 100644 photonlib-cpp-examples/poseest/src/main/include/subsystems/GamepieceLauncher.h rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/include/subsystems/SwerveDrive.h (98%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/include/subsystems/SwerveDriveSim.h (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/src/main/include/subsystems/SwerveModule.h (100%) rename photonlib-cpp-examples/{apriltagExample => poseest}/src/test/cpp/main.cpp (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/swerve_module.png (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/tag-blue.png (100%) rename photonlib-cpp-examples/{swervedriveposeestsim => poseest}/tag-green.png (100%) delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/.gitignore delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/.wpilib/wpilib_preferences.json delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/WPILib-License.md delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/gradlew delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/networktables.json delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/settings.gradle delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/simgui-ds.json delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/simgui.json delete mode 100644 photonlib-cpp-examples/swervedriveposeestsim/src/test/cpp/main.cpp diff --git a/docs/source/docs/contributing/building-photon.md b/docs/source/docs/contributing/building-photon.md index 8f2fb8c182..55c483a98d 100644 --- a/docs/source/docs/contributing/building-photon.md +++ b/docs/source/docs/contributing/building-photon.md @@ -243,19 +243,9 @@ The program will wait for the VSCode debugger to attach before proceeding. ### Running examples -You can run one of the many built in examples straight from the command line, too! They contain a fully featured robot project, and some include simulation support. The projects can be found inside the photonlib-java-examples and photonlib-cpp-examples subdirectories, respectively. The projects currently available include: - -- photonlib-java-examples: - - aimandrange:simulateJava - - aimattarget:simulateJava - - getinrange:simulateJava - - simaimandrange:simulateJava - - simposeest:simulateJava -- photonlib-cpp-examples: - - aimandrange:simulateNative - - getinrange:simulateNative - -To run them, use the commands listed below. PhotonLib must first be published to your local maven repository, then the copy PhotonLib task will copy the generated vendordep json file into each example. After that, the simulateJava/simulateNative task can be used like a normal robot project. Robot simulation with attached debugger is technically possible by using simulateExternalJava and modifying the launch script it exports, though unsupported. +You can run one of the many built in examples straight from the command line, too! They contain a fully featured robot project, and some include simulation support. The projects can be found inside the photonlib-java-examples and photonlib-cpp-examples subdirectories, respectively. + +To run them, use the commands listed below. PhotonLib must first be published to your local maven repository, then the copy PhotonLib task will copy the generated vendordep json file into each example. After that, the simulateJava/simulateNative task can be used like a normal robot project. Robot simulation with attached debugger is technically possible by using simulateExternalJava and modifying the launch script it exports, though not yet supported. ``` ~/photonvision$ ./gradlew publishToMavenLocal diff --git a/photonlib-cpp-examples/apriltagExample/build.gradle b/photonlib-cpp-examples/apriltagExample/build.gradle deleted file mode 100644 index 9ae88e1577..0000000000 --- a/photonlib-cpp-examples/apriltagExample/build.gradle +++ /dev/null @@ -1,116 +0,0 @@ -plugins { - id "cpp" - id "google-test-test-suite" - id "edu.wpi.first.GradleRIO" version "2024.3.2" - - id "com.dorongold.task-tree" version "2.1.0" -} - -repositories { - mavenLocal() - jcenter() -} - -apply from: "${rootDir}/../shared/examples_common.gradle" - -// Define my targets (RoboRIO) and artifacts (deployable files) -// This is added by GradleRIO's backing project DeployUtils. -deploy { - targets { - roborio(getTargetTypeClass('RoboRIO')) { - // Team number is loaded either from the .wpilib/wpilib_preferences.json - // or from command line. If not found an exception will be thrown. - // You can use getTeamOrDefault(team) instead of getTeamNumber if you - // want to store a team number in this file. - team = project.frc.getTeamOrDefault(5940) - debug = project.frc.getDebugOrDefault(false) - - artifacts { - // First part is artifact name, 2nd is artifact type - // getTargetTypeClass is a shortcut to get the class type using a string - - frcCpp(getArtifactTypeClass('FRCNativeArtifact')) { - } - - // Static files artifact - frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) { - files = project.fileTree('src/main/deploy') - directory = '/home/lvuser/deploy' - } - } - } - } -} - -def deployArtifact = deploy.targets.roborio.artifacts.frcCpp - -// Set this to true to enable desktop support. -def includeDesktopSupport = true - -// Set to true to run simulation in debug mode -wpi.cpp.debugSimulation = false - -// Default enable simgui -wpi.sim.addGui().defaultEnabled = true -// Enable DS but not by default -wpi.sim.addDriverstation() - -model { - components { - frcUserProgram(NativeExecutableSpec) { - // We don't need to build for roborio -- if we do, we need to install - // a roborio toolchain every time we build in CI - // Ideally, we'd be able to set the roborio toolchain as optional, but - // I can't figure out how to set that environment variable from build.gradle - // (see https://github.com/wpilibsuite/native-utils/blob/2917c69fb5094e36d499c465f047dab81c68446c/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/ToolchainGraphBuildService.java#L71) - // for now, commented out - - // targetPlatform wpi.platforms.roborio - - if (includeDesktopSupport) { - targetPlatform wpi.platforms.desktop - } - - sources.cpp { - source { - srcDir 'src/main/cpp' - include '**/*.cpp', '**/*.cc' - } - exportedHeaders { - srcDir 'src/main/include' - } - } - - // Set deploy task to deploy this component - deployArtifact.component = it - - // Enable run tasks for this component - wpi.cpp.enableExternalTasks(it) - - // Enable simulation for this component - wpi.sim.enable(it) - // Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. - wpi.cpp.vendor.cpp(it) - wpi.cpp.deps.wpilib(it) - } - } - testSuites { - frcUserProgramTest(GoogleTestTestSuiteSpec) { - testing $.components.frcUserProgram - - sources.cpp { - source { - srcDir 'src/test/cpp' - include '**/*.cpp' - } - } - - // Enable run tasks for this component - wpi.cpp.enableExternalTasks(it) - - wpi.cpp.vendor.cpp(it) - wpi.cpp.deps.wpilib(it) - wpi.cpp.deps.googleTest(it) - } - } -} diff --git a/photonlib-cpp-examples/apriltagExample/gradlew.bat b/photonlib-cpp-examples/apriltagExample/gradlew.bat deleted file mode 100644 index 53a6b238d4..0000000000 --- a/photonlib-cpp-examples/apriltagExample/gradlew.bat +++ /dev/null @@ -1,91 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/photonlib-cpp-examples/apriltagExample/simgui-ds.json b/photonlib-cpp-examples/apriltagExample/simgui-ds.json deleted file mode 100644 index 7b51005024..0000000000 --- a/photonlib-cpp-examples/apriltagExample/simgui-ds.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "Keyboard 0 Settings": { - "window": { - "visible": true - } - }, - "keyboardJoysticks": [ - { - "axisConfig": [ - {}, - { - "decKey": 87, - "incKey": 83 - }, - { - "decayRate": 0.0, - "keyRate": 0.009999999776482582 - }, - {}, - { - "decKey": 65, - "incKey": 68 - } - ], - "axisCount": 6, - "buttonCount": 4, - "buttonKeys": [ - 90, - 88, - 67, - 86 - ], - "povConfig": [ - { - "key0": 328, - "key135": 323, - "key180": 322, - "key225": 321, - "key270": 324, - "key315": 327, - "key45": 329, - "key90": 326 - } - ], - "povCount": 1 - }, - { - "axisConfig": [ - { - "decKey": 74, - "incKey": 76 - }, - { - "decKey": 73, - "incKey": 75 - } - ], - "axisCount": 2, - "buttonCount": 4, - "buttonKeys": [ - 77, - 44, - 46, - 47 - ], - "povCount": 0 - }, - { - "axisConfig": [ - { - "decKey": 263, - "incKey": 262 - }, - { - "decKey": 265, - "incKey": 264 - } - ], - "axisCount": 2, - "buttonCount": 6, - "buttonKeys": [ - 260, - 268, - 266, - 261, - 269, - 267 - ], - "povCount": 0 - }, - { - "axisCount": 0, - "buttonCount": 0, - "povCount": 0 - } - ], - "robotJoysticks": [ - { - "guid": "Keyboard0" - } - ] -} diff --git a/photonlib-cpp-examples/apriltagExample/simgui-window.json b/photonlib-cpp-examples/apriltagExample/simgui-window.json deleted file mode 100644 index 79d676b16b..0000000000 --- a/photonlib-cpp-examples/apriltagExample/simgui-window.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "Docking": { - "Data": [] - }, - "MainWindow": { - "GLOBAL": { - "fps": "120", - "height": "880", - "maximized": "0", - "style": "0", - "userScale": "2", - "width": "1652", - "xpos": "268", - "ypos": "82" - } - }, - "Table": { - "0x542B5671,2": { - "Column 0 Width": "391", - "Column 1 Width": "156", - "RefScale": "13" - } - }, - "Window": { - "###/SmartDashboard/Field": { - "Collapsed": "0", - "Pos": "514,2", - "Size": "517,341" - }, - "###FMS": { - "Collapsed": "0", - "Pos": "36,663", - "Size": "283,146" - }, - "###Joysticks": { - "Collapsed": "0", - "Pos": "373,500", - "Size": "796,206" - }, - "###Keyboard 0 Settings": { - "Collapsed": "0", - "Pos": "149,98", - "Size": "300,560" - }, - "###NetworkTables": { - "Collapsed": "0", - "Pos": "663,464", - "Size": "750,365" - }, - "###NetworkTables Info": { - "Collapsed": "0", - "Pos": "520,330", - "Size": "750,145" - }, - "###Other Devices": { - "Collapsed": "0", - "Pos": "1025,20", - "Size": "250,695" - }, - "###System Joysticks": { - "Collapsed": "0", - "Pos": "5,350", - "Size": "192,218" - }, - "###Timing": { - "Collapsed": "0", - "Pos": "5,150", - "Size": "135,127" - }, - "Debug##Default": { - "Collapsed": "0", - "Pos": "60,60", - "Size": "400,400" - }, - "Robot State": { - "Collapsed": "0", - "Pos": "5,20", - "Size": "92,99" - } - } -} diff --git a/photonlib-cpp-examples/apriltagExample/simgui.json b/photonlib-cpp-examples/apriltagExample/simgui.json deleted file mode 100644 index bb09beb6ee..0000000000 --- a/photonlib-cpp-examples/apriltagExample/simgui.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "NTProvider": { - "types": { - "/FMSInfo": "FMSInfo", - "/SmartDashboard/Field": "Field2d" - }, - "windows": { - "/SmartDashboard/Field": { - "window": { - "visible": true - } - } - } - }, - "NetworkTables": { - "transitory": { - "CameraPublisher": { - "open": true - }, - "SmartDashboard": { - "open": true - }, - "photonvision": { - "open": true, - "photonvision": { - "open": true - } - } - } - }, - "NetworkTables Info": { - "Clients": { - "open": true - }, - "Server": { - "open": true - }, - "visible": true - } -} diff --git a/photonlib-cpp-examples/apriltagExample/src/main/cpp/Drivetrain.cpp b/photonlib-cpp-examples/apriltagExample/src/main/cpp/Drivetrain.cpp deleted file mode 100644 index c92980b7f6..0000000000 --- a/photonlib-cpp-examples/apriltagExample/src/main/cpp/Drivetrain.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "Drivetrain.h" - -#include -#include - -void Drivetrain::SetSpeeds(const frc::DifferentialDriveWheelSpeeds& speeds) { - auto leftFeedforward = m_feedforward.Calculate(speeds.left); - auto rightFeedforward = m_feedforward.Calculate(speeds.right); - double leftOutput = m_leftPIDController.Calculate(m_leftEncoder.GetRate(), - speeds.left.value()); - double rightOutput = m_rightPIDController.Calculate(m_rightEncoder.GetRate(), - speeds.right.value()); - - m_leftGroup.SetVoltage(units::volt_t{leftOutput} + leftFeedforward); - m_rightGroup.SetVoltage(units::volt_t{rightOutput} + rightFeedforward); -} - -void Drivetrain::Drive(units::meters_per_second_t xSpeed, - units::radians_per_second_t rot) { - SetSpeeds(m_kinematics.ToWheelSpeeds({xSpeed, 0_mps, rot})); -} - -void Drivetrain::UpdateOdometry() { - m_poseEstimator.Update(m_gyro.GetRotation2d(), - units::meter_t{m_leftEncoder.GetDistance()}, - units::meter_t{m_rightEncoder.GetDistance()}); -} - -void Drivetrain::ResetOdometry(const frc::Pose2d& pose) { - m_leftEncoder.Reset(); - m_rightEncoder.Reset(); - m_drivetrainSimulator.SetPose(pose); - m_poseEstimator.ResetPosition( - m_gyro.GetRotation2d(), units::meter_t{m_leftEncoder.GetDistance()}, - units::meter_t{m_rightEncoder.GetDistance()}, pose); -} - -void Drivetrain::SimulationPeriodic() { - // To update our simulation, we set motor voltage inputs, update the - // simulation, and write the simulated positions and velocities to our - // simulated encoder and gyro. We negate the right side so that positive - // voltages make the right side move forward. - - m_drivetrainSimulator.SetInputs(units::volt_t{m_leftGroup.Get()} * - frc::RobotController::GetInputVoltage(), - units::volt_t{m_rightGroup.Get()} * - frc::RobotController::GetInputVoltage()); - m_drivetrainSimulator.Update(20_ms); - - m_leftEncoderSim.SetDistance(m_drivetrainSimulator.GetLeftPosition().value()); - m_leftEncoderSim.SetRate(m_drivetrainSimulator.GetLeftVelocity().value()); - m_rightEncoderSim.SetDistance( - m_drivetrainSimulator.GetRightPosition().value()); - m_rightEncoderSim.SetRate(m_drivetrainSimulator.GetRightVelocity().value()); - m_gyroSim.SetAngle(-m_drivetrainSimulator.GetHeading().Degrees().value()); -} - -void Drivetrain::Periodic() { - UpdateOdometry(); - - auto result = m_pcw.Update(m_poseEstimator.GetEstimatedPosition()); - if (result) { - m_poseEstimator.AddVisionMeasurement( - result.value().estimatedPose.ToPose2d(), result.value().timestamp); - } - - m_fieldSim.SetRobotPose(m_poseEstimator.GetEstimatedPosition()); -} diff --git a/photonlib-cpp-examples/apriltagExample/src/main/cpp/Robot.cpp b/photonlib-cpp-examples/apriltagExample/src/main/cpp/Robot.cpp deleted file mode 100644 index 8a84b64f45..0000000000 --- a/photonlib-cpp-examples/apriltagExample/src/main/cpp/Robot.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "Robot.h" - -#include -#include - -void Robot::RobotInit() { - if constexpr (frc::RobotBase::IsSimulation()) { - auto inst = nt::NetworkTableInstance::GetDefault(); - inst.StopServer(); - // set the NT server if simulating this code. - // "localhost" for photon on desktop, or "photonvision.local" or - // "[ip-address]" for coprocessor - inst.SetServer("localhost"); - inst.StartClient4("Robot Simulation"); - } -} - -void Robot::TeleopPeriodic() { - // Get the x speed. We are inverting this because Xbox controllers return - // negative values when we push forward. - const auto xSpeed = -m_controller.GetLeftY() * Drivetrain::kMaxSpeed; - - // Get the rate of angular rotation. We are inverting this because we want a - // positive value when we pull to the left (remember, CCW is positive in - // mathematics). Xbox controllers return positive values when you pull to - // the right by default. - auto rot = -m_controller.GetRightX() * Drivetrain::kMaxAngularSpeed; - - m_drive.Drive(xSpeed, rot); -} - -void Robot::RobotPeriodic() { m_drive.Periodic(); } -void Robot::SimulationPeriodic() { m_drive.SimulationPeriodic(); } - -#ifndef RUNNING_FRC_TESTS -int main() { return frc::StartRobot(); } -#endif diff --git a/photonlib-cpp-examples/apriltagExample/src/main/include/Drivetrain.h b/photonlib-cpp-examples/apriltagExample/src/main/include/Drivetrain.h deleted file mode 100644 index 903256cbed..0000000000 --- a/photonlib-cpp-examples/apriltagExample/src/main/include/Drivetrain.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "PhotonCameraWrapper.h" - -/** - * Represents a differential drive style drivetrain. - */ -class Drivetrain { - public: - Drivetrain() { - m_gyro.Reset(); - - // We need to invert one side of the drivetrain so that positive voltages - // result in both sides moving forward. Depending on how your robot's - // gearbox is constructed, you might have to invert the left side instead. - m_rightGroup.SetInverted(true); - - // Set the distance per pulse for the drive encoders. We can simply use the - // distance traveled for one rotation of the wheel divided by the encoder - // resolution. - m_leftEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius / - kEncoderResolution); - m_rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius / - kEncoderResolution); - - m_leftEncoder.Reset(); - m_rightEncoder.Reset(); - - m_rightGroup.SetInverted(true); - - frc::SmartDashboard::PutData("Field", &m_fieldSim); - } - - static constexpr units::meters_per_second_t kMaxSpeed = - 3.0_mps; // 3 meters per second - static constexpr units::radians_per_second_t kMaxAngularSpeed{ - std::numbers::pi}; // 1/2 rotation per second - - void SetSpeeds(const frc::DifferentialDriveWheelSpeeds& speeds); - void Drive(units::meters_per_second_t xSpeed, - units::radians_per_second_t rot); - void UpdateOdometry(); - void ResetOdometry(const frc::Pose2d& pose); - - frc::Pose2d GetPose() const { return m_poseEstimator.GetEstimatedPosition(); } - - void SimulationPeriodic(); - void Periodic(); - - private: - static constexpr units::meter_t kTrackWidth = 0.381_m * 2; - static constexpr double kWheelRadius = 0.0508; // meters - static constexpr int kEncoderResolution = 4096; - - frc::PWMSparkMax m_leftLeader{1}; - frc::PWMSparkMax m_leftFollower{2}; - frc::PWMSparkMax m_rightLeader{3}; - frc::PWMSparkMax m_rightFollower{4}; - - frc::MotorControllerGroup m_leftGroup{m_leftLeader, m_leftFollower}; - frc::MotorControllerGroup m_rightGroup{m_rightLeader, m_rightFollower}; - - frc::Encoder m_leftEncoder{0, 1}; - frc::Encoder m_rightEncoder{2, 3}; - - frc::PIDController m_leftPIDController{8.5, 0.0, 0.0}; - frc::PIDController m_rightPIDController{8.5, 0.0, 0.0}; - - frc::AnalogGyro m_gyro{0}; - - frc::DifferentialDriveKinematics m_kinematics{kTrackWidth}; - - frc::DifferentialDrivePoseEstimator m_poseEstimator{ - m_kinematics, m_gyro.GetRotation2d(), - units::meter_t{m_leftEncoder.GetDistance()}, - units::meter_t{m_rightEncoder.GetDistance()}, frc::Pose2d{}}; - - PhotonCameraWrapper m_pcw; - - // Gains are for example purposes only - must be determined for your own - // robot! - frc::SimpleMotorFeedforward m_feedforward{1_V, 3_V / 1_mps}; - - // Simulation classes help us simulate our robot - frc::sim::AnalogGyroSim m_gyroSim{m_gyro}; - frc::sim::EncoderSim m_leftEncoderSim{m_leftEncoder}; - frc::sim::EncoderSim m_rightEncoderSim{m_rightEncoder}; - frc::Field2d m_fieldSim; - frc::LinearSystem<2, 2, 2> m_drivetrainSystem = - frc::LinearSystemId::IdentifyDrivetrainSystem( - 1.98_V / 1_mps, 0.2_V / 1_mps_sq, 1.5_V / 1_mps, 0.3_V / 1_mps_sq); - frc::sim::DifferentialDrivetrainSim m_drivetrainSimulator{ - m_drivetrainSystem, kTrackWidth, frc::DCMotor::CIM(2), 8, 2_in}; -}; diff --git a/photonlib-cpp-examples/apriltagExample/src/main/include/PhotonCameraWrapper.h b/photonlib-cpp-examples/apriltagExample/src/main/include/PhotonCameraWrapper.h deleted file mode 100644 index b63362eee1..0000000000 --- a/photonlib-cpp-examples/apriltagExample/src/main/include/PhotonCameraWrapper.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include -#include - -#include - -#include -#include - -class PhotonCameraWrapper { - private: - photon::PhotonCamera camera{"WPI2023"}; - - public: - photon::PhotonPoseEstimator m_poseEstimator{ - frc::LoadAprilTagLayoutField(frc::AprilTagField::k2023ChargedUp), - photon::MULTI_TAG_PNP_ON_RIO, frc::Transform3d{}}; - - inline std::optional Update( - frc::Pose2d estimatedPose) { - m_poseEstimator.SetReferencePose(frc::Pose3d(estimatedPose)); - std::optional ret = std::nullopt; - for (const auto& change : camera.GetAllUnreadResults()) - ret = m_poseEstimator.Update(change); - - return ret; - } -}; diff --git a/photonlib-cpp-examples/apriltagExample/src/main/include/Robot.h b/photonlib-cpp-examples/apriltagExample/src/main/include/Robot.h deleted file mode 100644 index 40bac7a42f..0000000000 --- a/photonlib-cpp-examples/apriltagExample/src/main/include/Robot.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "Drivetrain.h" - -class Robot : public frc::TimedRobot { - public: - void RobotInit() override; - void RobotPeriodic() override; - void TeleopPeriodic() override; - void SimulationPeriodic() override; - - private: - frc::XboxController m_controller{0}; - - Drivetrain m_drive; -}; diff --git a/photonlib-cpp-examples/getinrange/.gitignore b/photonlib-cpp-examples/getinrange/.gitignore deleted file mode 100644 index 34878ab18c..0000000000 --- a/photonlib-cpp-examples/getinrange/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendordeps diff --git a/photonlib-cpp-examples/getinrange/.wpilib/wpilib_preferences.json b/photonlib-cpp-examples/getinrange/.wpilib/wpilib_preferences.json deleted file mode 100644 index 36bf1b5d2f..0000000000 --- a/photonlib-cpp-examples/getinrange/.wpilib/wpilib_preferences.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "enableCppIntellisense": true, - "currentLanguage": "cpp", - "projectYear": "2024", - "teamNumber": 5 -} diff --git a/photonlib-cpp-examples/getinrange/WPILib-License.md b/photonlib-cpp-examples/getinrange/WPILib-License.md deleted file mode 100644 index 3d5a824cad..0000000000 --- a/photonlib-cpp-examples/getinrange/WPILib-License.md +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2009-2021 FIRST and other WPILib contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of FIRST, WPILib, nor the names of other WPILib - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY FIRST AND OTHER WPILIB CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/photonlib-cpp-examples/getinrange/build.gradle b/photonlib-cpp-examples/getinrange/build.gradle deleted file mode 100644 index 9ae88e1577..0000000000 --- a/photonlib-cpp-examples/getinrange/build.gradle +++ /dev/null @@ -1,116 +0,0 @@ -plugins { - id "cpp" - id "google-test-test-suite" - id "edu.wpi.first.GradleRIO" version "2024.3.2" - - id "com.dorongold.task-tree" version "2.1.0" -} - -repositories { - mavenLocal() - jcenter() -} - -apply from: "${rootDir}/../shared/examples_common.gradle" - -// Define my targets (RoboRIO) and artifacts (deployable files) -// This is added by GradleRIO's backing project DeployUtils. -deploy { - targets { - roborio(getTargetTypeClass('RoboRIO')) { - // Team number is loaded either from the .wpilib/wpilib_preferences.json - // or from command line. If not found an exception will be thrown. - // You can use getTeamOrDefault(team) instead of getTeamNumber if you - // want to store a team number in this file. - team = project.frc.getTeamOrDefault(5940) - debug = project.frc.getDebugOrDefault(false) - - artifacts { - // First part is artifact name, 2nd is artifact type - // getTargetTypeClass is a shortcut to get the class type using a string - - frcCpp(getArtifactTypeClass('FRCNativeArtifact')) { - } - - // Static files artifact - frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) { - files = project.fileTree('src/main/deploy') - directory = '/home/lvuser/deploy' - } - } - } - } -} - -def deployArtifact = deploy.targets.roborio.artifacts.frcCpp - -// Set this to true to enable desktop support. -def includeDesktopSupport = true - -// Set to true to run simulation in debug mode -wpi.cpp.debugSimulation = false - -// Default enable simgui -wpi.sim.addGui().defaultEnabled = true -// Enable DS but not by default -wpi.sim.addDriverstation() - -model { - components { - frcUserProgram(NativeExecutableSpec) { - // We don't need to build for roborio -- if we do, we need to install - // a roborio toolchain every time we build in CI - // Ideally, we'd be able to set the roborio toolchain as optional, but - // I can't figure out how to set that environment variable from build.gradle - // (see https://github.com/wpilibsuite/native-utils/blob/2917c69fb5094e36d499c465f047dab81c68446c/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/ToolchainGraphBuildService.java#L71) - // for now, commented out - - // targetPlatform wpi.platforms.roborio - - if (includeDesktopSupport) { - targetPlatform wpi.platforms.desktop - } - - sources.cpp { - source { - srcDir 'src/main/cpp' - include '**/*.cpp', '**/*.cc' - } - exportedHeaders { - srcDir 'src/main/include' - } - } - - // Set deploy task to deploy this component - deployArtifact.component = it - - // Enable run tasks for this component - wpi.cpp.enableExternalTasks(it) - - // Enable simulation for this component - wpi.sim.enable(it) - // Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. - wpi.cpp.vendor.cpp(it) - wpi.cpp.deps.wpilib(it) - } - } - testSuites { - frcUserProgramTest(GoogleTestTestSuiteSpec) { - testing $.components.frcUserProgram - - sources.cpp { - source { - srcDir 'src/test/cpp' - include '**/*.cpp' - } - } - - // Enable run tasks for this component - wpi.cpp.enableExternalTasks(it) - - wpi.cpp.vendor.cpp(it) - wpi.cpp.deps.wpilib(it) - wpi.cpp.deps.googleTest(it) - } - } -} diff --git a/photonlib-cpp-examples/getinrange/gradlew b/photonlib-cpp-examples/getinrange/gradlew deleted file mode 100755 index 0ef4c1e860..0000000000 --- a/photonlib-cpp-examples/getinrange/gradlew +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/photonlib-cpp-examples/getinrange/gradlew.bat b/photonlib-cpp-examples/getinrange/gradlew.bat deleted file mode 100644 index 53a6b238d4..0000000000 --- a/photonlib-cpp-examples/getinrange/gradlew.bat +++ /dev/null @@ -1,91 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/photonlib-cpp-examples/getinrange/settings.gradle b/photonlib-cpp-examples/getinrange/settings.gradle deleted file mode 100644 index d8802bb464..0000000000 --- a/photonlib-cpp-examples/getinrange/settings.gradle +++ /dev/null @@ -1,30 +0,0 @@ -import org.gradle.internal.os.OperatingSystem - -rootProject.name = 'getinrange' - -pluginManagement { - repositories { - mavenLocal() - jcenter() - gradlePluginPortal() - String frcYear = '2024' - File frcHome - if (OperatingSystem.current().isWindows()) { - String publicFolder = System.getenv('PUBLIC') - if (publicFolder == null) { - publicFolder = "C:\\Users\\Public" - } - def homeRoot = new File(publicFolder, "wpilib") - frcHome = new File(homeRoot, frcYear) - } else { - def userFolder = System.getProperty("user.home") - def homeRoot = new File(userFolder, "wpilib") - frcHome = new File(homeRoot, frcYear) - } - def frcHomeMaven = new File(frcHome, 'maven') - maven { - name 'frcHome' - url frcHomeMaven - } - } -} diff --git a/photonlib-cpp-examples/getinrange/simgui-window.json b/photonlib-cpp-examples/getinrange/simgui-window.json deleted file mode 100644 index 1d727b7218..0000000000 --- a/photonlib-cpp-examples/getinrange/simgui-window.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "MainWindow": { - "GLOBAL": { - "height": "720", - "maximized": "0", - "style": "0", - "userScale": "2", - "width": "1280", - "xpos": "3124", - "ypos": "324" - } - }, - "Window": { - "###FMS": { - "Collapsed": "0", - "Pos": "5,540", - "Size": "283,146" - }, - "###Joysticks": { - "Collapsed": "0", - "Pos": "250,465", - "Size": "796,155" - }, - "###Keyboard 0 Settings": { - "Collapsed": "0", - "Pos": "10,50", - "Size": "300,560" - }, - "###NetworkTables": { - "Collapsed": "0", - "Pos": "250,277", - "Size": "750,185" - }, - "###Other Devices": { - "Collapsed": "0", - "Pos": "1025,20", - "Size": "250,695" - }, - "###System Joysticks": { - "Collapsed": "0", - "Pos": "5,350", - "Size": "192,218" - }, - "###Timing": { - "Collapsed": "0", - "Pos": "5,150", - "Size": "135,127" - }, - "Debug##Default": { - "Collapsed": "0", - "Pos": "60,60", - "Size": "400,400" - }, - "Robot State": { - "Collapsed": "0", - "Pos": "5,20", - "Size": "92,99" - } - } -} diff --git a/photonlib-cpp-examples/getinrange/simgui.json b/photonlib-cpp-examples/getinrange/simgui.json deleted file mode 100644 index 449f4b1d65..0000000000 --- a/photonlib-cpp-examples/getinrange/simgui.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "NTProvider": { - "types": { - "/FMSInfo": "FMSInfo" - } - } -} diff --git a/photonlib-cpp-examples/getinrange/src/main/include/Robot.h b/photonlib-cpp-examples/getinrange/src/main/include/Robot.h deleted file mode 100644 index e8905e4e0f..0000000000 --- a/photonlib-cpp-examples/getinrange/src/main/include/Robot.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include - -#include -#include -#include -#include -#include -#include -#include - -class Robot : public frc::TimedRobot { - public: - void TeleopPeriodic() override; - - private: - // Constants such as camera and target height stored. Change per robot and - // goal! - const units::meter_t CAMERA_HEIGHT = 24_in; - const units::meter_t TARGET_HEIGHT = 5_ft; - - // Angle between horizontal and the camera. - const units::radian_t CAMERA_PITCH = 0_deg; - - // How far from the target we want to be - const units::meter_t GOAL_RANGE_METERS = 3_ft; - - // PID constants should be tuned per robot - const double P_GAIN = 0.1; - const double D_GAIN = 0.0; - frc::PIDController controller{P_GAIN, 0.0, D_GAIN}; - - // Change this to match the name of your camera - photon::PhotonCamera camera{"photonvision"}; - - frc::XboxController xboxController{0}; - - // Drive motors - frc::PWMVictorSPX leftMotor{0}; - frc::PWMVictorSPX rightMotor{1}; - frc::DifferentialDrive drive{leftMotor, rightMotor}; -}; diff --git a/photonlib-cpp-examples/getinrange/src/test/cpp/main.cpp b/photonlib-cpp-examples/getinrange/src/test/cpp/main.cpp deleted file mode 100644 index 031d1ce96b..0000000000 --- a/photonlib-cpp-examples/getinrange/src/test/cpp/main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include "gtest/gtest.h" - -int main(int argc, char** argv) { - HAL_Initialize(500, 0); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/photonlib-cpp-examples/apriltagExample/.gitignore b/photonlib-cpp-examples/poseest/.gitignore similarity index 100% rename from photonlib-cpp-examples/apriltagExample/.gitignore rename to photonlib-cpp-examples/poseest/.gitignore diff --git a/photonlib-cpp-examples/apriltagExample/.wpilib/wpilib_preferences.json b/photonlib-cpp-examples/poseest/.wpilib/wpilib_preferences.json similarity index 100% rename from photonlib-cpp-examples/apriltagExample/.wpilib/wpilib_preferences.json rename to photonlib-cpp-examples/poseest/.wpilib/wpilib_preferences.json diff --git a/photonlib-cpp-examples/apriltagExample/WPILib-License.md b/photonlib-cpp-examples/poseest/WPILib-License.md similarity index 100% rename from photonlib-cpp-examples/apriltagExample/WPILib-License.md rename to photonlib-cpp-examples/poseest/WPILib-License.md diff --git a/photonlib-cpp-examples/swervedriveposeestsim/build.gradle b/photonlib-cpp-examples/poseest/build.gradle similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/build.gradle rename to photonlib-cpp-examples/poseest/build.gradle diff --git a/photonlib-cpp-examples/apriltagExample/gradlew b/photonlib-cpp-examples/poseest/gradlew similarity index 100% rename from photonlib-cpp-examples/apriltagExample/gradlew rename to photonlib-cpp-examples/poseest/gradlew diff --git a/photonlib-cpp-examples/swervedriveposeestsim/gradlew.bat b/photonlib-cpp-examples/poseest/gradlew.bat similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/gradlew.bat rename to photonlib-cpp-examples/poseest/gradlew.bat diff --git a/photonlib-cpp-examples/apriltagExample/networktables.json b/photonlib-cpp-examples/poseest/networktables.json similarity index 100% rename from photonlib-cpp-examples/apriltagExample/networktables.json rename to photonlib-cpp-examples/poseest/networktables.json diff --git a/photonlib-cpp-examples/apriltagExample/settings.gradle b/photonlib-cpp-examples/poseest/settings.gradle similarity index 100% rename from photonlib-cpp-examples/apriltagExample/settings.gradle rename to photonlib-cpp-examples/poseest/settings.gradle diff --git a/photonlib-cpp-examples/getinrange/simgui-ds.json b/photonlib-cpp-examples/poseest/simgui-ds.json similarity index 94% rename from photonlib-cpp-examples/getinrange/simgui-ds.json rename to photonlib-cpp-examples/poseest/simgui-ds.json index bd35d5052f..addd5860ce 100644 --- a/photonlib-cpp-examples/getinrange/simgui-ds.json +++ b/photonlib-cpp-examples/poseest/simgui-ds.json @@ -11,10 +11,13 @@ "incKey": 83 }, { - "decKey": 69, "decayRate": 0.0, - "incKey": 82, "keyRate": 0.009999999776482582 + }, + {}, + { + "decKey": 81, + "incKey": 69 } ], "axisCount": 6, diff --git a/photonlib-cpp-examples/swervedriveposeestsim/simgui-window.json b/photonlib-cpp-examples/poseest/simgui-window.json similarity index 68% rename from photonlib-cpp-examples/swervedriveposeestsim/simgui-window.json rename to photonlib-cpp-examples/poseest/simgui-window.json index 1605887709..3baff34d0a 100644 --- a/photonlib-cpp-examples/swervedriveposeestsim/simgui-window.json +++ b/photonlib-cpp-examples/poseest/simgui-window.json @@ -17,38 +17,48 @@ "Window": { "###/SmartDashboard/VisionSystemSim-main/Sim Field": { "Collapsed": "0", - "Pos": "199,200", - "Size": "1342,628" + "Pos": "554,10", + "Size": "991,527" }, "###FMS": { "Collapsed": "0", - "Pos": "5,540", - "Size": "283,146" + "Pos": "12,604", + "Size": "202,214" }, "###Joysticks": { "Collapsed": "0", - "Pos": "359,95", - "Size": "796,240" + "Pos": "278,685", + "Size": "976,219" }, "###NetworkTables": { "Collapsed": "0", - "Pos": "865,52", + "Pos": "353,479", "Size": "830,620" }, + "###NetworkTables Info": { + "Collapsed": "0", + "Pos": "315,527", + "Size": "750,145" + }, "###Other Devices": { "Collapsed": "0", "Pos": "1025,20", "Size": "250,695" }, + "###Plot <0>": { + "Collapsed": "0", + "Pos": "113,22", + "Size": "448,400" + }, "###System Joysticks": { "Collapsed": "0", "Pos": "5,350", - "Size": "192,218" + "Size": "232,254" }, "###Timing": { "Collapsed": "0", "Pos": "5,150", - "Size": "135,127" + "Size": "162,142" }, "Debug##Default": { "Collapsed": "0", @@ -58,7 +68,7 @@ "Robot State": { "Collapsed": "0", "Pos": "5,20", - "Size": "92,99" + "Size": "109,134" } } } diff --git a/photonlib-cpp-examples/poseest/simgui.json b/photonlib-cpp-examples/poseest/simgui.json new file mode 100644 index 0000000000..b3f0626c37 --- /dev/null +++ b/photonlib-cpp-examples/poseest/simgui.json @@ -0,0 +1,161 @@ +{ + "NTProvider": { + "types": { + "/FMSInfo": "FMSInfo", + "/SmartDashboard/VisionSystemSim-main/Sim Field": "Field2d" + }, + "windows": { + "/SmartDashboard/VisionSystemSim-main/Sim Field": { + "EstimatedRobot": { + "arrowWeight": 3.0, + "length": 0.800000011920929, + "selectable": false, + "weight": 3.0, + "width": 0.800000011920929 + }, + "EstimatedRobotModules": { + "arrows": false, + "image": "swerve_module.png", + "length": 0.30000001192092896, + "selectable": false, + "width": 0.30000001192092896 + }, + "Robot": { + "arrowColor": [ + 1.0, + 1.0, + 1.0, + 255.0 + ], + "arrowWeight": 2.0, + "color": [ + 1.0, + 1.0, + 1.0, + 255.0 + ], + "length": 0.800000011920929, + "selectable": false, + "weight": 2.0, + "width": 0.800000011920929 + }, + "VisionEstimation": { + "arrowColor": [ + 0.0, + 0.6075949668884277, + 1.0, + 255.0 + ], + "arrowWeight": 2.0, + "color": [ + 0.0, + 0.6075949668884277, + 1.0, + 255.0 + ], + "selectable": false, + "weight": 2.0 + }, + "apriltag": { + "arrows": false, + "image": "tag-green.png", + "length": 0.6000000238418579, + "width": 0.5 + }, + "bottom": 1476, + "cameras": { + "arrowColor": [ + 0.29535865783691406, + 1.0, + 0.9910804033279419, + 255.0 + ], + "arrowSize": 19, + "arrowWeight": 3.0, + "length": 1.0, + "style": "Hidden", + "weight": 1.0, + "width": 1.0 + }, + "height": 8.210550308227539, + "image": "2023-field.png", + "left": 150, + "right": 2961, + "top": 79, + "visibleTargetPoses": { + "arrows": false, + "image": "tag-blue.png", + "length": 0.5, + "selectable": false, + "width": 0.4000000059604645 + }, + "width": 16.541748046875, + "window": { + "visible": true + } + } + } + }, + "NetworkTables": { + "transitory": { + "CameraPublisher": { + "YOUR CAMERA NAME-processed": { + "open": true, + "string[]##v_/CameraPublisher/YOUR CAMERA NAME-processed/streams": { + "open": true + } + }, + "open": true + }, + "SmartDashboard": { + "VisionSystemSim-main": { + "open": true + }, + "open": true + } + } + }, + "NetworkTables Info": { + "visible": true + }, + "Plot": { + "Plot <0>": { + "plots": [ + { + "axis": [ + { + "autoFit": true + } + ], + "backgroundColor": [ + 0.0, + 0.0, + 0.0, + 0.8500000238418579 + ], + "height": 332, + "series": [ + { + "color": [ + 0.2980392277240753, + 0.44705885648727417, + 0.6901960968971252, + 1.0 + ], + "id": "NT:/SmartDashboard/GPLauncher Act Spd (RPM)" + }, + { + "color": [ + 0.8666667342185974, + 0.5176470875740051, + 0.32156863808631897, + 1.0 + ], + "id": "NT:/SmartDashboard/GPLauncher Des Spd (RPM)" + } + ] + } + ] + } + } +} diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/Robot.cpp b/photonlib-cpp-examples/poseest/src/main/cpp/Robot.cpp similarity index 74% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/Robot.cpp rename to photonlib-cpp-examples/poseest/src/main/cpp/Robot.cpp index 4505740955..75a4ff22c7 100644 --- a/photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/Robot.cpp +++ b/photonlib-cpp-examples/poseest/src/main/cpp/Robot.cpp @@ -32,6 +32,7 @@ void Robot::RobotInit() {} void Robot::RobotPeriodic() { + launcher.periodic(); drivetrain.Periodic(); auto visionEst = vision.GetEstimatedGlobalPose(); @@ -52,47 +53,35 @@ void Robot::DisabledPeriodic() { drivetrain.Stop(); } void Robot::DisabledExit() {} -void Robot::AutonomousInit() { - autoTimer.Restart(); - frc::Pose2d pose{1_m, 1_m, frc::Rotation2d{}}; - drivetrain.ResetPose(pose, true); -} +void Robot::AutonomousInit() {} -void Robot::AutonomousPeriodic() { - if (autoTimer.Get() < 10_s) { - drivetrain.Drive(0.5_mps, 0.5_mps, 0.5_rad_per_s, false); - } else { - autoTimer.Stop(); - drivetrain.Stop(); - } -} +void Robot::AutonomousPeriodic() {} void Robot::AutonomousExit() {} -void Robot::TeleopInit() {} +void Robot::TeleopInit() { + frc::Pose2d pose{1_m, 1_m, frc::Rotation2d{}}; + drivetrain.ResetPose(pose, true); +} void Robot::TeleopPeriodic() { - double forward = -controller.GetLeftY() * kDriveSpeed; - if (std::abs(forward) < 0.1) { - forward = 0; - } - forward = forwardLimiter.Calculate(forward); - - double strafe = -controller.GetLeftX() * kDriveSpeed; - if (std::abs(strafe) < 0.1) { - strafe = 0; - } - strafe = strafeLimiter.Calculate(strafe); - - double turn = -controller.GetRightX() * kDriveSpeed; - if (std::abs(turn) < 0.1) { - turn = 0; - } - turn = turnLimiter.Calculate(turn); - - drivetrain.Drive(forward * constants::Swerve::kMaxLinearSpeed, - strafe * constants::Swerve::kMaxLinearSpeed, - turn * constants::Swerve::kMaxAngularSpeed, true); + // Calculate drivetrain commands from Joystick values + auto forward = + -1.0 * controller.GetLeftY() * constants::Swerve::kMaxLinearSpeed; + auto strafe = + -1.0 * controller.GetLeftX() * constants::Swerve::kMaxLinearSpeed; + auto turn = + -1.0 * controller.GetRightX() * constants::Swerve::kMaxAngularSpeed; + + // Command drivetrain motors based on target speeds + drivetrain.Drive(forward, strafe, turn); + + // Calculate whether the gamepiece launcher runs based on our global pose + // estimate. + frc::Pose2d curPose = drivetrain.GetPose(); + bool shouldRun = (curPose.Y() > 2.0_m && + curPose.X() < 4.0_m); // Close enough to blue speaker + launcher.setRunning(shouldRun); } void Robot::TeleopExit() {} @@ -104,6 +93,7 @@ void Robot::TestPeriodic() {} void Robot::TestExit() {} void Robot::SimulationPeriodic() { + launcher.simulationPeriodic(); drivetrain.SimulationPeriodic(); vision.SimPeriodic(drivetrain.GetSimPose()); diff --git a/photonlib-cpp-examples/getinrange/src/main/cpp/Robot.cpp b/photonlib-cpp-examples/poseest/src/main/cpp/subsystems/GamepieceLauncher.cpp similarity index 50% rename from photonlib-cpp-examples/getinrange/src/main/cpp/Robot.cpp rename to photonlib-cpp-examples/poseest/src/main/cpp/subsystems/GamepieceLauncher.cpp index 7ac4cd93bd..fc61a731ff 100644 --- a/photonlib-cpp-examples/getinrange/src/main/cpp/Robot.cpp +++ b/photonlib-cpp-examples/poseest/src/main/cpp/subsystems/GamepieceLauncher.cpp @@ -22,41 +22,37 @@ * SOFTWARE. */ -#include "Robot.h" +#include "subsystems/GamepieceLauncher.h" // Include the header file -#include - -void Robot::TeleopPeriodic() { - double forwardSpeed; - double rotationSpeed = xboxController.GetLeftX(); - - if (xboxController.GetAButton()) { - // Vision-alignment mode - // Query the latest result from PhotonVision - photon::PhotonPipelineResult result = camera.GetLatestResult(); +GamepieceLauncher::GamepieceLauncher() { + motor = new frc::PWMSparkMax(8); // Create the motor object for PWM port 8 + simulationInit(); +} - if (result.HasTargets()) { - // First calculate range - units::meter_t range = photon::PhotonUtils::CalculateDistanceToTarget( - CAMERA_HEIGHT, TARGET_HEIGHT, CAMERA_PITCH, - units::degree_t{result.GetBestTarget().GetPitch()}); +void GamepieceLauncher::setRunning(bool shouldRun) { + curDesSpd = shouldRun ? LAUNCH_SPEED_RPM : 0.0; +} - // Use this range as the measurement we give to the PID controller. - forwardSpeed = - -controller.Calculate(range.value(), GOAL_RANGE_METERS.value()); - } else { - // If we have no targets, stay still. - forwardSpeed = 0; - } - } else { - // Manual Driver Mode - forwardSpeed = -xboxController.GetRightY(); - } +void GamepieceLauncher::periodic() { + // Calculate the maximum RPM + double maxRPM = + units::radians_per_second_t(frc::DCMotor::Falcon500(1).freeSpeed) + .to() * + 60 / (2 * std::numbers::pi); + curMotorCmd = curDesSpd / maxRPM; + curMotorCmd = std::clamp(curMotorCmd, 0.0, 1.0); + motor->Set(curMotorCmd); + + frc::SmartDashboard::PutNumber("GPLauncher Des Spd (RPM)", curDesSpd); +} - // Use our forward/turn speeds to control the drivetrain - drive.ArcadeDrive(forwardSpeed, rotationSpeed); +void GamepieceLauncher::simulationPeriodic() { + launcherSim.SetInputVoltage(curMotorCmd * + frc::RobotController::GetBatteryVoltage()); + launcherSim.Update(0.02_s); + auto spd = launcherSim.GetAngularVelocity().to() * 60 / + (2 * std::numbers::pi); + frc::SmartDashboard::PutNumber("GPLauncher Act Spd (RPM)", spd); } -#ifndef RUNNING_FRC_TESTS -int main() { return frc::StartRobot(); } -#endif +void GamepieceLauncher::simulationInit() {} diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/subsystems/SwerveDrive.cpp b/photonlib-cpp-examples/poseest/src/main/cpp/subsystems/SwerveDrive.cpp similarity index 97% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/subsystems/SwerveDrive.cpp rename to photonlib-cpp-examples/poseest/src/main/cpp/subsystems/SwerveDrive.cpp index 54c39b1d5d..154c2f88ef 100644 --- a/photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/subsystems/SwerveDrive.cpp +++ b/photonlib-cpp-examples/poseest/src/main/cpp/subsystems/SwerveDrive.cpp @@ -50,15 +50,15 @@ void SwerveDrive::Periodic() { void SwerveDrive::Drive(units::meters_per_second_t vx, units::meters_per_second_t vy, - units::radians_per_second_t omega, bool openLoop) { + units::radians_per_second_t omega) { frc::ChassisSpeeds newChassisSpeeds = frc::ChassisSpeeds::FromFieldRelativeSpeeds(vx, vy, omega, GetHeading()); - SetChassisSpeeds(newChassisSpeeds, openLoop, false); + SetChassisSpeeds(newChassisSpeeds, true, false); } void SwerveDrive::SetChassisSpeeds(const frc::ChassisSpeeds& newChassisSpeeds, bool openLoop, bool steerInPlace) { - SetModuleStates(kinematics.ToSwerveModuleStates(newChassisSpeeds), openLoop, + SetModuleStates(kinematics.ToSwerveModuleStates(newChassisSpeeds), true, steerInPlace); this->targetChassisSpeeds = newChassisSpeeds; } @@ -75,7 +75,7 @@ void SwerveDrive::SetModuleStates( } } -void SwerveDrive::Stop() { Drive(0_mps, 0_mps, 0_rad_per_s, true); } +void SwerveDrive::Stop() { Drive(0_mps, 0_mps, 0_rad_per_s); } void SwerveDrive::AddVisionMeasurement(const frc::Pose2d& visionMeasurement, units::second_t timestamp) { diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/subsystems/SwerveDriveSim.cpp b/photonlib-cpp-examples/poseest/src/main/cpp/subsystems/SwerveDriveSim.cpp similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/subsystems/SwerveDriveSim.cpp rename to photonlib-cpp-examples/poseest/src/main/cpp/subsystems/SwerveDriveSim.cpp diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/subsystems/SwerveModule.cpp b/photonlib-cpp-examples/poseest/src/main/cpp/subsystems/SwerveModule.cpp similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/cpp/subsystems/SwerveModule.cpp rename to photonlib-cpp-examples/poseest/src/main/cpp/subsystems/SwerveModule.cpp diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/deploy/example.txt b/photonlib-cpp-examples/poseest/src/main/deploy/example.txt similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/deploy/example.txt rename to photonlib-cpp-examples/poseest/src/main/deploy/example.txt diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/include/Constants.h b/photonlib-cpp-examples/poseest/src/main/include/Constants.h similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/include/Constants.h rename to photonlib-cpp-examples/poseest/src/main/include/Constants.h diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/include/Robot.h b/photonlib-cpp-examples/poseest/src/main/include/Robot.h similarity index 85% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/include/Robot.h rename to photonlib-cpp-examples/poseest/src/main/include/Robot.h index 7a3697494a..96af16d532 100644 --- a/photonlib-cpp-examples/swervedriveposeestsim/src/main/include/Robot.h +++ b/photonlib-cpp-examples/poseest/src/main/include/Robot.h @@ -25,11 +25,10 @@ #pragma once #include -#include #include -#include #include "Vision.h" +#include "subsystems/GamepieceLauncher.h" #include "subsystems/SwerveDrive.h" class Robot : public frc::TimedRobot { @@ -53,10 +52,6 @@ class Robot : public frc::TimedRobot { private: SwerveDrive drivetrain{}; Vision vision{}; + GamepieceLauncher launcher{}; frc::XboxController controller{0}; - frc::SlewRateLimiter forwardLimiter{1.0 / 0.6_s}; - frc::SlewRateLimiter strafeLimiter{1.0 / 0.6_s}; - frc::SlewRateLimiter turnLimiter{1.0 / 0.33_s}; - frc::Timer autoTimer{}; - double kDriveSpeed{0.6}; }; diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/include/Vision.h b/photonlib-cpp-examples/poseest/src/main/include/Vision.h similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/include/Vision.h rename to photonlib-cpp-examples/poseest/src/main/include/Vision.h diff --git a/photonlib-cpp-examples/poseest/src/main/include/subsystems/GamepieceLauncher.h b/photonlib-cpp-examples/poseest/src/main/include/subsystems/GamepieceLauncher.h new file mode 100644 index 0000000000..39590267d5 --- /dev/null +++ b/photonlib-cpp-examples/poseest/src/main/include/subsystems/GamepieceLauncher.h @@ -0,0 +1,66 @@ +/* + * MIT License + * + * Copyright (c) PhotonVision + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef PHOTONVISION_PHOTONLIB_CPP_EXAMPLES_POSEEST_SRC_MAIN_INCLUDE_SUBSYSTEMS_GAMEPIECELAUNCHER_H_ +#define PHOTONVISION_PHOTONLIB_CPP_EXAMPLES_POSEEST_SRC_MAIN_INCLUDE_SUBSYSTEMS_GAMEPIECELAUNCHER_H_ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +class GamepieceLauncher { + public: + GamepieceLauncher(); // Constructor + void setRunning(bool shouldRun); // Method to start/stop the launcher + void periodic(); // Method to handle periodic updates + void simulationPeriodic(); // Method to handle simulation updates + + private: + frc::PWMSparkMax* motor; // Motor controller + + const double LAUNCH_SPEED_RPM = 2500; + double curDesSpd = 0.0; + double curMotorCmd = 0.0; + + static constexpr units::kilogram_square_meter_t kFlywheelMomentOfInertia = + 0.5 * 1.5_lb * 4_in * 4_in; + + frc::DCMotor m_gearbox = frc::DCMotor::Falcon500(1); + frc::LinearSystem<1, 1, 1> m_plant{frc::LinearSystemId::FlywheelSystem( + m_gearbox, kFlywheelMomentOfInertia, 1.0)}; + + frc::sim::FlywheelSim launcherSim{m_plant, m_gearbox, 1.0}; + + void simulationInit(); // Method to initialize simulation components +}; + +#endif // PHOTONVISION_PHOTONLIB_CPP_EXAMPLES_POSEEST_SRC_MAIN_INCLUDE_SUBSYSTEMS_GAMEPIECELAUNCHER_H_ diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/include/subsystems/SwerveDrive.h b/photonlib-cpp-examples/poseest/src/main/include/subsystems/SwerveDrive.h similarity index 98% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/include/subsystems/SwerveDrive.h rename to photonlib-cpp-examples/poseest/src/main/include/subsystems/SwerveDrive.h index 1e3d26b32f..1fb0bf7e87 100644 --- a/photonlib-cpp-examples/swervedriveposeestsim/src/main/include/subsystems/SwerveDrive.h +++ b/photonlib-cpp-examples/poseest/src/main/include/subsystems/SwerveDrive.h @@ -38,7 +38,7 @@ class SwerveDrive { SwerveDrive(); void Periodic(); void Drive(units::meters_per_second_t vx, units::meters_per_second_t vy, - units::radians_per_second_t omega, bool openLoop); + units::radians_per_second_t omega); void SetChassisSpeeds(const frc::ChassisSpeeds& targetChassisSpeeds, bool openLoop, bool steerInPlace); void SetModuleStates( diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/include/subsystems/SwerveDriveSim.h b/photonlib-cpp-examples/poseest/src/main/include/subsystems/SwerveDriveSim.h similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/include/subsystems/SwerveDriveSim.h rename to photonlib-cpp-examples/poseest/src/main/include/subsystems/SwerveDriveSim.h diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/main/include/subsystems/SwerveModule.h b/photonlib-cpp-examples/poseest/src/main/include/subsystems/SwerveModule.h similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/src/main/include/subsystems/SwerveModule.h rename to photonlib-cpp-examples/poseest/src/main/include/subsystems/SwerveModule.h diff --git a/photonlib-cpp-examples/apriltagExample/src/test/cpp/main.cpp b/photonlib-cpp-examples/poseest/src/test/cpp/main.cpp similarity index 100% rename from photonlib-cpp-examples/apriltagExample/src/test/cpp/main.cpp rename to photonlib-cpp-examples/poseest/src/test/cpp/main.cpp diff --git a/photonlib-cpp-examples/swervedriveposeestsim/swerve_module.png b/photonlib-cpp-examples/poseest/swerve_module.png similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/swerve_module.png rename to photonlib-cpp-examples/poseest/swerve_module.png diff --git a/photonlib-cpp-examples/swervedriveposeestsim/tag-blue.png b/photonlib-cpp-examples/poseest/tag-blue.png similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/tag-blue.png rename to photonlib-cpp-examples/poseest/tag-blue.png diff --git a/photonlib-cpp-examples/swervedriveposeestsim/tag-green.png b/photonlib-cpp-examples/poseest/tag-green.png similarity index 100% rename from photonlib-cpp-examples/swervedriveposeestsim/tag-green.png rename to photonlib-cpp-examples/poseest/tag-green.png diff --git a/photonlib-cpp-examples/swervedriveposeestsim/.gitignore b/photonlib-cpp-examples/swervedriveposeestsim/.gitignore deleted file mode 100644 index 34878ab18c..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendordeps diff --git a/photonlib-cpp-examples/swervedriveposeestsim/.wpilib/wpilib_preferences.json b/photonlib-cpp-examples/swervedriveposeestsim/.wpilib/wpilib_preferences.json deleted file mode 100644 index 36bf1b5d2f..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/.wpilib/wpilib_preferences.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "enableCppIntellisense": true, - "currentLanguage": "cpp", - "projectYear": "2024", - "teamNumber": 5 -} diff --git a/photonlib-cpp-examples/swervedriveposeestsim/WPILib-License.md b/photonlib-cpp-examples/swervedriveposeestsim/WPILib-License.md deleted file mode 100644 index 3d5a824cad..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/WPILib-License.md +++ /dev/null @@ -1,24 +0,0 @@ -Copyright (c) 2009-2021 FIRST and other WPILib contributors -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of FIRST, WPILib, nor the names of other WPILib - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY FIRST AND OTHER WPILIB CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/photonlib-cpp-examples/swervedriveposeestsim/gradlew b/photonlib-cpp-examples/swervedriveposeestsim/gradlew deleted file mode 100644 index 0ef4c1e860..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/gradlew +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -APP_NAME="Gradle" -APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/photonlib-cpp-examples/swervedriveposeestsim/networktables.json b/photonlib-cpp-examples/swervedriveposeestsim/networktables.json deleted file mode 100644 index fe51488c70..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/networktables.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/photonlib-cpp-examples/swervedriveposeestsim/settings.gradle b/photonlib-cpp-examples/swervedriveposeestsim/settings.gradle deleted file mode 100644 index 44fbca7512..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/settings.gradle +++ /dev/null @@ -1,30 +0,0 @@ -import org.gradle.internal.os.OperatingSystem - -rootProject.name = 'aimattarget' - -pluginManagement { - repositories { - mavenLocal() - jcenter() - gradlePluginPortal() - String frcYear = '2024' - File frcHome - if (OperatingSystem.current().isWindows()) { - String publicFolder = System.getenv('PUBLIC') - if (publicFolder == null) { - publicFolder = "C:\\Users\\Public" - } - def homeRoot = new File(publicFolder, "wpilib") - frcHome = new File(homeRoot, frcYear) - } else { - def userFolder = System.getProperty("user.home") - def homeRoot = new File(userFolder, "wpilib") - frcHome = new File(homeRoot, frcYear) - } - def frcHomeMaven = new File(frcHome, 'maven') - maven { - name 'frcHome' - url frcHomeMaven - } - } -} diff --git a/photonlib-cpp-examples/swervedriveposeestsim/simgui-ds.json b/photonlib-cpp-examples/swervedriveposeestsim/simgui-ds.json deleted file mode 100644 index c4b7efd3d8..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/simgui-ds.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "keyboardJoysticks": [ - { - "axisConfig": [ - { - "decKey": 65, - "incKey": 68 - }, - { - "decKey": 87, - "incKey": 83 - }, - { - "decKey": 69, - "decayRate": 0.0, - "incKey": 82, - "keyRate": 0.009999999776482582 - } - ], - "axisCount": 3, - "buttonCount": 4, - "buttonKeys": [ - 90, - 88, - 67, - 86 - ], - "povConfig": [ - { - "key0": 328, - "key135": 323, - "key180": 322, - "key225": 321, - "key270": 324, - "key315": 327, - "key45": 329, - "key90": 326 - } - ], - "povCount": 1 - }, - { - "axisConfig": [ - { - "decKey": 74, - "incKey": 76 - }, - { - "decKey": 73, - "incKey": 75 - } - ], - "axisCount": 2, - "buttonCount": 4, - "buttonKeys": [ - 77, - 44, - 46, - 47 - ], - "povCount": 0 - }, - { - "axisConfig": [ - { - "decKey": 263, - "incKey": 262 - }, - { - "decKey": 265, - "incKey": 264 - } - ], - "axisCount": 2, - "buttonCount": 6, - "buttonKeys": [ - 260, - 268, - 266, - 261, - 269, - 267 - ], - "povCount": 0 - }, - { - "axisCount": 0, - "buttonCount": 0, - "povCount": 0 - } - ], - "robotJoysticks": [ - { - "guid": "78696e70757401000000000000000000", - "useGamepad": true - } - ] -} diff --git a/photonlib-cpp-examples/swervedriveposeestsim/simgui.json b/photonlib-cpp-examples/swervedriveposeestsim/simgui.json deleted file mode 100644 index e1ba9acce8..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/simgui.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "NTProvider": { - "types": { - "/FMSInfo": "FMSInfo", - "/SmartDashboard/VisionSystemSim-main/Sim Field": "Field2d" - }, - "windows": { - "/SmartDashboard/VisionSystemSim-main/Sim Field": { - "EstimatedRobotModules": { - "arrows": false, - "image": "swerve_module.png", - "length": 0.30000001192092896, - "width": 0.30000001192092896 - }, - "apriltag": { - "image": "tag-green.png", - "length": 0.6000000238418579, - "width": 0.6000000238418579 - }, - "bottom": 544, - "builtin": "2023 Charged Up", - "cameras": { - "arrowSize": 19, - "arrowWeight": 1.0, - "style": "Hidden" - }, - "height": 8.013679504394531, - "left": 46, - "right": 1088, - "top": 36, - "visibleTargetPoses": { - "image": "tag-blue.png" - }, - "width": 16.541748046875, - "window": { - "visible": true - } - } - } - }, - "NetworkTables": { - "transitory": { - "SmartDashboard": { - "Drive": { - "open": true - }, - "open": true - }, - "photonvision": { - "open": true, - "photonvision": { - "open": true - } - } - } - } -} diff --git a/photonlib-cpp-examples/swervedriveposeestsim/src/test/cpp/main.cpp b/photonlib-cpp-examples/swervedriveposeestsim/src/test/cpp/main.cpp deleted file mode 100644 index 031d1ce96b..0000000000 --- a/photonlib-cpp-examples/swervedriveposeestsim/src/test/cpp/main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * MIT License - * - * Copyright (c) PhotonVision - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include - -#include "gtest/gtest.h" - -int main(int argc, char** argv) { - HAL_Initialize(500, 0); - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; -} diff --git a/photonlib-java-examples/poseest/simgui.json b/photonlib-java-examples/poseest/simgui.json index b8d18f09c6..6bc1edd79f 100644 --- a/photonlib-java-examples/poseest/simgui.json +++ b/photonlib-java-examples/poseest/simgui.json @@ -118,13 +118,15 @@ "NetworkTables Info": { "visible": true }, - "NetworkTables View": { - "visible": false - }, - "Plot": { + "Plot": { "Plot <0>": { "plots": [ { +"axis": [ + { + "autoFit": true + } + ], "backgroundColor": [ 0.0, 0.0,