Skip to content

Commit 2ecdd5a

Browse files
authored
Merge pull request #159 from SouthwestRoboticsProgramming/test_bench
Test bench
2 parents ad2e096 + 02c5211 commit 2ecdd5a

38 files changed

+2226
-4
lines changed

RobotLib/src/main/java/com/swrobotics/lib/motor/FeedbackMotor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.swrobotics.lib.motor;
22

33
import com.swrobotics.lib.encoder.Encoder;
4-
import com.swrobotics.lib.net.NTDouble;
4+
import com.swrobotics.lib.net.NTEntry;
55
import com.swrobotics.mathlib.Angle;
66

77
public interface FeedbackMotor extends Motor {
@@ -42,7 +42,7 @@ default void setPID(double kP, double kI, double kD) {
4242
setF(0);
4343
}
4444

45-
default void setPID(NTDouble kP, NTDouble kI, NTDouble kD) {
45+
default void setPID(NTEntry<Double> kP, NTEntry<Double> kI, NTEntry<Double> kD) {
4646
kP.nowAndOnChange(() -> setP(kP.get()));
4747
kI.nowAndOnChange(() -> setI(kI.get()));
4848
kD.nowAndOnChange(() -> setD(kD.get()));
@@ -56,7 +56,7 @@ default void setPIDF(double kP, double kI, double kD, double kF) {
5656
setF(kF);
5757
}
5858

59-
default void setPIDF(NTDouble kP, NTDouble kI, NTDouble kD, NTDouble kF) {
59+
default void setPIDF(NTEntry<Double> kP, NTEntry<Double> kI, NTEntry<Double> kD, NTEntry<Double> kF) {
6060
setPID(kP, kI, kD);
6161
kF.nowAndOnChange(() -> setF(kF.get()));
6262
}

RobotLib/src/main/java/com/swrobotics/lib/motor/rev/SparkMaxMotor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ public Encoder getAbsoluteEncoder() {
144144
}
145145

146146
/**
147-
* Enables feedback using a relative encoder connected to the encoder port.
147+
* Enables feedback using a relative encoder connected to the encoder port,
148+
* or the data port if in brushed mode.
148149
*
149150
* @param type type of the encoder connected
150151
* @param ticksPerRotation number of ticks per encoder rotation

TestBench/.gitignore

Lines changed: 162 additions & 0 deletions
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
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"robotWidth": 0.83,
3+
"robotLength": 0.83,
4+
"holonomicMode": true,
5+
"generateJSON": false,
6+
"generateCSV": false
7+
}

TestBench/build.gradle

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
plugins {
2+
id "java"
3+
id "edu.wpi.first.GradleRIO" version "2023.3.2"
4+
}
5+
6+
sourceCompatibility = JavaVersion.VERSION_11
7+
targetCompatibility = JavaVersion.VERSION_11
8+
9+
compileJava {
10+
sourceCompatibility = '11'
11+
targetCompatibility = '11'
12+
}
13+
14+
def ROBOT_MAIN_CLASS = "com.swrobotics.robot.Main"
15+
16+
// Define my targets (RoboRIO) and artifacts (deployable files)
17+
// This is added by GradleRIO's backing project DeployUtils.
18+
deploy {
19+
targets {
20+
roborio(getTargetTypeClass('RoboRIO')) {
21+
// Team number is loaded either from the .wpilib/wpilib_preferences.json
22+
// or from command line. If not found an exception will be thrown.
23+
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
24+
// want to store a team number in this file.
25+
team = project.frc.getTeamNumber()
26+
debug = project.frc.getDebugOrDefault(false)
27+
28+
artifacts {
29+
// First part is artifact name, 2nd is artifact type
30+
// getTargetTypeClass is a shortcut to get the class type using a string
31+
32+
frcJava(getArtifactTypeClass('FRCJavaArtifact')) {
33+
}
34+
35+
// Static files artifact
36+
frcStaticFileDeploy(getArtifactTypeClass('FileTreeArtifact')) {
37+
files = project.fileTree('src/main/deploy')
38+
directory = '/home/lvuser/deploy'
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
def deployArtifact = deploy.targets.roborio.artifacts.frcJava
46+
47+
// Set to true to use debug for JNI.
48+
wpi.java.debugJni = false
49+
50+
// Set this to true to enable desktop support.
51+
def includeDesktopSupport = true
52+
53+
test {
54+
useJUnit()
55+
}
56+
57+
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
58+
// Also defines JUnit 4.
59+
dependencies {
60+
implementation project(':Messenger:MessengerClient')
61+
implementation project(':TaskManager:TaskManager-FileSystem')
62+
implementation project(':Profiler')
63+
implementation project(':MathLib')
64+
implementation project(':RobotLib')
65+
66+
implementation 'com.google.code.gson:gson:2.9.0'
67+
68+
implementation wpi.java.deps.wpilib()
69+
implementation wpi.java.vendor.java()
70+
71+
roborioDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.roborio)
72+
roborioDebug wpi.java.vendor.jniDebug(wpi.platforms.roborio)
73+
74+
roborioRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.roborio)
75+
roborioRelease wpi.java.vendor.jniRelease(wpi.platforms.roborio)
76+
77+
nativeDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.desktop)
78+
nativeDebug wpi.java.vendor.jniDebug(wpi.platforms.desktop)
79+
simulationDebug wpi.sim.enableDebug()
80+
81+
nativeRelease wpi.java.deps.wpilibJniRelease(wpi.platforms.desktop)
82+
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
83+
simulationRelease wpi.sim.enableRelease()
84+
85+
testImplementation 'junit:junit:4.13.1'
86+
testImplementation 'org.mockito:mockito-core:2.+'
87+
}
88+
89+
// Simulation configuration (e.g. environment variables).
90+
wpi.sim.addGui().defaultEnabled = true
91+
wpi.sim.addDriverstation()
92+
93+
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
94+
// in order to make them all available at runtime. Also adding the manifest so WPILib
95+
// knows where to look for our Robot Class.
96+
jar {
97+
dependsOn ':Messenger:MessengerClient:jar'
98+
dependsOn ':TaskManager:TaskManager-FileSystem:jar'
99+
dependsOn ':Profiler:jar'
100+
dependsOn ':MathLib:jar'
101+
dependsOn ':RobotLib:jar'
102+
103+
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
104+
manifest edu.wpi.first.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
105+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
106+
}
107+
108+
// Configure jar and deploy tasks
109+
deployArtifact.jarTask = jar
110+
wpi.java.configureExecutableTasks(jar)
111+
wpi.java.configureTestTasks(test)
637 KB
Loading
Lines changed: 3 additions & 0 deletions
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.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"waypoints": [
3+
{
4+
"anchorPoint": {
5+
"x": 2.9260858521717044,
6+
"y": 4.8874039628421135
7+
},
8+
"prevControl": null,
9+
"nextControl": {
10+
"x": 6.369990090640911,
11+
"y": 4.8874039628421135
12+
},
13+
"holonomicAngle": 0.0,
14+
"isReversal": false,
15+
"velOverride": null,
16+
"isLocked": false,
17+
"isStopPoint": false,
18+
"stopEvent": {
19+
"names": [],
20+
"executionBehavior": "parallel",
21+
"waitBehavior": "none",
22+
"waitTime": 0
23+
}
24+
},
25+
{
26+
"anchorPoint": {
27+
"x": 6.25,
28+
"y": 2.66
29+
},
30+
"prevControl": {
31+
"x": 6.25,
32+
"y": 4.420174972855124
33+
},
34+
"nextControl": null,
35+
"holonomicAngle": 0.0,
36+
"isReversal": false,
37+
"velOverride": null,
38+
"isLocked": false,
39+
"isStopPoint": false,
40+
"stopEvent": {
41+
"names": [
42+
"BALANCE"
43+
],
44+
"executionBehavior": "parallel",
45+
"waitBehavior": "none",
46+
"waitTime": 0
47+
}
48+
}
49+
],
50+
"markers": []
51+
}

0 commit comments

Comments
 (0)