Skip to content

Commit db458c7

Browse files
authored
Merge branch 'master' into deprecate-cached-spark-max
2 parents 1b503cc + fc8c870 commit db458c7

5 files changed

Lines changed: 37 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
release:
10+
name: Release Tag
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- name: Create Release
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
tag: ${{ github.ref_name }}
19+
run: |
20+
gh release create "$tag" --repo="$GITHUB_REPOSITORY" --title="$tag" --generate-notes

src/main/java/org/carlmontrobotics/lib199/Mocks.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public final class Mocks {
2424
private static final List<WeakReference<Object>> MOCKS = Collections.synchronizedList(new ArrayList<>());
2525
private static final Predicate<WeakReference<?>> IS_REFERENCE_CLEARED = reference -> reference.get() == null;
2626
private static final Consumer<WeakReference<Object>> CLEAR_INVOCATIONS_ON_REFERENCED_MOCK = reference -> Mockito.clearInvocations(reference.get());
27-
private static final Predicate<WeakReference<Object>> CLEAR_INVOCATIONS_ON_REFERENCED_MOCK_IF_REFERNCE_NOT_CLEARED = reference -> {
27+
private static final Predicate<WeakReference<Object>> CLEAR_INVOCATIONS_ON_REFERENCED_MOCK_IF_REFERENCE_NOT_CLEARED = reference -> {
2828
if(IS_REFERENCE_CLEARED.test(reference)) return true;
2929
CLEAR_INVOCATIONS_ON_REFERENCED_MOCK.accept(reference);
3030
return false;
@@ -37,7 +37,7 @@ public final class Mocks {
3737
// 2) Garbage collected references are removed
3838
// 3) Mock is garbage collected
3939
// 4) Mock invocations are cleared -> throws NullPointerException
40-
Lib199Subsystem.registerPeriodic(() -> MOCKS.removeIf(CLEAR_INVOCATIONS_ON_REFERENCED_MOCK_IF_REFERNCE_NOT_CLEARED));
40+
Lib199Subsystem.registerPeriodic(() -> MOCKS.removeIf(CLEAR_INVOCATIONS_ON_REFERENCED_MOCK_IF_REFERENCE_NOT_CLEARED));
4141
}
4242

4343
/**
@@ -61,7 +61,7 @@ public static <T, U> T createMock(Class<T> classToMock, U implClass, Class<?>...
6161
* @param <U> the class type which will be used to provide method implementations
6262
* @param classToMock the class type which will be mocked
6363
* @param implClass the object to which to try to forward method calls
64-
* @param forwardUnknownCalls whether methods which are not overriden will call their real methods
64+
* @param forwardUnknownCalls whether methods which are not overridden will call their real methods
6565
* @param interfaces a list of interfaces which the mocked object should extend
6666
* @return an instance of <code>T</code> in which some or all of the classes methods are replaced with a mocked implementation from <code>U</code>
6767
* @see #createMock(Class, Object, Class...)
@@ -77,7 +77,7 @@ public static <T, U> T createMock(Class<T> classToMock, U implClass, boolean for
7777
* @param <U> the class type which will be used to provide method implementations
7878
* @param classToMock the class type which will be mocked
7979
* @param implClass the object to which to try to forward method calls
80-
* @param defaultAnswer The answer to use when no overriden implementation is found
80+
* @param defaultAnswer The answer to use when no overridden implementation is found
8181
* @param interfaces a list of interfaces which the mocked object should extend
8282
* @return an instance of <code>T</code> in which some or all of the classes methods are replaced with a mocked implementation from <code>U</code>
8383
* @see #createMock(Class, Object, Class...)

src/main/java/org/carlmontrobotics/lib199/MotorControllerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public static UsbCamera configureCamera() {
171171
}
172172

173173
/**
174-
* This method is equivilent to calling {@link #configureCamera()} {@code numCameras} times.
174+
* This method is equivalent to calling {@link #configureCamera()} {@code numCameras} times.
175175
* The last camera will be set as the primary Camera feed.
176176
* To change it, call {@code CameraServer.getServer().setSource()}.
177177
*

src/main/java/org/carlmontrobotics/lib199/MotorErrors.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ private static <T extends Enum<T>> void reportError(String vendor, T error, T ok
4747
if(error == null || error == ok) {
4848
return;
4949
}
50-
System.err.println("Error: " + error.name() + " occured while configuring " + vendor + " motor");
50+
System.err.println("Error: " + error.name() + " occurred while configuring " + vendor + " motor");
5151
System.err.println("Full stack trace:");
5252
StackTraceElement[] stack = Thread.currentThread().getStackTrace();
5353
System.err.println(Arrays.toString(stack));
5454
}
5555

5656
public static void checkSparkMaxErrors(CANSparkMax spark) {
57-
//Purposely obivously impersonal to differentiate from actual computer generated errors
57+
//Purposely obviously impersonal to differentiate from actual computer generated errors
5858
short faults = spark.getFaults();
5959
short stickyFaults = spark.getStickyFaults();
6060
short prevFaults = flags.containsKey(spark) ? flags.get(spark) : 0;
@@ -114,7 +114,7 @@ public static void doReportSparkMaxTemp() {
114114
temperatureSparks.forEach((port, spark) -> {
115115
double temp = spark.getMotorTemperature();
116116
SmartDashboard.putNumber("Port " + port + " Spark Max Temp", temp);
117-
// Check if temperature exceeds the setpoint or if the contoller has already overheated to prevent other code from resetting the current limit after the controller has cooled
117+
// Check if temperature exceeds the setpoint or if the controller has already overheated to prevent other code from resetting the current limit after the controller has cooled
118118
if(temp >= sparkTemperatureLimits.get(port) || overheatedSparks.contains(port)) {
119119
if(!overheatedSparks.contains(port)) {
120120
overheatedSparks.add(port);

src/main/java/org/carlmontrobotics/lib199/path/RobotPath.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ public Command getPathCommand(boolean faceInPathDirection, boolean stopAtEnd) {
8585
if (trajectory == null) {
8686
generateTrajectory();
8787
}
88-
hs.reset();
8988
// We want the robot to stay facing the same direction (in this case), so save
9089
// the current heading (make sure to update at the start of the command)
9190
AtomicReference<Rotation2d> headingRef = new AtomicReference<>(dt.getPose().getRotation());
9291
Supplier<Rotation2d> desiredHeading = (!faceInPathDirection) ? () -> headingRef.get() : () -> hs.sample();
9392
Command command = dt.createAutoCommand(trajectory, desiredHeading);
93+
command = new InstantCommand(hs::reset).andThen(command, new InstantCommand(hs::stop));
9494
if (stopAtEnd) {
9595
command = command.andThen(new InstantCommand(dt::stop, dt));
9696
}
@@ -310,5 +310,13 @@ public void reset() {
310310
timerStarted = false;
311311
timer.reset();
312312
}
313+
314+
/**
315+
* Stops the timer
316+
*/
317+
public void stop() {
318+
timer.stop();
319+
reset();
320+
}
313321
}
314322
}

0 commit comments

Comments
 (0)