Skip to content

Commit 65a1e88

Browse files
committedApr 19, 2022
initial commit
1 parent 5fb874b commit 65a1e88

21 files changed

+1670
-0
lines changed
 

‎.gitignore

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# This gitignore has been specially created by the WPILib team.
2+
# If you remove items from this file, intellisense might break.
3+
4+
### C++ ###
5+
# Prerequisites
6+
*.d
7+
8+
# Compiled Object files
9+
*.slo
10+
*.lo
11+
*.o
12+
*.obj
13+
14+
# Precompiled Headers
15+
*.gch
16+
*.pch
17+
18+
# Compiled Dynamic libraries
19+
*.so
20+
*.dylib
21+
*.dll
22+
23+
# Fortran module files
24+
*.mod
25+
*.smod
26+
27+
# Compiled Static libraries
28+
*.lai
29+
*.la
30+
*.a
31+
*.lib
32+
33+
# Executables
34+
*.exe
35+
*.out
36+
*.app
37+
38+
### Java ###
39+
# Compiled class file
40+
*.class
41+
42+
# Log file
43+
*.log
44+
45+
# BlueJ files
46+
*.ctxt
47+
48+
# Mobile Tools for Java (J2ME)
49+
.mtj.tmp/
50+
51+
# Package Files #
52+
*.jar
53+
*.war
54+
*.nar
55+
*.ear
56+
*.zip
57+
*.tar.gz
58+
*.rar
59+
60+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
61+
hs_err_pid*
62+
63+
### Linux ###
64+
*~
65+
66+
# temporary files which can be created if a process still has a handle open of a deleted file
67+
.fuse_hidden*
68+
69+
# KDE directory preferences
70+
.directory
71+
72+
# Linux trash folder which might appear on any partition or disk
73+
.Trash-*
74+
75+
# .nfs files are created when an open file is removed but is still being accessed
76+
.nfs*
77+
78+
### macOS ###
79+
# General
80+
.DS_Store
81+
.AppleDouble
82+
.LSOverride
83+
84+
# Icon must end with two \r
85+
Icon
86+
87+
# Thumbnails
88+
._*
89+
90+
# Files that might appear in the root of a volume
91+
.DocumentRevisions-V100
92+
.fseventsd
93+
.Spotlight-V100
94+
.TemporaryItems
95+
.Trashes
96+
.VolumeIcon.icns
97+
.com.apple.timemachine.donotpresent
98+
99+
# Directories potentially created on remote AFP share
100+
.AppleDB
101+
.AppleDesktop
102+
Network Trash Folder
103+
Temporary Items
104+
.apdisk
105+
106+
### VisualStudioCode ###
107+
.vscode/*
108+
!.vscode/settings.json
109+
!.vscode/tasks.json
110+
!.vscode/launch.json
111+
!.vscode/extensions.json
112+
113+
### Windows ###
114+
# Windows thumbnail cache files
115+
Thumbs.db
116+
ehthumbs.db
117+
ehthumbs_vista.db
118+
119+
# Dump file
120+
*.stackdump
121+
122+
# Folder config file
123+
[Dd]esktop.ini
124+
125+
# Recycle Bin used on file shares
126+
$RECYCLE.BIN/
127+
128+
# Windows Installer files
129+
*.cab
130+
*.msi
131+
*.msix
132+
*.msm
133+
*.msp
134+
135+
# Windows shortcuts
136+
*.lnk
137+
138+
### Gradle ###
139+
.gradle
140+
/build/
141+
142+
# Ignore Gradle GUI config
143+
gradle-app.setting
144+
145+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
146+
!gradle-wrapper.jar
147+
148+
# Cache of project
149+
.gradletasknamecache
150+
151+
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
152+
# gradle/wrapper/gradle-wrapper.properties
153+
154+
# # VS Code Specific Java Settings
155+
# DO NOT REMOVE .classpath and .project
156+
.classpath
157+
.project
158+
.settings/
159+
bin/
160+
161+
# Simulation GUI and other tools window save file
162+
*-window.json

‎.vscode/launch.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
8+
{
9+
"type": "wpilib",
10+
"name": "WPILib Desktop Debug",
11+
"request": "launch",
12+
"desktop": true,
13+
},
14+
{
15+
"type": "wpilib",
16+
"name": "WPILib roboRIO Debug",
17+
"request": "launch",
18+
"desktop": false,
19+
}
20+
]
21+
}

‎.vscode/settings.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "automatic",
3+
"java.server.launchMode": "Standard",
4+
"files.exclude": {
5+
"**/.git": true,
6+
"**/.svn": true,
7+
"**/.hg": true,
8+
"**/CVS": true,
9+
"**/.DS_Store": true,
10+
"bin/": true,
11+
"**/.classpath": true,
12+
"**/.project": true,
13+
"**/.settings": true,
14+
"**/.factorypath": true,
15+
"**/*~": true
16+
},
17+
"java.test.config": [
18+
{
19+
"name": "WPIlibUnitTests",
20+
"workingDirectory": "${workspaceFolder}/build/jni/release",
21+
"vmargs": [ "-Djava.library.path=${workspaceFolder}/build/jni/release" ],
22+
"env": {
23+
"LD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release" ,
24+
"DYLD_LIBRARY_PATH": "${workspaceFolder}/build/jni/release"
25+
}
26+
},
27+
],
28+
"java.test.defaultConfig": "WPIlibUnitTests"
29+
}

‎.wpilib/wpilib_preferences.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"enableCppIntellisense": false,
3+
"currentLanguage": "java",
4+
"projectYear": "2022",
5+
"teamNumber": 1466
6+
}

‎WPILib-License.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2009-2021 FIRST and other WPILib contributors
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
* Neither the name of FIRST, WPILib, nor the names of other WPILib
12+
contributors may be used to endorse or promote products derived from
13+
this software without specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY FIRST AND OTHER WPILIB CONTRIBUTORS "AS IS" AND
16+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR
18+
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR
19+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

