Initial commit
This commit is contained in:
commit
0d99cc8055
41 changed files with 2326 additions and 0 deletions
162
.gitignore
vendored
Normal file
162
.gitignore
vendored
Normal file
|
@ -0,0 +1,162 @@
|
|||
# This gitignore has been specially created by the WPILib team.
|
||||
# If you remove items from this file, intellisense might break.
|
||||
|
||||
### C++ ###
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
### Java ###
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
### Linux ###
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
### Gradle ###
|
||||
.gradle
|
||||
/build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||
# gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
# # VS Code Specific Java Settings
|
||||
# DO NOT REMOVE .classpath and .project
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
bin/
|
||||
|
||||
# Simulation GUI and other tools window save file
|
||||
*-window.json
|
21
.vscode/launch.json
vendored
Normal file
21
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"type": "wpilib",
|
||||
"name": "WPILib Desktop Debug",
|
||||
"request": "launch",
|
||||
"desktop": true,
|
||||
},
|
||||
{
|
||||
"type": "wpilib",
|
||||
"name": "WPILib roboRIO Debug",
|
||||
"request": "launch",
|
||||
"desktop": false,
|
||||
}
|
||||
]
|
||||
}
|
83
.vscode/settings.json
vendored
Normal file
83
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
{
|
||||
"java.configuration.updateBuildConfiguration": "disabled",
|
||||
"java.import.gradle.enabled": false,
|
||||
"files.exclude": {
|
||||
"**/.git": true,
|
||||
"**/.svn": true,
|
||||
"**/.hg": true,
|
||||
"**/CVS": true,
|
||||
"**/.DS_Store": true,
|
||||
"bin/": true,
|
||||
"**/.classpath": true,
|
||||
"**/.project": true,
|
||||
"**/.settings": true,
|
||||
"**/.factorypath": true,
|
||||
"**/*~": true
|
||||
},
|
||||
"C_Cpp.default.configurationProvider": "vscode-wpilib",
|
||||
"files.associations": {
|
||||
"*.inc": "cpp",
|
||||
"ratio": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"deque": "cpp",
|
||||
"vector": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"hash_map": "cpp",
|
||||
"hash_set": "cpp",
|
||||
"cctype": "cpp",
|
||||
"chrono": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"complex": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"list": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"filesystem": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"map": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
}
|
||||
}
|
6
.wpilib/wpilib_preferences.json
Normal file
6
.wpilib/wpilib_preferences.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"enableCppIntellisense": true,
|
||||
"currentLanguage": "cpp",
|
||||
"projectYear": "2022",
|
||||
"teamNumber": 1592
|
||||
}
|
24
WPILib-License.md
Normal file
24
WPILib-License.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
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.
|
99
build.gradle
Normal file
99
build.gradle
Normal file
|
@ -0,0 +1,99 @@
|
|||
plugins {
|
||||
id "cpp"
|
||||
id "google-test-test-suite"
|
||||
id "edu.wpi.first.GradleRIO" version "2022.4.1"
|
||||
}
|
||||
|
||||
// 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.getTeamNumber()
|
||||
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) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=permwrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=permwrapper/dists
|
234
gradlew
vendored
Executable file
234
gradlew
vendored
Executable file
|
@ -0,0 +1,234 @@
|
|||
#!/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
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && 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 \
|
||||
"$@"
|
||||
|
||||
# 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" "$@"
|
89
gradlew.bat
vendored
Normal file
89
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
@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%" == "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%"=="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!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
27
settings.gradle
Normal file
27
settings.gradle
Normal file
|
@ -0,0 +1,27 @@
|
|||
import org.gradle.internal.os.OperatingSystem
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
String frcYear = '2022'
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
113
simgui-ds.json
Normal file
113
simgui-ds.json
Normal file
|
@ -0,0 +1,113 @@
|
|||
{
|
||||
"Keyboard 0 Settings": {
|
||||
"window": {
|
||||
"visible": true
|
||||
}
|
||||
},
|
||||
"keyboardJoysticks": [
|
||||
{
|
||||
"axisConfig": [
|
||||
{
|
||||
"decKey": 65,
|
||||
"incKey": 68
|
||||
},
|
||||
{
|
||||
"decKey": 87,
|
||||
"incKey": 83
|
||||
},
|
||||
{
|
||||
"decKey": 69,
|
||||
"incKey": 82
|
||||
}
|
||||
],
|
||||
"axisCount": 3,
|
||||
"buttonCount": 10,
|
||||
"buttonKeys": [
|
||||
90,
|
||||
88,
|
||||
67,
|
||||
86,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
57,
|
||||
48
|
||||
],
|
||||
"povConfig": [
|
||||
{
|
||||
"key0": 328,
|
||||
"key135": 323,
|
||||
"key180": 322,
|
||||
"key225": 321,
|
||||
"key270": 324,
|
||||
"key315": 327,
|
||||
"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"
|
||||
},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
{
|
||||
"guid": "0300000051090000a416000011010000",
|
||||
"name": "asddsa"
|
||||
}
|
||||
]
|
||||
}
|
152
simgui.json
Normal file
152
simgui.json
Normal file
|
@ -0,0 +1,152 @@
|
|||
{
|
||||
"HALProvider": {
|
||||
"RoboRIO": {
|
||||
"window": {
|
||||
"visible": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"NTProvider": {
|
||||
"types": {
|
||||
"/FMSInfo": "FMSInfo",
|
||||
"/LiveWindow/Ungrouped/Scheduler": "Scheduler",
|
||||
"/LiveWindow/Ungrouped/frc2::SubsystemBase": "Subsystem",
|
||||
"/SmartDashboard/chassis": "Subsystem",
|
||||
"/SmartDashboard/frc2::SubsystemBase": "Subsystem",
|
||||
"/SmartDashboard/potato_cannon": "Subsystem"
|
||||
},
|
||||
"windows": {
|
||||
"/SmartDashboard/chassis": {
|
||||
"window": {
|
||||
"visible": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"NetworkTables": {
|
||||
"FMSInfo": {
|
||||
"open": true
|
||||
},
|
||||
"LiveWindow": {
|
||||
".status": {
|
||||
"open": true
|
||||
},
|
||||
"Ungrouped": {
|
||||
"Scheduler": {
|
||||
"open": true
|
||||
},
|
||||
"frc2::SubsystemBase": {
|
||||
"open": true
|
||||
},
|
||||
"open": true
|
||||
},
|
||||
"open": true
|
||||
},
|
||||
"SmartDashboard": {
|
||||
"chassis": {
|
||||
"open": true
|
||||
},
|
||||
"frc2::SubsystemBase": {
|
||||
"open": true
|
||||
},
|
||||
"open": true,
|
||||
"potato_cannon": {
|
||||
"open": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"Plot": {
|
||||
"Plot <0>": {
|
||||
"plots": [
|
||||
{
|
||||
"axis": [
|
||||
{
|
||||
"autoFit": true
|
||||
}
|
||||
],
|
||||
"height": 320,
|
||||
"series": [
|
||||
{
|
||||
"color": [
|
||||
0.2980392277240753,
|
||||
0.44705885648727417,
|
||||
0.6901960968971252,
|
||||
1.0
|
||||
],
|
||||
"id": "Rio 6V Voltage"
|
||||
},
|
||||
{
|
||||
"color": [
|
||||
0.8666667342185974,
|
||||
0.5176470875740051,
|
||||
0.32156863808631897,
|
||||
1.0
|
||||
],
|
||||
"id": "Joystick[0] Axis[0]"
|
||||
},
|
||||
{
|
||||
"color": [
|
||||
0.3333333432674408,
|
||||
0.658823549747467,
|
||||
0.4078431725502014,
|
||||
1.0
|
||||
],
|
||||
"id": "Joystick[0] Axis[1]"
|
||||
},
|
||||
{
|
||||
"color": [
|
||||
0.7686275243759155,
|
||||
0.30588236451148987,
|
||||
0.32156863808631897,
|
||||
1.0
|
||||
],
|
||||
"id": "NT:/SmartDashboard/lb_pod.angle"
|
||||
},
|
||||
{
|
||||
"color": [
|
||||
0.5058823823928833,
|
||||
0.44705885648727417,
|
||||
0.7019608020782471,
|
||||
1.0
|
||||
],
|
||||
"id": "NT:/SmartDashboard/lf_pod.angle"
|
||||
},
|
||||
{
|
||||
"color": [
|
||||
0.5764706134796143,
|
||||
0.4705882668495178,
|
||||
0.3764706254005432,
|
||||
1.0
|
||||
],
|
||||
"id": "NT:/SmartDashboard/rb_pod.angle"
|
||||
},
|
||||
{
|
||||
"color": [
|
||||
0.8549020290374756,
|
||||
0.545098066329956,
|
||||
0.7647059559822083,
|
||||
1.0
|
||||
],
|
||||
"id": "NT:/SmartDashboard/rf_pod.angle"
|
||||
},
|
||||
{
|
||||
"color": [
|
||||
0.2724913954734802,
|
||||
1.0,
|
||||
0.14705884456634521,
|
||||
1.0
|
||||
],
|
||||
"id": "NT:/SmartDashboard/lb_pod.mag"
|
||||
}
|
||||
],
|
||||
"yaxis2": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"Plot <1>": {
|
||||
"window": {
|
||||
"visible": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
82
src/main/cpp/Robot.cpp
Normal file
82
src/main/cpp/Robot.cpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "Robot.h"
|
||||
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc2/command/CommandScheduler.h>
|
||||
|
||||
void Robot::RobotInit() {}
|
||||
|
||||
/**
|
||||
* This function is called every 20 ms, no matter the mode. Use
|
||||
* this for items like diagnostics that you want to run during disabled,
|
||||
* autonomous, teleoperated and test.
|
||||
*
|
||||
* <p> This runs after the mode specific periodic functions, but before
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called once each time the robot enters Disabled mode. You
|
||||
* can use it to reset any subsystem information you want to clear when the
|
||||
* robot is disabled.
|
||||
*/
|
||||
void Robot::DisabledInit() {}
|
||||
|
||||
void Robot::DisabledPeriodic() {}
|
||||
|
||||
/**
|
||||
* This autonomous runs the autonomous command selected by your {@link
|
||||
* RobotContainer} class.
|
||||
*/
|
||||
void Robot::AutonomousInit() {
|
||||
m_autonomous_command = m_container.get_autonomous_command();
|
||||
|
||||
if (m_autonomous_command != nullptr) {
|
||||
m_autonomous_command->Schedule();
|
||||
}
|
||||
}
|
||||
|
||||
void Robot::AutonomousPeriodic() {}
|
||||
|
||||
void Robot::TeleopInit() {
|
||||
// This makes sure that the autonomous stops running when
|
||||
// teleop starts running. If you want the autonomous to
|
||||
// continue until interrupted by another command, remove
|
||||
// this line or comment it out.
|
||||
if (m_autonomous_command != nullptr) {
|
||||
m_autonomous_command->Cancel();
|
||||
m_autonomous_command = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called periodically during operator control.
|
||||
*/
|
||||
void Robot::TeleopPeriodic() {}
|
||||
|
||||
/**
|
||||
* This function is called periodically during test mode.
|
||||
*/
|
||||
void Robot::TestPeriodic() {}
|
||||
|
||||
/**
|
||||
* This function is called once when the robot is first started up.
|
||||
*/
|
||||
void Robot::SimulationInit() {}
|
||||
|
||||
/**
|
||||
* This function is called periodically whilst in simulation.
|
||||
*/
|
||||
void Robot::SimulationPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
55
src/main/cpp/RobotContainer.cpp
Normal file
55
src/main/cpp/RobotContainer.cpp
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "Constants.h"
|
||||
#include "RobotContainer.h"
|
||||
|
||||
#include <frc/PowerDistribution.h>
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc2/command/button/JoystickButton.h>
|
||||
|
||||
RobotContainer::RobotContainer() :
|
||||
m_autonomous_command(m_chassis, m_driver) {
|
||||
// Initialize all of your commands and subsystems here
|
||||
m_chassis.SetDefaultCommand(DriveWithJoysticks(m_chassis, m_driver));
|
||||
|
||||
frc::SmartDashboard::PutData("chassis", &m_chassis);
|
||||
frc::SmartDashboard::PutData("shooter", &m_shooter);
|
||||
|
||||
// Configure the button bindings
|
||||
map_buttons();
|
||||
}
|
||||
|
||||
void RobotContainer::map_buttons() {
|
||||
// Configure your button bindings here
|
||||
// frc2::JoystickButton(&m_manip, 4).WhenPressed(
|
||||
// SetShooterSpeed(&m_potatoCannon, SHOOTER_RPM));
|
||||
|
||||
// Zero gyro
|
||||
frc2::JoystickButton(&m_driver, 10).WhenPressed(
|
||||
frc2::InstantCommand{[this] {
|
||||
m_chassis.zero_gyro(); }, {&m_chassis}});
|
||||
|
||||
// Shooter speeds
|
||||
frc2::JoystickButton(&m_manip, 4).WhenPressed(
|
||||
frc2::InstantCommand{[this] {
|
||||
m_shooter.set(constants::shooter::HIGH); }});
|
||||
frc2::JoystickButton(&m_manip, 3).WhenPressed(
|
||||
frc2::InstantCommand{[this] {
|
||||
m_shooter.set(constants::shooter::MED); }});
|
||||
frc2::JoystickButton(&m_manip, 1).WhenPressed(
|
||||
frc2::InstantCommand{[this] {
|
||||
m_shooter.set(constants::shooter::LOW); }});
|
||||
frc2::JoystickButton(&m_manip, 2).WhenPressed(
|
||||
frc2::InstantCommand{[this] {
|
||||
m_shooter.set(0_rpm); }});
|
||||
|
||||
// Gatherer
|
||||
}
|
||||
|
||||
frc2::Command* RobotContainer::get_autonomous_command() {
|
||||
// An example command will be run in autonomous
|
||||
return &m_autonomous_command;
|
||||
}
|
40
src/main/cpp/commands/DriveWithJoysticks.cpp
Normal file
40
src/main/cpp/commands/DriveWithJoysticks.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "commands/DriveWithJoysticks.h"
|
||||
#include "Utils.h"
|
||||
|
||||
DriveWithJoysticks::DriveWithJoysticks(Chassis &chassis, frc::Joystick &joystick)
|
||||
: m_chassis{chassis}, m_joystick{joystick} {
|
||||
SetName("DriveWithJoysticks");
|
||||
AddRequirements(&m_chassis);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
void DriveWithJoysticks::Initialize() {}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void DriveWithJoysticks::Execute() {
|
||||
auto x = m_joystick.GetX();
|
||||
auto y = m_joystick.GetY();
|
||||
auto z = m_joystick.GetZ();
|
||||
|
||||
x = utils::joy_expo(x, constants::joysticks::JOY_DRIVE_EXPO);
|
||||
y = utils::joy_expo(y, constants::joysticks::JOY_DRIVE_EXPO);
|
||||
z = utils::joy_expo(z, constants::joysticks::JOY_TURN_EXPO);
|
||||
|
||||
auto forward = -y * 2_fps;
|
||||
auto left = -x * 2_fps;
|
||||
auto theta = z * 1.5_rad_per_s;
|
||||
|
||||
m_chassis.drive_field_relative(forward, left, theta);
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
void DriveWithJoysticks::End(bool interrupted) {}
|
||||
|
||||
// Returns true when the command should end.
|
||||
bool DriveWithJoysticks::IsFinished() {
|
||||
return false;
|
||||
}
|
30
src/main/cpp/commands/Eject.cpp
Normal file
30
src/main/cpp/commands/Eject.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "commands/Eject.h"
|
||||
|
||||
Eject::Eject(Gatherer &gatherer) :
|
||||
m_gatherer(gatherer) {
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
SetName("Eject");
|
||||
AddRequirements(&m_gatherer);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
void Eject::Initialize() {
|
||||
m_gatherer.eject();
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void Eject::Execute() {}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
void Eject::End(bool interrupted) {
|
||||
m_gatherer.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
bool Eject::IsFinished() {
|
||||
return false;
|
||||
}
|
30
src/main/cpp/commands/Gather.cpp
Normal file
30
src/main/cpp/commands/Gather.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "commands/Gather.h"
|
||||
|
||||
Gather::Gather(Gatherer &gatherer) :
|
||||
m_gatherer(gatherer) {
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
SetName("Gather");
|
||||
AddRequirements(&m_gatherer);
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
void Gather::Initialize() {
|
||||
m_gatherer.gather();
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void Gather::Execute() {}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
void Gather::End(bool interrupted) {
|
||||
m_gatherer.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
bool Gather::IsFinished() {
|
||||
return false;
|
||||
}
|
35
src/main/cpp/commands/Shoot.cpp
Normal file
35
src/main/cpp/commands/Shoot.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "commands/Shoot.h"
|
||||
|
||||
#include <frc/Timer.h>
|
||||
|
||||
Shoot::Shoot(Gatherer &gatherer, Shooter &shooter) :
|
||||
m_gatherer(gatherer), m_shooter(shooter) {
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
SetName("Shoot");
|
||||
AddRequirements({&m_gatherer, &m_shooter});
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
void Shoot::Initialize() {
|
||||
m_start_time = frc::Timer::GetFPGATimestamp();
|
||||
}
|
||||
|
||||
// Called repeatedly when this Command is scheduled to run
|
||||
void Shoot::Execute() {
|
||||
bool full = frc::Timer::GetFPGATimestamp() - m_start_time > 1_s;
|
||||
m_gatherer.shoot(full);
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
void Shoot::End(bool interrupted) {
|
||||
m_gatherer.stop();
|
||||
}
|
||||
|
||||
// Returns true when the command should end.
|
||||
bool Shoot::IsFinished() {
|
||||
return false;
|
||||
}
|
112
src/main/cpp/subsystems/Chassis.cpp
Normal file
112
src/main/cpp/subsystems/Chassis.cpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "subsystems/Chassis.h"
|
||||
#include "Units.h"
|
||||
|
||||
#include <frc/kinematics/SwerveModuleState.h>
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <units/angle.h>
|
||||
|
||||
Chassis::Chassis() {
|
||||
// Implementation of subsystem constructor goes here.
|
||||
zero_pod_encoders();
|
||||
|
||||
configure_pod(m_lf_pod);
|
||||
configure_pod(m_rf_pod);
|
||||
configure_pod(m_lb_pod);
|
||||
configure_pod(m_rb_pod);
|
||||
}
|
||||
|
||||
void Chassis::zero_pod_encoders() {
|
||||
m_lf_pod.turn.SetSelectedSensorPosition(0);
|
||||
m_rf_pod.turn.SetSelectedSensorPosition(0);
|
||||
m_lb_pod.turn.SetSelectedSensorPosition(0);
|
||||
m_rb_pod.turn.SetSelectedSensorPosition(0);
|
||||
}
|
||||
|
||||
void Chassis::zero_gyro() {
|
||||
// m_gyro.ZeroYaw();
|
||||
}
|
||||
|
||||
void Chassis::drive(frc::ChassisSpeeds speeds) {
|
||||
auto module_states = m_kinematics.ToSwerveModuleStates(speeds);
|
||||
m_kinematics.DesaturateWheelSpeeds(&module_states, constants::chassis::MAX_SPEED);
|
||||
|
||||
auto lf_optimized = frc::SwerveModuleState::Optimize(
|
||||
module_states[0],
|
||||
get_pod_angle(m_lf_pod));
|
||||
auto rf_optimized = frc::SwerveModuleState::Optimize(
|
||||
module_states[1],
|
||||
get_pod_angle(m_rf_pod));
|
||||
auto lb_optimized = frc::SwerveModuleState::Optimize(
|
||||
module_states[2],
|
||||
get_pod_angle(m_lb_pod));
|
||||
auto rb_optimized = frc::SwerveModuleState::Optimize(
|
||||
module_states[3],
|
||||
get_pod_angle(m_rb_pod));
|
||||
|
||||
set_pod(m_lf_pod, lf_optimized);
|
||||
set_pod(m_rf_pod, rf_optimized);
|
||||
set_pod(m_lb_pod, lb_optimized);
|
||||
set_pod(m_rb_pod, rb_optimized);
|
||||
}
|
||||
|
||||
void Chassis::drive_field_relative(
|
||||
units::meters_per_second_t forward,
|
||||
units::meters_per_second_t left,
|
||||
units::radians_per_second_t theta) {
|
||||
auto speeds = frc::ChassisSpeeds::FromFieldRelativeSpeeds(
|
||||
forward,
|
||||
left,
|
||||
theta,
|
||||
// frc::Rotation2d(units::degree_t(-m_gyro.GetAngle()))
|
||||
frc::Rotation2d(units::degree_t(0))
|
||||
);
|
||||
|
||||
drive(speeds);
|
||||
}
|
||||
|
||||
void Chassis::configure_pod(Pod &pod) {
|
||||
pod.turn.ConfigSelectedFeedbackSensor(TalonSRXFeedbackDevice::CTRE_MagEncoder_Relative);
|
||||
pod.turn.SetSensorPhase(true);
|
||||
pod.turn.Config_kP(0, constants::chassis::TURN_P);
|
||||
pod.turn.Config_kI(0, constants::chassis::TURN_I);
|
||||
pod.turn.Config_kD(0, constants::chassis::TURN_D);
|
||||
|
||||
pod.drive.ConfigSupplyCurrentLimit({true, 15, 0, 0.01});
|
||||
}
|
||||
|
||||
void Chassis::set_pod(Pod &pod, frc::SwerveModuleState command) {
|
||||
// TODO: I can't remember if we waited for the angle target to be met before we
|
||||
// start to apply the drive velocity, look into that
|
||||
double drive_percent = command.speed / constants::chassis::MAX_SPEED;
|
||||
units::ctre_count_t counts =
|
||||
command.angle.Degrees() * constants::chassis::ROTATE_RATIO;
|
||||
|
||||
std::string pod_name;
|
||||
if(&pod == &m_lf_pod)
|
||||
pod_name = "lf_pod";
|
||||
if(&pod == &m_rf_pod)
|
||||
pod_name = "rf_pod";
|
||||
if(&pod == &m_lb_pod)
|
||||
pod_name = "lb_pod";
|
||||
if(&pod == &m_rb_pod)
|
||||
pod_name = "rb_pod";
|
||||
frc::SmartDashboard::PutNumber(pod_name + ".angle", command.angle.Degrees().value());
|
||||
frc::SmartDashboard::PutNumber(pod_name + ".mag", drive_percent);
|
||||
|
||||
if(abs(drive_percent) > constants::chassis::MIN_DRIVE_PERCENT)
|
||||
pod.turn.Set(ControlMode::Position, counts.value());
|
||||
pod.drive.Set(ControlMode::PercentOutput, drive_percent);
|
||||
pod.tmp = command.angle.Degrees().value();
|
||||
}
|
||||
|
||||
frc::Rotation2d Chassis::get_pod_angle(Pod &pod) {
|
||||
units::ctre_count_t counts{pod.turn.GetSelectedSensorPosition()};
|
||||
units::radian_t angle{counts / constants::chassis::ROTATE_RATIO};
|
||||
return frc::Rotation2d{units::degree_t{pod.tmp}};
|
||||
|
||||
//return frc::Rotation2d{angle};
|
||||
}
|
40
src/main/cpp/subsystems/Gatherer.cpp
Normal file
40
src/main/cpp/subsystems/Gatherer.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "subsystems/Gatherer.h"
|
||||
|
||||
Gatherer::Gatherer() {
|
||||
m_gather_low.SetInverted(false);
|
||||
m_gather_high_back.SetInverted(true);
|
||||
m_gather_high_front.SetInverted(false);
|
||||
}
|
||||
|
||||
// This method will be called once per scheduler run
|
||||
void Gatherer::Periodic() {}
|
||||
|
||||
void Gatherer::gather() {
|
||||
m_gather_low.Set(ControlMode::PercentOutput, 1.0);
|
||||
m_gather_high_back.Set(ControlMode::PercentOutput, -0.6);
|
||||
m_gather_high_front.Set(ControlMode::PercentOutput, 0.6);
|
||||
}
|
||||
|
||||
void Gatherer::eject() {
|
||||
m_gather_low.Set(ControlMode::PercentOutput, -1.0);
|
||||
m_gather_high_back.Set(ControlMode::PercentOutput, -0.6);
|
||||
m_gather_high_front.Set(ControlMode::PercentOutput, -0.6);
|
||||
}
|
||||
|
||||
void Gatherer::shoot(bool full) {
|
||||
if(full)
|
||||
m_gather_low.Set(ControlMode::PercentOutput, 1.0);
|
||||
|
||||
m_gather_high_back.Set(ControlMode::PercentOutput, 0.5);
|
||||
m_gather_high_front.Set(ControlMode::PercentOutput, 1.0);
|
||||
}
|
||||
|
||||
void Gatherer::stop() {
|
||||
m_gather_low.Set(ControlMode::PercentOutput, 0.0);
|
||||
m_gather_high_back.Set(ControlMode::PercentOutput, 0.0);
|
||||
m_gather_high_front.Set(ControlMode::PercentOutput, 0.0);
|
||||
}
|
10
src/main/cpp/subsystems/Shear.cpp
Normal file
10
src/main/cpp/subsystems/Shear.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "subsystems/Shear.h"
|
||||
|
||||
Shear::Shear() = default;
|
||||
|
||||
// This method will be called once per scheduler run
|
||||
void Shear::Periodic() {}
|
35
src/main/cpp/subsystems/Shooter.cpp
Normal file
35
src/main/cpp/subsystems/Shooter.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "subsystems/Shooter.h"
|
||||
#include "Units.h"
|
||||
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
|
||||
Shooter::Shooter() {
|
||||
m_shooter.SetInverted(false);
|
||||
|
||||
/*
|
||||
m_shooter.ConfigSelectedFeedbackSensor(FeedbackDevice::CTRE_MagEncoder_Relative, 0);
|
||||
m_shooter.SetSensorPhase(true);
|
||||
m_shooter.Config_kP(0, constants::shooter::P);
|
||||
m_shooter.Config_kI(0, constants::shooter::I);
|
||||
m_shooter.Config_kD(0, constants::shooter::D);
|
||||
*/
|
||||
}
|
||||
|
||||
void Shooter::set(units::revolutions_per_minute_t rpm) {
|
||||
rpm = rpm * constants::shooter::RATIO;
|
||||
m_shooter.Set(ControlMode::PercentOutput, rpm / constants::shooter::MAX_RPM);
|
||||
frc::SmartDashboard::PutNumber("rpm", rpm / constants::shooter::MAX_RPM);
|
||||
}
|
||||
|
||||
bool Shooter::at_speed() {
|
||||
units::ctre_count_t counts{m_shooter.GetClosedLoopError()};
|
||||
units::revolutions_per_minute_t error{counts / 1_min / constants::shooter::RATIO};
|
||||
return error < constants::shooter::SHOOTER_TARGET_ERROR;
|
||||
}
|
||||
|
||||
// This method will be called once per scheduler run
|
||||
void Shooter::Periodic() {}
|
4
src/main/deploy/example.txt
Normal file
4
src/main/deploy/example.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
Files placed in this directory will be deployed to the RoboRIO into the
|
||||
'deploy' directory in the home folder. Use the 'frc::filesystem::GetDeployDirectory'
|
||||
function from the 'frc/Filesystem.h' header to get a proper path relative to the deploy
|
||||
directory.
|
89
src/main/include/Constants.h
Normal file
89
src/main/include/Constants.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
#pragma once
|
||||
|
||||
#include "Units.h"
|
||||
|
||||
#include <units/angular_velocity.h>
|
||||
#include <units/length.h>
|
||||
#include <units/velocity.h>
|
||||
|
||||
namespace constants {
|
||||
namespace can_ids {
|
||||
const int LF_DRIVE = 1;
|
||||
const int LF_TURN = 2;
|
||||
const int RF_DRIVE = 3;
|
||||
const int RF_TURN = 4;
|
||||
const int LB_DRIVE = 5;
|
||||
const int LB_TURN = 6;
|
||||
const int RB_DRIVE = 7;
|
||||
const int RB_TURN = 8;
|
||||
|
||||
const int SHOOTER = 10;
|
||||
|
||||
const int GATHER_LOW = 20;
|
||||
const int GATHER_HIGH_BACK = 21;
|
||||
const int GATHER_HIGH_FRONT = 22;
|
||||
|
||||
const int SHEAR_LEFT = 30;
|
||||
const int SHEAR_RIGHT = 31;
|
||||
} // End namespace can_ids
|
||||
|
||||
namespace dio {
|
||||
const int LF_POD_ZERO = 0;
|
||||
const int RF_POD_ZERO = 1;
|
||||
const int LB_POD_ZERO = 2;
|
||||
const int RB_POD_ZERO = 3;
|
||||
const int GATHER_LOW = 4;
|
||||
const int GATHER_HIGH = 5;
|
||||
} // End namespace dio
|
||||
|
||||
namespace chassis {
|
||||
// drive full speed meters
|
||||
const auto MAX_SPEED = 30_fps;
|
||||
// double MAX_SPEED = 1.0;
|
||||
|
||||
// % of max speed that the turn motors will start to move
|
||||
// Prevents abrupt angle changes when basically zero velocity is being commanded
|
||||
const double MIN_DRIVE_PERCENT = 0.05;
|
||||
|
||||
// Gear ratio 72:44
|
||||
const auto ROTATE_RATIO = 72_tr / 44_tr;
|
||||
|
||||
const double TURN_P = 1.0;
|
||||
const double TURN_I = 0.0;
|
||||
const double TURN_D = 0.0;
|
||||
|
||||
const auto SWERVE_X_FROM_CENTER = 11_in;
|
||||
const auto SWERVE_Y_FROM_CENTER = 12.5_in;
|
||||
} // End namespace chassis
|
||||
|
||||
namespace shear {
|
||||
const double SHEAR_P = 1.0;
|
||||
const double SHEAR_I = 0.0;
|
||||
const double SHEAR_D = 0.0;
|
||||
|
||||
// Gearbox ratio 100:1
|
||||
const auto RATIO = 100_tr / 1_tr;
|
||||
|
||||
const auto SHEAR_TOLERANCE = 0.1_deg;
|
||||
} // End namespace shear
|
||||
|
||||
namespace joysticks {
|
||||
const double JOY_DRIVE_EXPO = 5.0;
|
||||
const double JOY_TURN_EXPO = 5.0;
|
||||
} // End namespace joysticks
|
||||
|
||||
namespace shooter {
|
||||
const auto RATIO = 1_tr / 1_tr;
|
||||
|
||||
const auto MAX_RPM = 1.0_rpm;
|
||||
const auto SHOOTER_TARGET_ERROR = 0.1_rpm;
|
||||
|
||||
const double P = 1.0;
|
||||
const double I = 0.0;
|
||||
const double D = 0.0;
|
||||
|
||||
const auto LOW = 0.4_rpm;
|
||||
const auto MED = 2_rpm / 3;
|
||||
const auto HIGH = 1.0_rpm;
|
||||
} // End namespace shooter
|
||||
} // End namespace Constants
|
32
src/main/include/Robot.h
Normal file
32
src/main/include/Robot.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc2/command/Command.h>
|
||||
|
||||
#include "RobotContainer.h"
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override;
|
||||
void RobotPeriodic() override;
|
||||
void DisabledInit() override;
|
||||
void DisabledPeriodic() override;
|
||||
void AutonomousInit() override;
|
||||
void AutonomousPeriodic() override;
|
||||
void TeleopInit() override;
|
||||
void TeleopPeriodic() override;
|
||||
void TestPeriodic() override;
|
||||
void SimulationInit() override;
|
||||
void SimulationPeriodic() override;
|
||||
|
||||
private:
|
||||
// Have it null by default so that if testing teleop it
|
||||
// doesn't have undefined behavior and potentially crash.
|
||||
frc2::Command* m_autonomous_command = nullptr;
|
||||
|
||||
RobotContainer m_container;
|
||||
};
|
46
src/main/include/RobotContainer.h
Normal file
46
src/main/include/RobotContainer.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc/PowerDistribution.h>
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc2/command/Command.h>
|
||||
#include <frc2/command/InstantCommand.h>
|
||||
|
||||
#include "commands/DriveWithJoysticks.h"
|
||||
#include "subsystems/Chassis.h"
|
||||
#include "subsystems/Shooter.h"
|
||||
#include "subsystems/Gatherer.h"
|
||||
#include "subsystems/Shear.h"
|
||||
|
||||
/**
|
||||
* This class is where the bulk of the robot should be declared. Since
|
||||
* Command-based is a "declarative" paradigm, very little robot logic should
|
||||
* actually be handled in the {@link Robot} periodic methods (other than the
|
||||
* scheduler calls). Instead, the structure of the robot (including subsystems,
|
||||
* commands, and button mappings) should be declared here.
|
||||
*/
|
||||
class RobotContainer {
|
||||
public:
|
||||
RobotContainer();
|
||||
|
||||
frc2::Command* get_autonomous_command();
|
||||
|
||||
private:
|
||||
// The robot's subsystems and commands are defined here...
|
||||
frc::PowerDistribution m_pdp{};
|
||||
|
||||
frc::Joystick m_driver{0};
|
||||
frc::Joystick m_manip{1};
|
||||
|
||||
Chassis m_chassis;
|
||||
Shooter m_shooter;
|
||||
Gatherer m_gatherer;
|
||||
Shear m_shear;
|
||||
|
||||
DriveWithJoysticks m_autonomous_command;
|
||||
|
||||
void map_buttons();
|
||||
};
|
10
src/main/include/Units.h
Normal file
10
src/main/include/Units.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <units/angle.h>
|
||||
|
||||
namespace units {
|
||||
|
||||
UNIT_ADD(encoder_counts, ctre_count, ctre_counts, ctre_cnt, units::unit<std::ratio<1, 4096>, units::turn>)
|
||||
|
||||
using namespace encoder_counts;
|
||||
} // End namespace units
|
17
src/main/include/Utils.h
Normal file
17
src/main/include/Utils.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace utils {
|
||||
|
||||
double joy_expo(double in, double exp) {
|
||||
double out;
|
||||
|
||||
out = std::exp(std::abs(in) * exp) - 1;
|
||||
out = out / (std::exp(exp) - 1);
|
||||
out = std::copysign(out, in);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
} // End namespace utils
|
36
src/main/include/commands/DriveWithJoysticks.h
Normal file
36
src/main/include/commands/DriveWithJoysticks.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <frc/Joystick.h>
|
||||
|
||||
#include "subsystems/Chassis.h"
|
||||
|
||||
/**
|
||||
* An example command that uses an example subsystem.
|
||||
*
|
||||
* <p>Note that this extends CommandHelper, rather extending CommandBase
|
||||
* directly; this is crucially important, or else the decorator functions in
|
||||
* Command will *not* work!
|
||||
*/
|
||||
class DriveWithJoysticks
|
||||
: public frc2::CommandHelper<frc2::CommandBase, DriveWithJoysticks> {
|
||||
public:
|
||||
DriveWithJoysticks(Chassis &chassis, frc::Joystick &joystick);
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
void Execute() override;
|
||||
|
||||
void End(bool interrupted) override;
|
||||
|
||||
bool IsFinished() override;
|
||||
|
||||
private:
|
||||
Chassis& m_chassis;
|
||||
frc::Joystick& m_joystick;
|
||||
};
|
34
src/main/include/commands/Eject.h
Normal file
34
src/main/include/commands/Eject.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
|
||||
#include "subsystems/Gatherer.h"
|
||||
|
||||
/**
|
||||
* An example command.
|
||||
*
|
||||
* <p>Note that this extends CommandHelper, rather extending CommandBase
|
||||
* directly; this is crucially important, or else the decorator functions in
|
||||
* Command will *not* work!
|
||||
*/
|
||||
class Eject
|
||||
: public frc2::CommandHelper<frc2::CommandBase, Eject> {
|
||||
public:
|
||||
Eject(Gatherer &gatherer);
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
void Execute() override;
|
||||
|
||||
void End(bool interrupted) override;
|
||||
|
||||
bool IsFinished() override;
|
||||
|
||||
private:
|
||||
Gatherer &m_gatherer;
|
||||
};
|
34
src/main/include/commands/Gather.h
Normal file
34
src/main/include/commands/Gather.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
|
||||
#include "subsystems/Gatherer.h"
|
||||
|
||||
/**
|
||||
* An example command.
|
||||
*
|
||||
* <p>Note that this extends CommandHelper, rather extending CommandBase
|
||||
* directly; this is crucially important, or else the decorator functions in
|
||||
* Command will *not* work!
|
||||
*/
|
||||
class Gather
|
||||
: public frc2::CommandHelper<frc2::CommandBase, Gather> {
|
||||
public:
|
||||
Gather(Gatherer &gatherer);
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
void Execute() override;
|
||||
|
||||
void End(bool interrupted) override;
|
||||
|
||||
bool IsFinished() override;
|
||||
|
||||
private:
|
||||
Gatherer &m_gatherer;
|
||||
};
|
39
src/main/include/commands/Shoot.h
Normal file
39
src/main/include/commands/Shoot.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/CommandBase.h>
|
||||
#include <frc2/command/CommandHelper.h>
|
||||
#include <units/time.h>
|
||||
|
||||
#include "subsystems/Gatherer.h"
|
||||
#include "subsystems/Shooter.h"
|
||||
|
||||
/**
|
||||
* An example command.
|
||||
*
|
||||
* <p>Note that this extends CommandHelper, rather extending CommandBase
|
||||
* directly; this is crucially important, or else the decorator functions in
|
||||
* Command will *not* work!
|
||||
*/
|
||||
class Shoot
|
||||
: public frc2::CommandHelper<frc2::CommandBase, Shoot> {
|
||||
public:
|
||||
Shoot(Gatherer &gatherer, Shooter &shooter);
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
void Execute() override;
|
||||
|
||||
void End(bool interrupted) override;
|
||||
|
||||
bool IsFinished() override;
|
||||
|
||||
private:
|
||||
Gatherer &m_gatherer;
|
||||
Shooter &m_shooter;
|
||||
|
||||
units::second_t m_start_time;
|
||||
};
|
73
src/main/include/subsystems/Chassis.h
Normal file
73
src/main/include/subsystems/Chassis.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Constants.h"
|
||||
|
||||
#include "AHRS.h"
|
||||
#include <ctre/Phoenix.h>
|
||||
#include <frc/geometry/Rotation2d.h>
|
||||
#include <frc/geometry/Translation2d.h>
|
||||
#include <frc/kinematics/SwerveDriveKinematics.h>
|
||||
#include <frc/kinematics/SwerveModuleState.h>
|
||||
#include <frc2/command/SubsystemBase.h>
|
||||
|
||||
|
||||
class Chassis : public frc2::SubsystemBase {
|
||||
struct Pod {
|
||||
TalonSRX turn;
|
||||
TalonFX drive;
|
||||
double tmp;
|
||||
};
|
||||
|
||||
public:
|
||||
Chassis();
|
||||
|
||||
void zero_pod_encoders();
|
||||
void zero_gyro();
|
||||
|
||||
void drive(frc::ChassisSpeeds speeds);
|
||||
void drive_field_relative(
|
||||
units::meters_per_second_t forward,
|
||||
units::meters_per_second_t left,
|
||||
units::radians_per_second_t theta);
|
||||
|
||||
private:
|
||||
void configure_pod(Pod &pod);
|
||||
void set_pod(Pod &pod, frc::SwerveModuleState command);
|
||||
frc::Rotation2d get_pod_angle(Pod &pod);
|
||||
|
||||
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
|
||||
Pod m_lf_pod{{constants::can_ids::LF_TURN}, {constants::can_ids::LF_DRIVE}};
|
||||
Pod m_rf_pod{{constants::can_ids::RF_TURN}, {constants::can_ids::RF_DRIVE}};
|
||||
Pod m_lb_pod{{constants::can_ids::LB_TURN}, {constants::can_ids::LB_DRIVE}};
|
||||
Pod m_rb_pod{{constants::can_ids::RB_TURN}, {constants::can_ids::RB_DRIVE}};
|
||||
|
||||
// AHRS m_gyro{frc::SPI::Port::kMXP};
|
||||
|
||||
const frc::Translation2d LF_POD_LOCATION{
|
||||
constants::chassis::SWERVE_X_FROM_CENTER,
|
||||
constants::chassis::SWERVE_Y_FROM_CENTER};
|
||||
const frc::Translation2d RF_POD_LOCATION{
|
||||
constants::chassis::SWERVE_X_FROM_CENTER,
|
||||
-constants::chassis::SWERVE_Y_FROM_CENTER};
|
||||
const frc::Translation2d LB_POD_LOCATION{
|
||||
-constants::chassis::SWERVE_X_FROM_CENTER,
|
||||
constants::chassis::SWERVE_Y_FROM_CENTER};
|
||||
const frc::Translation2d RB_POD_LOCATION{
|
||||
-constants::chassis::SWERVE_X_FROM_CENTER,
|
||||
-constants::chassis::SWERVE_Y_FROM_CENTER};
|
||||
|
||||
frc::SwerveDriveKinematics<4> m_kinematics{
|
||||
LF_POD_LOCATION,
|
||||
RF_POD_LOCATION,
|
||||
LB_POD_LOCATION,
|
||||
RB_POD_LOCATION
|
||||
};
|
||||
};
|
38
src/main/include/subsystems/Gatherer.h
Normal file
38
src/main/include/subsystems/Gatherer.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Constants.h"
|
||||
|
||||
#include <frc/DigitalInput.h>
|
||||
#include <frc2/command/SubsystemBase.h>
|
||||
#include <ctre/Phoenix.h>
|
||||
|
||||
class Gatherer : public frc2::SubsystemBase {
|
||||
public:
|
||||
Gatherer();
|
||||
|
||||
void gather();
|
||||
void eject();
|
||||
void shoot(bool full);
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Will be called periodically whenever the CommandScheduler runs.
|
||||
*/
|
||||
void Periodic() override;
|
||||
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
TalonSRX m_gather_low{constants::can_ids::GATHER_LOW};
|
||||
TalonSRX m_gather_high_back{constants::can_ids::GATHER_HIGH_BACK};
|
||||
TalonSRX m_gather_high_front{constants::can_ids::GATHER_HIGH_FRONT};
|
||||
|
||||
/*
|
||||
frc::DigitalInput m_low_sensor{constants::dio::GATHER_LOW};
|
||||
frc::DigitalInput m_high_sensor{constants::dio::GATHER_HIGH};
|
||||
*/
|
||||
};
|
21
src/main/include/subsystems/Shear.h
Normal file
21
src/main/include/subsystems/Shear.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc2/command/SubsystemBase.h>
|
||||
|
||||
class Shear : public frc2::SubsystemBase {
|
||||
public:
|
||||
Shear();
|
||||
|
||||
/**
|
||||
* Will be called periodically whenever the CommandScheduler runs.
|
||||
*/
|
||||
void Periodic() override;
|
||||
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
};
|
30
src/main/include/subsystems/Shooter.h
Normal file
30
src/main/include/subsystems/Shooter.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright (c) FIRST and other WPILib contributors.
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Constants.h"
|
||||
|
||||
#include <ctre/Phoenix.h>
|
||||
#include <frc2/command/SubsystemBase.h>
|
||||
#include <units/angular_velocity.h>
|
||||
|
||||
class Shooter : public frc2::SubsystemBase {
|
||||
public:
|
||||
Shooter();
|
||||
|
||||
void set(units::revolutions_per_minute_t rpm);
|
||||
|
||||
bool at_speed();
|
||||
|
||||
/**
|
||||
* Will be called periodically whenever the CommandScheduler runs.
|
||||
*/
|
||||
void Periodic() override;
|
||||
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
TalonSRX m_shooter{constants::can_ids::SHOOTER};
|
||||
};
|
10
src/test/cpp/main.cpp
Normal file
10
src/test/cpp/main.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <hal/HAL.h>
|
||||
|
||||
#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;
|
||||
}
|
257
vendordeps/Phoenix.json
Normal file
257
vendordeps/Phoenix.json
Normal file
|
@ -0,0 +1,257 @@
|
|||
{
|
||||
"fileName": "Phoenix.json",
|
||||
"name": "CTRE-Phoenix",
|
||||
"version": "5.21.2",
|
||||
"frcYear": 2022,
|
||||
"uuid": "ab676553-b602-441f-a38d-f1296eff6537",
|
||||
"mavenUrls": [
|
||||
"https://maven.ctr-electronics.com/release/"
|
||||
],
|
||||
"jsonUrl": "https://maven.ctr-electronics.com/release/com/ctre/phoenix/Phoenix-frc2022-latest.json",
|
||||
"javaDependencies": [
|
||||
{
|
||||
"groupId": "com.ctre.phoenix",
|
||||
"artifactId": "api-java",
|
||||
"version": "5.21.2"
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix",
|
||||
"artifactId": "wpiapi-java",
|
||||
"version": "5.21.2"
|
||||
}
|
||||
],
|
||||
"jniDependencies": [
|
||||
{
|
||||
"groupId": "com.ctre.phoenix",
|
||||
"artifactId": "cci",
|
||||
"version": "5.21.2",
|
||||
"isJar": false,
|
||||
"skipInvalidPlatforms": true,
|
||||
"validPlatforms": [
|
||||
"linuxathena"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "cci-sim",
|
||||
"version": "5.21.2",
|
||||
"isJar": false,
|
||||
"skipInvalidPlatforms": true,
|
||||
"validPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simTalonSRX",
|
||||
"version": "5.21.2",
|
||||
"isJar": false,
|
||||
"skipInvalidPlatforms": true,
|
||||
"validPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simTalonFX",
|
||||
"version": "5.21.2",
|
||||
"isJar": false,
|
||||
"skipInvalidPlatforms": true,
|
||||
"validPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simVictorSPX",
|
||||
"version": "5.21.2",
|
||||
"isJar": false,
|
||||
"skipInvalidPlatforms": true,
|
||||
"validPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simPigeonIMU",
|
||||
"version": "5.21.2",
|
||||
"isJar": false,
|
||||
"skipInvalidPlatforms": true,
|
||||
"validPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simCANCoder",
|
||||
"version": "5.21.2",
|
||||
"isJar": false,
|
||||
"skipInvalidPlatforms": true,
|
||||
"validPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
}
|
||||
],
|
||||
"cppDependencies": [
|
||||
{
|
||||
"groupId": "com.ctre.phoenix",
|
||||
"artifactId": "wpiapi-cpp",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_Phoenix_WPI",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"linuxathena"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix",
|
||||
"artifactId": "api-cpp",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_Phoenix",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"linuxathena"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix",
|
||||
"artifactId": "cci",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_PhoenixCCI",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"linuxathena"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "wpiapi-cpp-sim",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_Phoenix_WPISim",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "api-cpp-sim",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_PhoenixSim",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "cci-sim",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_PhoenixCCISim",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simTalonSRX",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_SimTalonSRX",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simTalonFX",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_SimTalonFX",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simVictorSPX",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_SimVictorSPX",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simPigeonIMU",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_SimPigeonIMU",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupId": "com.ctre.phoenix.sim",
|
||||
"artifactId": "simCANCoder",
|
||||
"version": "5.21.2",
|
||||
"libName": "CTRE_SimCANCoder",
|
||||
"headerClassifier": "headers",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"windowsx86-64",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
37
vendordeps/WPILibNewCommands.json
Normal file
37
vendordeps/WPILibNewCommands.json
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"fileName": "WPILibNewCommands.json",
|
||||
"name": "WPILib-New-Commands",
|
||||
"version": "1.0.0",
|
||||
"uuid": "111e20f7-815e-48f8-9dd6-e675ce75b266",
|
||||
"mavenUrls": [],
|
||||
"jsonUrl": "",
|
||||
"javaDependencies": [
|
||||
{
|
||||
"groupId": "edu.wpi.first.wpilibNewCommands",
|
||||
"artifactId": "wpilibNewCommands-java",
|
||||
"version": "wpilib"
|
||||
}
|
||||
],
|
||||
"jniDependencies": [],
|
||||
"cppDependencies": [
|
||||
{
|
||||
"groupId": "edu.wpi.first.wpilibNewCommands",
|
||||
"artifactId": "wpilibNewCommands-cpp",
|
||||
"version": "wpilib",
|
||||
"libName": "wpilibNewCommands",
|
||||
"headerClassifier": "headers",
|
||||
"sourcesClassifier": "sources",
|
||||
"sharedLibrary": true,
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"linuxathena",
|
||||
"linuxraspbian",
|
||||
"linuxaarch64bionic",
|
||||
"windowsx86-64",
|
||||
"windowsx86",
|
||||
"linuxx86-64",
|
||||
"osxx86-64"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
35
vendordeps/navx_frc.json
Normal file
35
vendordeps/navx_frc.json
Normal file
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"fileName": "navx_frc.json",
|
||||
"name": "KauaiLabs_navX_FRC",
|
||||
"version": "4.0.442",
|
||||
"uuid": "cb311d09-36e9-4143-a032-55bb2b94443b",
|
||||
"mavenUrls": [
|
||||
"https://repo1.maven.org/maven2/"
|
||||
],
|
||||
"jsonUrl": "https://www.kauailabs.com/dist/frc/2022/navx_frc.json",
|
||||
"javaDependencies": [
|
||||
{
|
||||
"groupId": "com.kauailabs.navx.frc",
|
||||
"artifactId": "navx-java",
|
||||
"version": "4.0.442"
|
||||
}
|
||||
],
|
||||
"jniDependencies": [],
|
||||
"cppDependencies": [
|
||||
{
|
||||
"groupId": "com.kauailabs.navx.frc",
|
||||
"artifactId": "navx-cpp",
|
||||
"version": "4.0.442",
|
||||
"headerClassifier": "headers",
|
||||
"sourcesClassifier": "sources",
|
||||
"sharedLibrary": false,
|
||||
"libName": "navx_frc",
|
||||
"skipInvalidPlatforms": true,
|
||||
"binaryPlatforms": [
|
||||
"linuxathena",
|
||||
"linuxraspbian",
|
||||
"windowsx86-64"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue