Skip to content

Commit f2a72f0

Browse files
Add swerve drive project with MAXSwerve modules (REVrobotics#1)
Co-authored-by: Trevor Van Doren <[email protected]>
1 parent 7b248f1 commit f2a72f0

21 files changed

+1550
-1
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": "2023Beta",
5+
"teamNumber": 2714
6+
}

README.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
# MAXSwerve-Java-Template
1+
# MAXSwerve Java Template
2+
3+
A template project for an FRC swerve drivetrain that uses REV MAXSwerve Modules.
4+
5+
Note that this is meant to be used with a drivetrain composed of four MAXSwerve Modules, each configured with two SPARKS MAX, a NEO as the driving motor, a NEO 550 as the turning motor, and a REV Through Bore Encoder as the absolute turning encoder.
6+
7+
## Prerequisites
8+
9+
* SPARK MAX Firmware v1.6.0 - Adds features that are required for swerve
10+
* REVLib v2023.1.0 - Includes APIs for the new firmware features
11+
12+
## Configuration
13+
14+
It is possible that this project will not work for your robot right out of the box. Various things like the CAN IDs, PIDF gains, chassis configuration, etc. must be determined for your own robot!
15+
16+
These values can be adjusted in the `Constants.java` file.

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

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
plugins {
2+
id "java"
3+
id "edu.wpi.first.GradleRIO" version "2023.1.1-beta-4"
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 5.
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 'org.junit.jupiter:junit-jupiter-api:5.4.2'
69+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.2'
70+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
71+
}
72+
73+
test {
74+
useJUnitPlatform()
75+
systemProperty 'junit.jupiter.extensions.autodetection.enabled', 'true'
76+
}
77+
78+
// Simulation configuration (e.g. environment variables).
79+
wpi.sim.addGui().defaultEnabled = true
80+
wpi.sim.addDriverstation()
81+
82+
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
83+
// in order to make them all available at runtime. Also adding the manifest so WPILib
84+
// knows where to look for our Robot Class.
85+
jar {
86+
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
87+
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
88+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
89+
}
90+
91+
// Configure jar and deploy tasks
92+
deployArtifact.jarTask = jar
93+
wpi.java.configureExecutableTasks(jar)
94+
wpi.java.configureTestTasks(test)
95+
96+
// Configure string concat to always inline compile
97+
tasks.withType(JavaCompile) {
98+
options.compilerArgs.add '-XDstringConcat=inline'
99+
}

gradle/wrapper/gradle-wrapper.jar

59.3 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.5.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=permwrapper/dists

0 commit comments

Comments
 (0)