‎build.gradle

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
plugins {
2+
id "java"
3+
id "edu.wpi.first.GradleRIO" version "2022.4.1"
4+
}
5+
6+
sourceCompatibility = JavaVersion.VERSION_11
7+
targetCompatibility = JavaVersion.VERSION_11
8+
9+
def ROBOT_MAIN_CLASS = "frc.robot.Main"
10+
11+
// Define my targets (RoboRIO) and artifacts (deployable files)
12+
// This is added by GradleRIO's backing project DeployUtils.
13+
deploy {
14+
targets {
15+
roborio(getTargetTypeClass('RoboRIO')) {
16+
// Team number is loaded either from the .wpilib/wpilib_preferences.json
17+
// or from command line. If not found an exception will be thrown.
18+
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
19+
// want to store a team number in this file.
20+
team = project.frc.getTeamNumber()
21+
debug = project.frc.getDebugOrDefault(false)
22+
23+
artifacts {
24+
// First part is artifact name, 2nd is artifact type
25+
// getTargetTypeClass is a shortcut to get the class type using a string
26+
27+
frcJava(getArtifactTypeClass('FRCJavaArtifact')) {
28+
}
29+
30+
// Static files artifact
31+
frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) {
32+
files = project.fileTree('src/main/deploy')
33+
directory = '/home/lvuser/deploy'
34+
}
35+
}
36+
}
37+
}
38+
}
39+
40+
def deployArtifact = deploy.targets.roborio.artifacts.frcJava
41+
42+
// Set to true to use debug for JNI.
43+
wpi.java.debugJni = false
44+
45+
// Set this to true to enable desktop support.
46+
def includeDesktopSupport = false
47+
48+
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
49+
// Also defines JUnit 4.
50+
dependencies {
51+
implementation wpi.java.deps.wpilib()
52+
implementation wpi.java.vendor.java()
53+
54+
roborioDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.roborio)
55+
roborioDebug wpi.java.vendor.jniDebug(wpi.platforms.roborio)
56+
57+
roborioRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.roborio)
58+
roborioRelease wpi.java.vendor.jniRelease(wpi.platforms.roborio)
59+
60+
nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop)
61+
nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop)
62+
simulationDebug wpi.sim.enableDebug()
63+
64+
nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop)
65+
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
66+
simulationRelease wpi.sim.enableRelease()
67+
68+
testImplementation 'junit:junit:4.13.1'
69+
}
70+
71+
// Simulation configuration (e.g. environment variables).
72+
wpi.sim.addGui().defaultEnabled = true
73+
wpi.sim.addDriverstation()
74+
75+
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
76+
// in order to make them all available at runtime. Also adding the manifest so WPILib
77+
// knows where to look for our Robot Class.
78+
jar {
79+
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
80+
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
81+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
82+
}
83+
84+
// Configure jar and deploy tasks
85+
deployArtifact.jarTask = jar
86+
wpi.java.configureExecutableTasks(jar)
87+
wpi.java.configureTestTasks(test)

‎gradle/wrapper/gradle-wrapper.jar

58.1 KB
Binary file not shown.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=permwrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=permwrapper/dists

‎gradlew

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
#!/bin/sh
2+
3+
#
4+
# Copyright © 2015-2021 the original authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
##############################################################################
20+
#
21+
# Gradle start up script for POSIX generated by Gradle.
22+
#
23+
# Important for running:
24+
#
25+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26+
# noncompliant, but you have some other compliant shell such as ksh or
27+
# bash, then to run this script, type that shell name before the whole
28+
# command line, like:
29+
#
30+
# ksh Gradle
31+
#
32+
# Busybox and similar reduced shells will NOT work, because this script
33+
# requires all of these POSIX shell features:
34+
# * functions;
35+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37+
# * compound commands having a testable exit status, especially «case»;
38+
# * various built-in commands including «command», «set», and «ulimit».
39+
#
40+
# Important for patching:
41+
#
42+
# (2) This script targets any POSIX shell, so it avoids extensions provided
43+
# by Bash, Ksh, etc; in particular arrays are avoided.
44+
#
45+
# The "traditional" practice of packing multiple parameters into a
46+
# space-separated string is a well documented source of bugs and security
47+
# problems, so this is (mostly) avoided, by progressively accumulating
48+
# options in "$@", and eventually passing that to Java.
49+
#
50+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52+
# see the in-line comments for details.
53+
#
54+
# There are tweaks for specific operating systems such as AIX, CygWin,
55+
# Darwin, MinGW, and NonStop.
56+
#
57+
# (3) This script is generated from the Groovy template
58+
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59+
# within the Gradle project.
60+
#
61+
# You can find Gradle at https://github.com/gradle/gradle/.
62+
#
63+
##############################################################################
64+
65+
# Attempt to set APP_HOME
66+
67+
# Resolve links: $0 may be a link
68+
app_path=$0
69+
70+
# Need this for daisy-chained symlinks.
71+
while
72+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73+
[ -h "$app_path" ]
74+
do
75+
ls=$( ls -ld "$app_path" )
76+
link=${ls#*' -> '}
77+
case $link in #(
78+
/*) app_path=$link ;; #(
79+
*) app_path=$APP_HOME$link ;;
80+
esac
81+
done
82+
83+
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84+
85+
APP_NAME="Gradle"
86+
APP_BASE_NAME=${0##*/}
87+
88+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90+
91+
# Use the maximum available, or set MAX_FD != -1 to use that value.
92+
MAX_FD=maximum
93+
94+
warn () {
95+
echo "$*"
96+
} >&2
97+
98+
die () {
99+
echo
100+
echo "$*"
101+
echo
102+
exit 1
103+
} >&2
104+
105+
# OS specific support (must be 'true' or 'false').
106+
cygwin=false
107+
msys=false
108+
darwin=false
109+
nonstop=false
110+
case "$( uname )" in #(
111+
CYGWIN* ) cygwin=true ;; #(
112+
Darwin* ) darwin=true ;; #(
113+
MSYS* | MINGW* ) msys=true ;; #(
114+
NONSTOP* ) nonstop=true ;;
115+
esac
116+
117+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118+
119+
120+
# Determine the Java command to use to start the JVM.
121+
if [ -n "$JAVA_HOME" ] ; then
122+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123+
# IBM's JDK on AIX uses strange locations for the executables
124+
JAVACMD=$JAVA_HOME/jre/sh/java
125+
else
126+
JAVACMD=$JAVA_HOME/bin/java
127+
fi
128+
if [ ! -x "$JAVACMD" ] ; then
129+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130+
131+
Please set the JAVA_HOME variable in your environment to match the
132+
location of your Java installation."
133+
fi
134+
else
135+
JAVACMD=java
136+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137+
138+
Please set the JAVA_HOME variable in your environment to match the
139+
location of your Java installation."
140+
fi
141+
142+
# Increase the maximum file descriptors if we can.
143+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144+
case $MAX_FD in #(
145+
max*)
146+
MAX_FD=$( ulimit -H -n ) ||
147+
warn "Could not query maximum file descriptor limit"
148+
esac
149+
case $MAX_FD in #(
150+
'' | soft) :;; #(
151+
*)
152+
ulimit -n "$MAX_FD" ||
153+
warn "Could not set maximum file descriptor limit to $MAX_FD"
154+
esac
155+
fi
156+
157+
# Collect all arguments for the java command, stacking in reverse order:
158+
# * args from the command line
159+
# * the main class name
160+
# * -classpath
161+
# * -D...appname settings
162+
# * --module-path (only if needed)
163+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164+
165+
# For Cygwin or MSYS, switch paths to Windows format before running java
166+
if "$cygwin" || "$msys" ; then
167+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169+
170+
JAVACMD=$( cygpath --unix "$JAVACMD" )
171+
172+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
173+
for arg do
174+
if
175+
case $arg in #(
176+
-*) false ;; # don't mess with options #(
177+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178+
[ -e "$t" ] ;; #(
179+
*) false ;;
180+
esac
181+
then
182+
arg=$( cygpath --path --ignore --mixed "$arg" )
183+
fi
184+
# Roll the args list around exactly as many times as the number of
185+
# args, so each arg winds up back in the position where it started, but
186+
# possibly modified.
187+
#
188+
# NB: a `for` loop captures its iteration list before it begins, so
189+
# changing the positional parameters here affects neither the number of
190+
# iterations, nor the values presented in `arg`.
191+
shift # remove old arg
192+
set -- "$@" "$arg" # push replacement arg
193+
done
194+
fi
195+
196+
# Collect all arguments for the java command;
197+
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198+
# shell script including quotes and variable substitutions, so put them in
199+
# double quotes to make sure that they get re-expanded; and
200+
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
set -- \
203+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
204+
-classpath "$CLASSPATH" \
205+
org.gradle.wrapper.GradleWrapperMain \
206+
"$@"
207+
208+
# Use "xargs" to parse quoted args.
209+
#
210+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211+
#
212+
# In Bash we could simply go:
213+
#
214+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215+
# set -- "${ARGS[@]}" "$@"
216+
#
217+
# but POSIX shell has neither arrays nor command substitution, so instead we
218+
# post-process each arg (as a line of input to sed) to backslash-escape any
219+
# character that might be a shell metacharacter, then use eval to reverse
220+
# that process (while maintaining the separation between arguments), and wrap
221+
# the whole thing up as a single "set" statement.
222+
#
223+
# This will of course break if any of these variables contains a newline or
224+
# an unmatched quote.
225+
#
226+
227+
eval "set -- $(
228+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229+
xargs -n1 |
230+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231+
tr '\n' ' '
232+
)" '"$@"'
233+
234+
exec "$JAVACMD" "$@"

‎gradlew.bat

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
17+
@if "%DEBUG%" == "" @echo off
18+
@rem ##########################################################################
19+
@rem
20+
@rem Gradle startup script for Windows
21+
@rem
22+
@rem ##########################################################################
23+
24+
@rem Set local scope for the variables with windows NT shell
25+
if "%OS%"=="Windows_NT" setlocal
26+
27+
set DIRNAME=%~dp0
28+
if "%DIRNAME%" == "" set DIRNAME=.
29+
set APP_BASE_NAME=%~n0
30+
set APP_HOME=%DIRNAME%
31+
32+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
33+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34+
35+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37+
38+
@rem Find java.exe
39+
if defined JAVA_HOME goto findJavaFromJavaHome
40+
41+
set JAVA_EXE=java.exe
42+
%JAVA_EXE% -version >NUL 2>&1
43+
if "%ERRORLEVEL%" == "0" goto execute
44+
45+
echo.
46+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47+
echo.
48+
echo Please set the JAVA_HOME variable in your environment to match the
49+
echo location of your Java installation.
50+
51+
goto fail
52+
53+
:findJavaFromJavaHome
54+
set JAVA_HOME=%JAVA_HOME:"=%
55+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56+
57+
if exist "%JAVA_EXE%" goto execute
58+
59+
echo.
60+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61+
echo.
62+
echo Please set the JAVA_HOME variable in your environment to match the
63+
echo location of your Java installation.
64+
65+
goto fail
66+
67+
:execute
68+
@rem Setup the command line
69+
70+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71+
72+
73+
@rem Execute Gradle
74+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75+
76+
:end
77+
@rem End local scope for the variables with windows NT shell
78+
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
80+
:fail
81+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82+
rem the _cmd.exe /c_ return code!
83+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84+
exit /b 1
85+
86+
:mainEnd
87+
if "%OS%"=="Windows_NT" endlocal
88+
89+
:omega

‎settings.gradle

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import org.gradle.internal.os.OperatingSystem
2+
3+
pluginManagement {
4+
repositories {
5+
mavenLocal()
6+
gradlePluginPortal()
7+
String frcYear = '2022'
8+
File frcHome
9+
if (OperatingSystem.current().isWindows()) {
10+
String publicFolder = System.getenv('PUBLIC')
11+
if (publicFolder == null) {
12+
publicFolder = "C:\\Users\\Public"
13+
}
14+
def homeRoot = new File(publicFolder, "wpilib")
15+
frcHome = new File(homeRoot, frcYear)
16+
} else {
17+
def userFolder = System.getProperty("user.home")
18+
def homeRoot = new File(userFolder, "wpilib")
19+
frcHome = new File(homeRoot, frcYear)
20+
}
21+
def frcHomeMaven = new File(frcHome, 'maven')
22+
maven {
23+
name 'frcHome'
24+
url frcHomeMaven
25+
}
26+
}
27+
}

‎simgui-ds.json

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"keyboardJoysticks": [
3+
{
4+
"axisConfig": [
5+
{
6+
"decKey": 65,
7+
"incKey": 68
8+
},
9+
{
10+
"decKey": 87,
11+
"incKey": 83
12+
},
13+
{
14+
"decKey": 69,
15+
"decayRate": 0.0,
16+
"incKey": 82,
17+
"keyRate": 0.009999999776482582
18+
}
19+
],
20+
"axisCount": 3,
21+
"buttonCount": 4,
22+
"buttonKeys": [
23+
90,
24+
88,
25+
67,
26+
86
27+
],
28+
"povConfig": [
29+
{
30+
"key0": 328,
31+
"key135": 323,
32+
"key180": 322,
33+
"key225": 321,
34+
"key270": 324,
35+
"key315": 327,
36+
"key45": 329,
37+
"key90": 326
38+
}
39+
],
40+
"povCount": 1
41+
},
42+
{
43+
"axisConfig": [
44+
{
45+
"decKey": 74,
46+
"incKey": 76
47+
},
48+
{
49+
"decKey": 73,
50+
"incKey": 75
51+
}
52+
],
53+
"axisCount": 2,
54+
"buttonCount": 4,
55+
"buttonKeys": [
56+
77,
57+
44,
58+
46,
59+
47
60+
],
61+
"povCount": 0
62+
},
63+
{
64+
"axisConfig": [
65+
{
66+
"decKey": 263,
67+
"incKey": 262
68+
},
69+
{
70+
"decKey": 265,
71+
"incKey": 264
72+
}
73+
],
74+
"axisCount": 2,
75+
"buttonCount": 6,
76+
"buttonKeys": [
77+
260,
78+
268,
79+
266,
80+
261,
81+
269,
82+
267
83+
],
84+
"povCount": 0
85+
},
86+
{
87+
"axisCount": 0,
88+
"buttonCount": 0,
89+
"povCount": 0
90+
}
91+
],
92+
"robotJoysticks": [
93+
{},
94+
{
95+
"guid": "78696e70757401000000000000000000",
96+
"useGamepad": true
97+
}
98+
]
99+
}

‎simgui.json

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"HALProvider": {
3+
"Encoders": {
4+
"window": {
5+
"visible": true
6+
}
7+
},
8+
"PWM Outputs": {
9+
"window": {
10+
"visible": true
11+
}
12+
},
13+
"RoboRIO": {
14+
"window": {
15+
"visible": true
16+
}
17+
}
18+
},
19+
"NTProvider": {
20+
"types": {
21+
"/FMSInfo": "FMSInfo",
22+
"/LiveWindow/DriveSubsystem": "Subsystem",
23+
"/LiveWindow/Ungrouped/ADXRS450_Gyro[0]": "Gyro",
24+
"/LiveWindow/Ungrouped/DifferentialDrive[1]": "DifferentialDrive",
25+
"/LiveWindow/Ungrouped/Scheduler": "Scheduler"
26+
}
27+
},
28+
"NetworkTables": {
29+
"FMSInfo": {
30+
"open": true
31+
},
32+
"LiveWindow": {
33+
"Ungrouped": {
34+
"open": true
35+
},
36+
"open": true
37+
}
38+
}
39+
}

‎src/main/deploy/example.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Files placed in this directory will be deployed to the RoboRIO into the
2+
'deploy' directory in the home folder. Use the 'Filesystem.getDeployDirectory' wpilib function
3+
to get a proper path relative to the deploy directory.
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot;
6+
7+
import edu.wpi.first.math.kinematics.DifferentialDriveKinematics;
8+
9+
/**
10+
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
11+
* constants. This class should not be used for any other purpose. All constants should be declared
12+
* globally (i.e. public static). Do not put anything functional in this class.
13+
*
14+
* <p>It is advised to statically import this class (or one of its inner classes) wherever the
15+
* constants are needed, to reduce verbosity.
16+
*/
17+
public final class Constants {
18+
public static final class DriveConstants {
19+
public static final int kLeftMotor1Port = 2;
20+
public static final int kLeftMotor2Port = 3;
21+
public static final int kRightMotor1Port = 0;
22+
public static final int kRightMotor2Port = 1;
23+
24+
public static final int[] kLeftEncoderPorts = new int[] {2, 3};
25+
public static final int[] kRightEncoderPorts = new int[] {0, 1};
26+
public static final boolean kLeftEncoderReversed = false;
27+
public static final boolean kRightEncoderReversed = true;
28+
29+
public static final double kTrackwidthMeters = 0.69;
30+
public static final DifferentialDriveKinematics kDriveKinematics =
31+
new DifferentialDriveKinematics(kTrackwidthMeters);
32+
33+
public static final int kEncoderCPR = 1024;
34+
public static final double kWheelDiameterMeters = 0.15;
35+
public static final double kEncoderDistancePerPulse =
36+
// Assumes the encoders are directly mounted on the wheel shafts
37+
(kWheelDiameterMeters * Math.PI) / (double) kEncoderCPR;
38+
39+
// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
40+
// These characterization values MUST be determined either experimentally or theoretically
41+
// for *your* robot's drive.
42+
// The Robot Characterization Toolsuite provides a convenient tool for obtaining these
43+
// values for your robot.
44+
public static final double ksVolts = 0.22;
45+
public static final double kvVoltSecondsPerMeter = 1.98;
46+
public static final double kaVoltSecondsSquaredPerMeter = 0.2;
47+
48+
// Example value only - as above, this must be tuned for your drive!
49+
public static final double kPDriveVel = 8.5;
50+
}
51+
52+
public static final class OIConstants {
53+
public static final int kDriverControllerPort = 1;
54+
}
55+
56+
public static final class AutoConstants {
57+
public static final double kMaxSpeedMetersPerSecond = 3;
58+
public static final double kMaxAccelerationMetersPerSecondSquared = 3;
59+
60+
// Reasonable baseline values for a RAMSETE follower in units of meters and seconds
61+
public static final double kRamseteB = 2;
62+
public static final double kRamseteZeta = 0.7;
63+
}
64+
65+
public static final class ArmConstants {
66+
public static final int amr1 = 5;
67+
public static final int arm2 = 4;
68+
}
69+
}

‎src/main/java/frc/robot/Main.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot;
6+
7+
import edu.wpi.first.wpilibj.RobotBase;
8+
9+
/**
10+
* Do NOT add any static variables to this class, or any initialization at all. Unless you know what
11+
* you are doing, do not modify this file except to change the parameter class to the startRobot
12+
* call.
13+
*/
14+
public final class Main {
15+
private Main() {}
16+
17+
/**
18+
* Main initialization function. Do not perform any initialization here.
19+
*
20+
* <p>If you change your main robot class, change the parameter type.
21+
*/
22+
public static void main(String... args) {
23+
RobotBase.startRobot(Robot::new);
24+
}
25+
}

‎src/main/java/frc/robot/Robot.java

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot;
6+
7+
import edu.wpi.first.wpilibj.TimedRobot;
8+
import edu.wpi.first.wpilibj2.command.Command;
9+
import edu.wpi.first.wpilibj2.command.CommandScheduler;
10+
11+
/**
12+
* The VM is configured to automatically run this class, and to call the functions corresponding to
13+
* each mode, as described in the TimedRobot documentation. If you change the name of this class or
14+
* the package after creating this project, you must also update the build.gradle file in the
15+
* project.
16+
*/
17+
public class Robot extends TimedRobot {
18+
private Command m_autonomousCommand;
19+
20+
private RobotContainer m_robotContainer;
21+
22+
/**
23+
* This function is run when the robot is first started up and should be used for any
24+
* initialization code.
25+
*/
26+
@Override
27+
public void robotInit() {
28+
// Instantiate our RobotContainer. This will perform all our button bindings, and put our
29+
// autonomous chooser on the dashboard.
30+
m_robotContainer = new RobotContainer();
31+
}
32+
33+
/**
34+
* This function is called every 20 ms, no matter the mode. Use this for items like diagnostics
35+
* that you want ran during disabled, autonomous, teleoperated and test.
36+
*
37+
* <p>This runs after the mode specific periodic functions, but before LiveWindow and
38+
* SmartDashboard integrated updating.
39+
*/
40+
@Override
41+
public void robotPeriodic() {
42+
// Runs the Scheduler. This is responsible for polling buttons, adding newly-scheduled
43+
// commands, running already-scheduled commands, removing finished or interrupted commands,
44+
// and running subsystem periodic() methods. This must be called from the robot's periodic
45+
// block in order for anything in the Command-based framework to work.
46+
CommandScheduler.getInstance().run();
47+
}
48+
49+
/** This function is called once each time the robot enters Disabled mode. */
50+
@Override
51+
public void disabledInit() {}
52+
53+
@Override
54+
public void disabledPeriodic() {}
55+
56+
/** This autonomous runs the autonomous command selected by your {@link RobotContainer} class. */
57+
@Override
58+
public void autonomousInit() {
59+
// m_autonomousCommand = m_robotContainer.getAutonomousCommand();
60+
61+
/*
62+
* String autoSelected = SmartDashboard.getString("Auto Selector",
63+
* "Default"); switch(autoSelected) { case "My Auto": autonomousCommand
64+
* = new MyAutoCommand(); break; case "Default Auto": default:
65+
* autonomousCommand = new ExampleCommand(); break; }
66+
*/
67+
68+
// schedule the autonomous command (example)
69+
if (m_autonomousCommand != null) {
70+
m_autonomousCommand.schedule();
71+
}
72+
}
73+
74+
/** This function is called periodically during autonomous. */
75+
@Override
76+
public void autonomousPeriodic() {}
77+
78+
@Override
79+
public void teleopInit() {
80+
// This makes sure that the autonomous stops running when
81+
// teleop starts running. If you want the autonomous to
82+
// continue until interrupted by another command, remove
83+
// this line or comment it out.
84+
if (m_autonomousCommand != null) {
85+
m_autonomousCommand.cancel();
86+
}
87+
}
88+
89+
/** This function is called periodically during operator control. */
90+
@Override
91+
public void teleopPeriodic() {}
92+
93+
@Override
94+
public void testInit() {
95+
// Cancels all running commands at the start of test mode.
96+
CommandScheduler.getInstance().cancelAll();
97+
}
98+
99+
/** This function is called periodically during test mode. */
100+
@Override
101+
public void testPeriodic() {}
102+
}
+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot;
6+
7+
import static edu.wpi.first.wpilibj.XboxController.Button;
8+
9+
import edu.wpi.first.math.controller.PIDController;
10+
import edu.wpi.first.math.controller.RamseteController;
11+
import edu.wpi.first.math.controller.SimpleMotorFeedforward;
12+
import edu.wpi.first.math.geometry.Pose2d;
13+
import edu.wpi.first.math.geometry.Rotation2d;
14+
import edu.wpi.first.math.geometry.Translation2d;
15+
import edu.wpi.first.math.trajectory.Trajectory;
16+
import edu.wpi.first.math.trajectory.TrajectoryConfig;
17+
import edu.wpi.first.math.trajectory.TrajectoryGenerator;
18+
import edu.wpi.first.math.trajectory.constraint.DifferentialDriveVoltageConstraint;
19+
import edu.wpi.first.wpilibj.XboxController;
20+
import frc.robot.Constants.AutoConstants;
21+
import frc.robot.Constants.DriveConstants;
22+
import frc.robot.Constants.OIConstants;
23+
import frc.robot.subsystems.DriveSubsystem;
24+
import edu.wpi.first.wpilibj2.command.Command;
25+
import edu.wpi.first.wpilibj2.command.RamseteCommand;
26+
import edu.wpi.first.wpilibj2.command.RunCommand;
27+
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
28+
import java.util.List;
29+
30+
/**
31+
* This class is where the bulk of the robot should be declared. Since Command-based is a
32+
* "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot}
33+
* periodic methods (other than the scheduler calls). Instead, the structure of the robot (including
34+
* subsystems, commands, and button mappings) should be declared here.
35+
*/
36+
public class RobotContainer {
37+
// The robot's subsystems
38+
private final DriveSubsystem m_robotDrive = new DriveSubsystem();
39+
40+
// The driver's controller
41+
XboxController m_driverController = new XboxController(OIConstants.kDriverControllerPort);
42+
43+
/** The container for the robot. Contains subsystems, OI devices, and commands. */
44+
public RobotContainer() {
45+
// Configure the button bindings
46+
configureButtonBindings();
47+
48+
49+
50+
51+
// Configure default commands
52+
// Set the default drive command to split-stick arcade drive
53+
m_robotDrive.setDefaultCommand(
54+
// A split-stick arcade command
55+
new RunCommand(
56+
() ->
57+
m_robotDrive.arcadeDrive(
58+
-m_driverController.getRightY(), m_driverController.getLeftX()),
59+
m_robotDrive));
60+
}
61+
62+
/**
63+
* Use this method to define your button->command mappings. Buttons can be created by
64+
* instantiating a {@link edu.wpi.first.wpilibj.GenericHID} or one of its subclasses ({@link
65+
* edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then calling passing it to a
66+
* {@link JoystickButton}.
67+
*/
68+
private void configureButtonBindings() {
69+
// Drive at half speed when the right bumper is held
70+
new JoystickButton(m_driverController, Button.kRightBumper.value)
71+
.whenPressed(() -> m_robotDrive.setMaxOutput(0.5))
72+
.whenReleased(() -> m_robotDrive.setMaxOutput(1));
73+
}
74+
75+
/**
76+
* Use this to pass the autonomous command to the main {@link Robot} class.
77+
*
78+
* @return the command to run in autonomous
79+
*/
80+
public Command getAutonomousCommand() {
81+
// Create a voltage constraint to ensure we don't accelerate too fast
82+
var autoVoltageConstraint =
83+
new DifferentialDriveVoltageConstraint(
84+
new SimpleMotorFeedforward(
85+
DriveConstants.ksVolts,
86+
DriveConstants.kvVoltSecondsPerMeter,
87+
DriveConstants.kaVoltSecondsSquaredPerMeter),
88+
DriveConstants.kDriveKinematics,
89+
10);
90+
91+
// Create config for trajectory
92+
TrajectoryConfig config =
93+
new TrajectoryConfig(
94+
AutoConstants.kMaxSpeedMetersPerSecond,
95+
AutoConstants.kMaxAccelerationMetersPerSecondSquared)
96+
// Add kinematics to ensure max speed is actually obeyed
97+
.setKinematics(DriveConstants.kDriveKinematics)
98+
// Apply the voltage constraint
99+
.addConstraint(autoVoltageConstraint);
100+
101+
// An example trajectory to follow. All units in meters.
102+
Trajectory exampleTrajectory =
103+
TrajectoryGenerator.generateTrajectory(
104+
// Start at the origin facing the +X direction
105+
new Pose2d(0, 0, new Rotation2d(0)),
106+
// Pass through these two interior waypoints, making an 's' curve path
107+
List.of(new Translation2d(1, 1), new Translation2d(2, -1)),
108+
// End 3 meters straight ahead of where we started, facing forward
109+
new Pose2d(3, 0, new Rotation2d(0)),
110+
// Pass config
111+
config);
112+
113+
RamseteCommand ramseteCommand =
114+
new RamseteCommand(
115+
exampleTrajectory,
116+
m_robotDrive::getPose,
117+
new RamseteController(AutoConstants.kRamseteB, AutoConstants.kRamseteZeta),
118+
new SimpleMotorFeedforward(
119+
DriveConstants.ksVolts,
120+
DriveConstants.kvVoltSecondsPerMeter,
121+
DriveConstants.kaVoltSecondsSquaredPerMeter),
122+
DriveConstants.kDriveKinematics,
123+
m_robotDrive::getWheelSpeeds,
124+
new PIDController(DriveConstants.kPDriveVel, 0, 0),
125+
new PIDController(DriveConstants.kPDriveVel, 0, 0),
126+
// RamseteCommand passes volts to the callback
127+
m_robotDrive::tankDriveVolts,
128+
m_robotDrive);
129+
130+
// Reset odometry to the starting pose of the trajectory.
131+
m_robotDrive.resetOdometry(exampleTrajectory.getInitialPose());
132+
133+
// Run path following command, then stop at the end.
134+
return ramseteCommand.andThen(() -> m_robotDrive.tankDriveVolts(0, 0));
135+
}
136+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.subsystems;
6+
7+
import edu.wpi.first.math.geometry.Pose2d;
8+
import edu.wpi.first.math.kinematics.DifferentialDriveOdometry;
9+
import edu.wpi.first.math.kinematics.DifferentialDriveWheelSpeeds;
10+
import edu.wpi.first.wpilibj.ADXRS450_Gyro;
11+
import edu.wpi.first.wpilibj.Encoder;
12+
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
13+
import frc.robot.Constants.DriveConstants;
14+
import edu.wpi.first.wpilibj.interfaces.Gyro;
15+
import edu.wpi.first.wpilibj.motorcontrol.MotorControllerGroup;
16+
import edu.wpi.first.wpilibj2.command.SubsystemBase;
17+
import com.ctre.phoenix.motorcontrol.NeutralMode;
18+
import com.ctre.phoenix.motorcontrol.TalonFXInvertType;
19+
import com.ctre.phoenix.motorcontrol.ControlMode;
20+
import com.ctre.phoenix.motorcontrol.DemandType;
21+
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
22+
23+
public class DriveSubsystem extends SubsystemBase {
24+
// The motors on the left side of the drive.
25+
private final WPI_TalonFX m_leftMotor1 = new WPI_TalonFX(DriveConstants.kLeftMotor1Port);
26+
private final WPI_TalonFX m_leftMotor2 = new WPI_TalonFX(DriveConstants.kLeftMotor2Port);
27+
28+
// The motors on the right side of the drive.
29+
private final WPI_TalonFX m_rightMotor1 = new WPI_TalonFX(DriveConstants.kRightMotor1Port);
30+
private final WPI_TalonFX m_rightMotor2 = new WPI_TalonFX(DriveConstants.kRightMotor2Port);
31+
32+
33+
// The robot's drive
34+
private final DifferentialDrive m_drive = new DifferentialDrive(
35+
new MotorControllerGroup(m_leftMotor1, m_leftMotor2),
36+
new MotorControllerGroup(m_rightMotor1, m_rightMotor2));
37+
38+
// The left-side drive encoder
39+
private final Encoder m_leftEncoder =
40+
new Encoder(
41+
DriveConstants.kLeftEncoderPorts[0],
42+
DriveConstants.kLeftEncoderPorts[1],
43+
DriveConstants.kLeftEncoderReversed);
44+
45+
// The right-side drive encoder
46+
private final Encoder m_rightEncoder =
47+
new Encoder(
48+
DriveConstants.kRightEncoderPorts[0],
49+
DriveConstants.kRightEncoderPorts[1],
50+
DriveConstants.kRightEncoderReversed);
51+
52+
// The gyro sensor
53+
private final Gyro m_gyro = new ADXRS450_Gyro();
54+
55+
// Odometry class for tracking robot pose
56+
private final DifferentialDriveOdometry m_odometry;
57+
58+
/** Creates a new DriveSubsystem. */
59+
public DriveSubsystem() {
60+
// We need to invert one side of the drivetrain so that positive voltages
61+
// result in both sides moving forward. Depending on how your robot's
62+
// gearbox is constructed, you might have to invert the left side instead.
63+
64+
m_rightMotor1.set(ControlMode.PercentOutput, 0);
65+
m_rightMotor2.set(ControlMode.PercentOutput, 0);
66+
m_leftMotor1.set(ControlMode.PercentOutput, 0);
67+
m_leftMotor2.set(ControlMode.PercentOutput, 0);
68+
69+
m_rightMotor1.configFactoryDefault();
70+
m_rightMotor2.configFactoryDefault();
71+
m_leftMotor1.configFactoryDefault();
72+
m_leftMotor2.configFactoryDefault();
73+
74+
m_rightMotor1.setNeutralMode(NeutralMode.Brake);
75+
m_rightMotor2.setNeutralMode(NeutralMode.Brake);
76+
m_leftMotor1.setNeutralMode(NeutralMode.Brake);
77+
m_leftMotor2.setNeutralMode(NeutralMode.Brake);
78+
79+
m_rightMotor1.setInverted(TalonFXInvertType.Clockwise);
80+
m_rightMotor2.setInverted(TalonFXInvertType.Clockwise);
81+
m_leftMotor1.setInverted(TalonFXInvertType.CounterClockwise);
82+
m_leftMotor2.setInverted(TalonFXInvertType.CounterClockwise);
83+
84+
85+
86+
87+
88+
// Sets the distance per pulse for the encoders
89+
m_leftEncoder.setDistancePerPulse(DriveConstants.kEncoderDistancePerPulse);
90+
m_rightEncoder.setDistancePerPulse(DriveConstants.kEncoderDistancePerPulse);
91+
92+
resetEncoders();
93+
m_odometry = new DifferentialDriveOdometry(m_gyro.getRotation2d());
94+
}
95+
96+
@Override
97+
public void periodic() {
98+
// Update the odometry in the periodic block
99+
m_odometry.update(
100+
m_gyro.getRotation2d(), m_leftEncoder.getDistance(), m_rightEncoder.getDistance());
101+
}
102+
103+
/**
104+
* Returns the currently-estimated pose of the robot.
105+
*
106+
* @return The pose.
107+
*/
108+
public Pose2d getPose() {
109+
return m_odometry.getPoseMeters();
110+
}
111+
112+
/**
113+
* Returns the current wheel speeds of the robot.
114+
*
115+
* @return The current wheel speeds.
116+
*/
117+
public DifferentialDriveWheelSpeeds getWheelSpeeds() {
118+
return new DifferentialDriveWheelSpeeds(m_leftEncoder.getRate(), m_rightEncoder.getRate());
119+
}
120+
121+
/**
122+
* Resets the odometry to the specified pose.
123+
*
124+
* @param pose The pose to which to set the odometry.
125+
*/
126+
public void resetOdometry(Pose2d pose) {
127+
resetEncoders();
128+
m_odometry.resetPosition(pose, m_gyro.getRotation2d());
129+
}
130+
131+
/**
132+
* Drives the robot using arcade controls.
133+
*
134+
* @param fwd the commanded forward movement
135+
* @param rot the commanded rotation
136+
*/
137+
public void arcadeDrive(double fwd, double rot) {
138+
m_drive.arcadeDrive(fwd, rot);
139+
}
140+
141+
/**
142+
* Controls the left and right sides of the drive directly with voltages.
143+
*
144+
* @param leftVolts the commanded left output
145+
* @param rightVolts the commanded right output
146+
*/
147+
public void tankDriveVolts(double leftVolts, double rightVolts) {
148+
m_leftMotor1.setVoltage(leftVolts);
149+
m_leftMotor2.setVoltage(leftVolts);
150+
m_rightMotor1.setVoltage(rightVolts);
151+
m_rightMotor2.setVoltage(rightVolts);
152+
m_drive.feed();
153+
}
154+
155+
/** Resets the drive encoders to currently read a position of 0. */
156+
public void resetEncoders() {
157+
m_leftEncoder.reset();
158+
m_rightEncoder.reset();
159+
}
160+
161+
/**
162+
* Gets the average distance of the two encoders.
163+
*
164+
* @return the average of the two encoder readings
165+
*/
166+
public double getAverageEncoderDistance() {
167+
return (m_leftEncoder.getDistance() + m_rightEncoder.getDistance()) / 2.0;
168+
}
169+
170+
/**
171+
* Gets the left drive encoder.
172+
*
173+
* @return the left drive encoder
174+
*/
175+
public Encoder getLeftEncoder() {
176+
return m_leftEncoder;
177+
}
178+
179+
/**
180+
* Gets the right drive encoder.
181+
*
182+
* @return the right drive encoder
183+
*/
184+
public Encoder getRightEncoder() {
185+
return m_rightEncoder;
186+
}
187+
188+
/**
189+
* Sets the max output of the drive. Useful for scaling the drive to drive more slowly.
190+
*
191+
* @param maxOutput the maximum output to which the drive will be constrained
192+
*/
193+
public void setMaxOutput(double maxOutput) {
194+
m_drive.setMaxOutput(maxOutput);
195+
}
196+
197+
/** Zeroes the heading of the robot. */
198+
public void zeroHeading() {
199+
m_gyro.reset();
200+
}
201+
202+
/**
203+
* Returns the heading of the robot.
204+
*
205+
* @return the robot's heading in degrees, from -180 to 180
206+
*/
207+
public double getHeading() {
208+
return m_gyro.getRotation2d().getDegrees();
209+
}
210+
211+
/**
212+
* Returns the turn rate of the robot.
213+
*
214+
* @return The turn rate of the robot, in degrees per second
215+
*/
216+
public double getTurnRate() {
217+
return -m_gyro.getRate();
218+
}
219+
}

‎vendordeps/Phoenix.json

+257
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
{
2+
"fileName": "Phoenix.json",
3+
"name": "CTRE-Phoenix",
4+
"version": "5.21.2",
5+
"frcYear": 2022,
6+
"uuid": "ab676553-b602-441f-a38d-f1296eff6537",
7+
"mavenUrls": [
8+
"https://maven.ctr-electronics.com/release/"
9+
],
10+
"jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix-frc2022-latest.json",
11+
"javaDependencies": [
12+
{
13+
"groupId": "com.ctre.phoenix",
14+
"artifactId": "api-java",
15+
"version": "5.21.2"
16+
},
17+
{
18+
"groupId": "com.ctre.phoenix",
19+
"artifactId": "wpiapi-java",
20+
"version": "5.21.2"
21+
}
22+
],
23+
"jniDependencies": [
24+
{
25+
"groupId": "com.ctre.phoenix",
26+
"artifactId": "cci",
27+
"version": "5.21.2",
28+
"isJar": false,
29+
"skipInvalidPlatforms": true,
30+
"validPlatforms": [
31+
"linuxathena"
32+
]
33+
},
34+
{
35+
"groupId": "com.ctre.phoenix.sim",
36+
"artifactId": "cci-sim",
37+
"version": "5.21.2",
38+
"isJar": false,
39+
"skipInvalidPlatforms": true,
40+
"validPlatforms": [
41+
"windowsx86-64",
42+
"linuxx86-64",
43+
"osxx86-64"
44+
]
45+
},
46+
{
47+
"groupId": "com.ctre.phoenix.sim",
48+
"artifactId": "simTalonSRX",
49+
"version": "5.21.2",
50+
"isJar": false,
51+
"skipInvalidPlatforms": true,
52+
"validPlatforms": [
53+
"windowsx86-64",
54+
"linuxx86-64",
55+
"osxx86-64"
56+
]
57+
},
58+
{
59+
"groupId": "com.ctre.phoenix.sim",
60+
"artifactId": "simTalonFX",
61+
"version": "5.21.2",
62+
"isJar": false,
63+
"skipInvalidPlatforms": true,
64+
"validPlatforms": [
65+
"windowsx86-64",
66+
"linuxx86-64",
67+
"osxx86-64"
68+
]
69+
},
70+
{
71+
"groupId": "com.ctre.phoenix.sim",
72+
"artifactId": "simVictorSPX",
73+
"version": "5.21.2",
74+
"isJar": false,
75+
"skipInvalidPlatforms": true,
76+
"validPlatforms": [
77+
"windowsx86-64",
78+
"linuxx86-64",
79+
"osxx86-64"
80+
]
81+
},
82+
{
83+
"groupId": "com.ctre.phoenix.sim",
84+
"artifactId": "simPigeonIMU",
85+
"version": "5.21.2",
86+
"isJar": false,
87+
"skipInvalidPlatforms": true,
88+
"validPlatforms": [
89+
"windowsx86-64",
90+
"linuxx86-64",
91+
"osxx86-64"
92+
]
93+
},
94+
{
95+
"groupId": "com.ctre.phoenix.sim",
96+
"artifactId": "simCANCoder",
97+
"version": "5.21.2",
98+
"isJar": false,
99+
"skipInvalidPlatforms": true,
100+
"validPlatforms": [
101+
"windowsx86-64",
102+
"linuxx86-64",
103+
"osxx86-64"
104+
]
105+
}
106+
],
107+
"cppDependencies": [
108+
{
109+
"groupId": "com.ctre.phoenix",
110+
"artifactId": "wpiapi-cpp",
111+
"version": "5.21.2",
112+
"libName": "CTRE_Phoenix_WPI",
113+
"headerClassifier": "headers",
114+
"sharedLibrary": true,
115+
"skipInvalidPlatforms": true,
116+
"binaryPlatforms": [
117+
"linuxathena"
118+
]
119+
},
120+
{
121+
"groupId": "com.ctre.phoenix",
122+
"artifactId": "api-cpp",
123+
"version": "5.21.2",
124+
"libName": "CTRE_Phoenix",
125+
"headerClassifier": "headers",
126+
"sharedLibrary": true,
127+
"skipInvalidPlatforms": true,
128+
"binaryPlatforms": [
129+
"linuxathena"
130+
]
131+
},
132+
{
133+
"groupId": "com.ctre.phoenix",
134+
"artifactId": "cci",
135+
"version": "5.21.2",
136+
"libName": "CTRE_PhoenixCCI",
137+
"headerClassifier": "headers",
138+
"sharedLibrary": true,
139+
"skipInvalidPlatforms": true,
140+
"binaryPlatforms": [
141+
"linuxathena"
142+
]
143+
},
144+
{
145+
"groupId": "com.ctre.phoenix.sim",
146+
"artifactId": "wpiapi-cpp-sim",
147+
"version": "5.21.2",
148+
"libName": "CTRE_Phoenix_WPISim",
149+
"headerClassifier": "headers",
150+
"sharedLibrary": true,
151+
"skipInvalidPlatforms": true,
152+
"binaryPlatforms": [
153+
"windowsx86-64",
154+
"linuxx86-64",
155+
"osxx86-64"
156+
]
157+
},
158+
{
159+
"groupId": "com.ctre.phoenix.sim",
160+
"artifactId": "api-cpp-sim",
161+
"version": "5.21.2",
162+
"libName": "CTRE_PhoenixSim",
163+
"headerClassifier": "headers",
164+
"sharedLibrary": true,
165+
"skipInvalidPlatforms": true,
166+
"binaryPlatforms": [
167+
"windowsx86-64",
168+
"linuxx86-64",
169+
"osxx86-64"
170+
]
171+
},
172+
{
173+
"groupId": "com.ctre.phoenix.sim",
174+
"artifactId": "cci-sim",
175+
"version": "5.21.2",
176+
"libName": "CTRE_PhoenixCCISim",
177+
"headerClassifier": "headers",
178+
"sharedLibrary": true,
179+
"skipInvalidPlatforms": true,
180+
"binaryPlatforms": [
181+
"windowsx86-64",
182+
"linuxx86-64",
183+
"osxx86-64"
184+
]
185+
},
186+
{
187+
"groupId": "com.ctre.phoenix.sim",
188+
"artifactId": "simTalonSRX",
189+
"version": "5.21.2",
190+
"libName": "CTRE_SimTalonSRX",
191+
"headerClassifier": "headers",
192+
"sharedLibrary": true,
193+
"skipInvalidPlatforms": true,
194+
"binaryPlatforms": [
195+
"windowsx86-64",
196+
"linuxx86-64",
197+
"osxx86-64"
198+
]
199+
},
200+
{
201+
"groupId": "com.ctre.phoenix.sim",
202+
"artifactId": "simTalonFX",
203+
"version": "5.21.2",
204+
"libName": "CTRE_SimTalonFX",
205+
"headerClassifier": "headers",
206+
"sharedLibrary": true,
207+
"skipInvalidPlatforms": true,
208+
"binaryPlatforms": [
209+
"windowsx86-64",
210+
"linuxx86-64",
211+
"osxx86-64"
212+
]
213+
},
214+
{
215+
"groupId": "com.ctre.phoenix.sim",
216+
"artifactId": "simVictorSPX",
217+
"version": "5.21.2",
218+
"libName": "CTRE_SimVictorSPX",
219+
"headerClassifier": "headers",
220+
"sharedLibrary": true,
221+
"skipInvalidPlatforms": true,
222+
"binaryPlatforms": [
223+
"windowsx86-64",
224+
"linuxx86-64",
225+
"osxx86-64"
226+
]
227+
},
228+
{
229+
"groupId": "com.ctre.phoenix.sim",
230+
"artifactId": "simPigeonIMU",
231+
"version": "5.21.2",
232+
"libName": "CTRE_SimPigeonIMU",
233+
"headerClassifier": "headers",
234+
"sharedLibrary": true,
235+
"skipInvalidPlatforms": true,
236+
"binaryPlatforms": [
237+
"windowsx86-64",
238+
"linuxx86-64",
239+
"osxx86-64"
240+
]
241+
},
242+
{
243+
"groupId": "com.ctre.phoenix.sim",
244+
"artifactId": "simCANCoder",
245+
"version": "5.21.2",
246+
"libName": "CTRE_SimCANCoder",
247+
"headerClassifier": "headers",
248+
"sharedLibrary": true,
249+
"skipInvalidPlatforms": true,
250+
"binaryPlatforms": [
251+
"windowsx86-64",
252+
"linuxx86-64",
253+
"osxx86-64"
254+
]
255+
}
256+
]
257+
}

‎vendordeps/WPILibNewCommands.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"fileName": "WPILibNewCommands.json",
3+
"name": "WPILib-New-Commands",
4+
"version": "1.0.0",
5+
"uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266",
6+
"mavenUrls": [],
7+
"jsonUrl": "",
8+
"javaDependencies": [
9+
{
10+
"groupId": "edu.wpi.first.wpilibNewCommands",
11+
"artifactId": "wpilibNewCommands-java",
12+
"version": "wpilib"
13+
}
14+
],
15+
"jniDependencies": [],
16+
"cppDependencies": [
17+
{
18+
"groupId": "edu.wpi.first.wpilibNewCommands",
19+
"artifactId": "wpilibNewCommands-cpp",
20+
"version": "wpilib",
21+
"libName": "wpilibNewCommands",
22+
"headerClassifier": "headers",
23+
"sourcesClassifier": "sources",
24+
"sharedLibrary": true,
25+
"skipInvalidPlatforms": true,
26+
"binaryPlatforms": [
27+
"linuxathena",
28+
"linuxraspbian",
29+
"linuxaarch64bionic",
30+
"windowsx86-64",
31+
"windowsx86",
32+
"linuxx86-64",
33+
"osxx86-64"
34+
]
35+
}
36+
]
37+
}

0 commit comments

Comments
 (0)
Please sign in to comment.