Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
73c962e
started cleaning
Nummun14 Nov 18, 2024
48b1fef
added a BUNCH more jDocs. (I'm litterally falling asleep rn)
Nummun14 Nov 19, 2024
772ff20
finished adding jDocs
Nummun14 Nov 19, 2024
8590e74
grammer sucks
Nummun14 Nov 20, 2024
8fd094b
updated libraries and adapted code to it
Nummun14 Nov 21, 2024
9641ef3
javadocs are annoying. So is REV. So am I.
Nummun14 Nov 22, 2024
3bc9934
"Javadocs are actually quite fun" - Ezra Gryn 2024
Nummun14 Nov 24, 2024
f4b54ed
erm actually🤓
Nummun14 Nov 25, 2024
d659a54
JAVADOCS!!! and mirroable fix
Nummun14 Nov 26, 2024
a31891e
updated wpilib tools
Nummun14 Nov 26, 2024
8f37ade
maybe firxed SimpleMotorSimulation? (I know the jdoc isn't good, I'll…
Nummun14 Nov 27, 2024
7a119a5
did a bit of the review, will soon finish it
Nummun14 Nov 27, 2024
2676093
removed this for ezra (Your welcome, good luck on the math test :))
Nummun14 Nov 27, 2024
6fa773d
sim thing
Nummun14 Nov 27, 2024
8f0c459
"Explain more"
Nummun14 Nov 28, 2024
93ca69c
improve simplemotorsim jdoc
Nummun14 Nov 28, 2024
19a0eec
maybe improved spark sim logic
Nummun14 Nov 28, 2024
e7cd066
made config better
Nummun14 Nov 28, 2024
b56e3a7
jdocs and sim logic
Nummun14 Nov 28, 2024
2fcaf24
improve mechanism constructers
Nummun14 Nov 28, 2024
602383b
REVSucksConstants
Nummun14 Nov 28, 2024
320ebe2
spark sim still isn't working. (but I'm hoOolding on(epic is playing …
Nummun14 Nov 28, 2024
230d359
Merge branch 'main' into general-cleanup
Nummun14 Nov 29, 2024
f897188
javadocs suck, spit, stop, and setPosition
Nummun14 Nov 29, 2024
dd432bf
Removed annoying javadoc warnings
levyishai Nov 29, 2024
df2019a
threaded signal javadocs, and sim logic, will keep working on it late…
Nummun14 Nov 29, 2024
c398a10
imrproved spark encoder methods, and temporeraly removed mirroable bu…
Nummun14 Nov 30, 2024
d921352
added docs for cancoder and gyro, and cleaned up mirrorable
Nummun14 Nov 30, 2024
050783a
corrected led naming
Nummun14 Nov 30, 2024
8ed0e20
idea for mirrorable fix
Nummun14 Nov 30, 2024
c13cbe1
cleaned up mirrorable solution
Nummun14 Nov 30, 2024
cdc813e
idea for mirrorable fix
Nummun14 Dec 1, 2024
ee01192
🥸🫨🙂‍↔️🤒🧐mirrorable
Nummun14 Dec 1, 2024
3da0f22
updated limelight helpers, fixed led jdocs, reverted to old mirrorabl…
Nummun14 Dec 1, 2024
c4fd20a
cleaned up mirrorable, and spark. Still trying to figure out revSim
Nummun14 Dec 1, 2024
fc9740a
mirrorable, gyro, cancoder cleanup. SparkSim logic changes
Nummun14 Dec 1, 2024
db6344a
removed redundent if statement, and added temporary debugging stuff f…
Nummun14 Dec 1, 2024
1937b8b
improved jdocs, and changed some SparkSim logic, still doesn't work t…
Nummun14 Dec 1, 2024
a69df8a
jdoc and encoder sim
Nummun14 Dec 2, 2024
5a080b6
sim encoder logic stuff. Sim still isn't working
Nummun14 Dec 2, 2024
bebb7df
debugging
Nummun14 Dec 2, 2024
b9159e9
whitespaces and cleaning
Nummun14 Dec 2, 2024
6eb137c
added debugging sout
Nummun14 Dec 2, 2024
e656f2c
more souts
Nummun14 Dec 2, 2024
6a206a0
logging
Nummun14 Dec 2, 2024
c23adcd
id
Nummun14 Dec 2, 2024
63af5a5
print
Nummun14 Dec 2, 2024
f3eb6b4
sout
Nummun14 Dec 2, 2024
4705de9
* 60
Nummun14 Dec 2, 2024
ce72ae1
units. Also, Yishai you really never tested the code
Nummun14 Dec 2, 2024
5d6ce1d
docs and logs
Nummun14 Dec 2, 2024
aa951f6
changed encoder logic stuff
Nummun14 Dec 2, 2024
9b34333
camel case, and removed testing
Nummun14 Dec 2, 2024
4da3434
cleaned up solution. SIM WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!…
Nummun14 Dec 2, 2024
6d6203b
cleaning, and made motor sim get system or rotor depending on the enc…
Nummun14 Dec 2, 2024
dd1f31c
cleaned velocity calc
Nummun14 Dec 2, 2024
2b78686
no longer ew
Nummun14 Dec 2, 2024
f1c8acd
method name
Nummun14 Dec 2, 2024
29b2691
javadocs
Nummun14 Dec 3, 2024
de9590c
jdocs and "ecnoders
Nummun14 Dec 3, 2024
61f30f6
javadocs
Nummun14 Dec 3, 2024
422c7c6
docs and sim
Nummun14 Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id "java"
id "java-library"
id "maven-publish"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "edu.wpi.first.WpilibTools" version "1.3.0"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
id "edu.wpi.first.WpilibTools" version "2.1.0"
}

java {
Expand Down Expand Up @@ -51,6 +51,7 @@ wpi.java.configureTestTasks(test)
// Configure string concat to always inline compile
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/trigon/commands/ExecuteEndCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public ExecuteEndCommand(Runnable onExecute, Runnable onEnd, SubsystemBase... re
super(() -> {
}, onExecute, (interrupted) -> onEnd.run(), () -> false, requirements);
}
}
}
18 changes: 18 additions & 0 deletions src/main/java/org/trigon/hardware/BaseInputs.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public abstract class BaseInputs implements LoggableInputs {
private final String name;
private double lastErrorTimestamp = 0;

/**
* Creates a new BaseInputs instance.
*
* @param name the name of the instance. Used for error messages
*/
public BaseInputs(String name) {
this.name = name;
}
Expand All @@ -20,6 +25,12 @@ public void fromLog(LogTable table) {
latestTable = table;
}

/**
* Gets a signal from the inputs.
*
* @param signalName the name of the signal
* @return the signal
*/
public double getSignal(String signalName) {
if (latestTable == null) {
if (shouldPrintError())
Expand All @@ -37,6 +48,13 @@ public double getSignal(String signalName) {
return value.getDouble();
}

/**
* Gets a threaded signal.
* Threaded signals use threading to process certain signals separately at a faster rate.
*
* @param signalName the name of the threaded signal
* @return the threaded signal
*/
public double[] getThreadedSignal(String signalName) {
if (latestTable == null) {
if (shouldPrintError())
Expand Down
40 changes: 39 additions & 1 deletion src/main/java/org/trigon/hardware/RobotHardwareStats.java
Original file line number Diff line number Diff line change
@@ -1,40 +1,78 @@
package org.trigon.hardware;

/**
* A class that contains stats about the robot's hardware.
*/
public class RobotHardwareStats {
public static final double SUPPLY_VOLTAGE = 12;
private static boolean IS_SIMULATION = false;
private static boolean IS_REPLAY = false;
private static double PERIODIC_TIME_SECONDS = 0.02;

/**
* Sets the current robot stats. This should be called in the robot's init method.
* If isReal is true both simulation and replay will be false, otherwise they will be set according to the replay type.
* We use this structure to avoid using static variables in the Robot class.
*
* @param isReal whether the robot is real or a simulation. This should be taken from the Robot class
* @param replayType the type of replay
*/
public static void setCurrentRobotStats(boolean isReal, ReplayType replayType) {
if (isReal || replayType.equals(ReplayType.NONE)) {
IS_SIMULATION = !isReal;
IS_REPLAY = false;
return;
}

IS_SIMULATION = replayType.equals(ReplayType.SIMULATION_REPLAY);
IS_REPLAY = true;
}

/**
* Sets how frequently the simulation is updated.
*
* @param periodicTimeSeconds the periodic time in seconds
*/
public static void setPeriodicTimeSeconds(double periodicTimeSeconds) {
PERIODIC_TIME_SECONDS = periodicTimeSeconds;
}

/**
* @return the periodic time in seconds set in {@link #setPeriodicTimeSeconds(double)}
*/
public static double getPeriodicTimeSeconds() {
return PERIODIC_TIME_SECONDS;
}

/**
* @return whether the robot is in replay mode or not
*/
public static boolean isReplay() {
return IS_REPLAY;
}

/**
* @return whether the robot is running in simulation or not
*/
public static boolean isSimulation() {
return IS_SIMULATION;
}

/**
* An enum that represents the type of replay.
*/
public enum ReplayType {
/**
* The robot is not in replay mode
*/
NONE,
/**
* The robot is in simulation replay mode
*/
SIMULATION_REPLAY,
/**
* The robot is in real replay mode
*/
REAL_REPLAY
}
}
33 changes: 29 additions & 4 deletions src/main/java/org/trigon/hardware/SignalThreadBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,41 @@
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.locks.ReentrantLock;

/**
* A class that represents a base for a signal thread.
* Signal threads are specialized threads that run at a specific frequency to handle updating signals.
*/
public class SignalThreadBase extends Thread {
public static final ReentrantLock SIGNALS_LOCK = new ReentrantLock();
protected final Queue<Double> timestamps = new ArrayBlockingQueue<>(100);
private final ThreadInputsAutoLogged threadInputs = new ThreadInputsAutoLogged();
private final String name;
protected double odometryFrequencyHertz = 50;
protected double threadFrequencyHertz = 50;

/**
* Creates a new SignalThreadBase.
*
* @param name the name of the thread
*/
public SignalThreadBase(String name) {
this.name = name;
}

public void setOdometryFrequencyHertz(double odometryFrequencyHertz) {
this.odometryFrequencyHertz = odometryFrequencyHertz;
/**
* Sets the thread frequency in hertz.
* The thread frequency determines how often the robot's position and motion data are updated.
* A higher frequency will result in more frequent updates, but may also demand more processing power.
* Only used for Spark motors.
*
* @param threadFrequencyHertz the odometry frequency in hertz
*/
public void setThreadFrequencyHertz(double threadFrequencyHertz) {
this.threadFrequencyHertz = threadFrequencyHertz;
}

/**
* Updates the latest timestamps, and processes the inputs.
*/
public void updateLatestTimestamps() {
if (!RobotHardwareStats.isReplay()) {
threadInputs.timestamps = timestamps.stream().mapToDouble(Double::doubleValue).toArray();
Expand All @@ -30,6 +50,11 @@ public void updateLatestTimestamps() {
Logger.processInputs(name, threadInputs);
}

/**
* Gets the latest timestamps when signals were updated.
*
* @return the latest timestamps
*/
public double[] getLatestTimestamps() {
return threadInputs.timestamps;
}
Expand All @@ -38,4 +63,4 @@ public double[] getLatestTimestamps() {
public static class ThreadInputs {
public double[] timestamps;
}
}
}
32 changes: 0 additions & 32 deletions src/main/java/org/trigon/hardware/SignalUtilities.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import edu.wpi.first.wpilibj2.command.button.Trigger;
import org.littletonrobotics.junction.networktables.LoggedDashboardBoolean;

/**
* A class that represents a keyboard controller. Used to get input from a keyboard.
*/
public class KeyboardController {
private final LoggedDashboardBoolean
esc, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10,
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/trigon/hardware/misc/XboxController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;

/**
* A class that represents an Xbox controller. Used to get the values of the sticks and buttons on a controller, with the option of a deadband and exponentiation.
*/
public class XboxController extends CommandXboxController {
private int exponent = 1;
private double deadband = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ void rainbow(double brightness, double speed, boolean inverted) {
@Override
void sectionColor(Supplier<Color>[] colors) {
final int amountOfSections = colors.length;
final int LEDsPerSection = (int) Math.floor(numberOfLEDs / amountOfSections);
final int ledsPerSection = (int) Math.floor(numberOfLEDs / amountOfSections);

for (int i = 0; i < amountOfSections; i++)
setLEDColors(
inverted ? colors[amountOfSections - i - 1].get() : colors[i].get(),
LEDsPerSection * i,
i == amountOfSections - 1 ? numberOfLEDs - 1 : LEDsPerSection * (i + 1) - 1
ledsPerSection * i,
i == amountOfSections - 1 ? numberOfLEDs - 1 : ledsPerSection * (i + 1) - 1
);
}

Expand Down Expand Up @@ -186,7 +186,7 @@ private void setBreathingLEDs(Color color, int breathingLEDs, LarsonAnimation.Bo
for (int i = 0; i < breathingLEDs; i++) {
if (lastBreatheLED - i >= indexOffset && lastBreatheLED - i < indexOffset + numberOfLEDs)
LED_BUFFER.setLED(lastBreatheLED - i, color);

else if (lastBreatheLED - i < indexOffset + numberOfLEDs) {
if (bounceMode.equals(LarsonAnimation.BounceMode.Back) || bounceMode.equals(LarsonAnimation.BounceMode.Center) && i > breathingLEDs / 2)
return;
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/org/trigon/hardware/misc/leds/CANdleLEDStrip.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public class CANdleLEDStrip extends LEDStrip {
private final int animationSlot;

/**
* Sets the CANdle instance to be used for controlling the LED strips. Must be set before using any LED strips. Should only be called once
* Sets the CANdle instance to be used for controlling the LED strips. Must be set before using any LED strips. Should only be called once.
* Must be configured before being set.
*
* @param candle the CANdle instance to be used
*/
Expand Down Expand Up @@ -140,19 +141,19 @@ void rainbow(double brightness, double speed, boolean inverted) {

@Override
void sectionColor(Supplier<Color>[] colors) {
final int LEDSPerSection = (int) Math.floor(numberOfLEDs / colors.length);
setSectionColor(colors.length, LEDSPerSection, colors);
final int ledsPerSection = (int) Math.floor(numberOfLEDs / colors.length);
setSectionColor(colors.length, ledsPerSection, colors);
}

private void setSectionColor(int amountOfSections, int LEDSPerSection, Supplier<Color>[] colors) {
private void setSectionColor(int amountOfSections, int ledsPerSection, Supplier<Color>[] colors) {
for (int i = 0; i < amountOfSections; i++) {
CANDLE.setLEDs(
(int) (inverted ? colors[amountOfSections - i - 1].get().red : colors[i].get().red),
(int) (inverted ? colors[amountOfSections - i - 1].get().green : colors[i].get().green),
(int) (inverted ? colors[amountOfSections - i - 1].get().blue : colors[i].get().blue),
0,
LEDSPerSection * i + indexOffset,
i == amountOfSections - 1 ? numberOfLEDs - 1 : LEDSPerSection * (i + 1) - 1
ledsPerSection * i + indexOffset,
i == amountOfSections - 1 ? numberOfLEDs - 1 : ledsPerSection * (i + 1) - 1
);
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/trigon/hardware/misc/leds/LEDCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static Command getStaticColorCommand(Color color, LEDStrip... ledStrips)
return new StartEndCommand(
() -> {
runForLEDs((LEDStrip::clearLEDColors), ledStrips);
runForLEDs(LEDStrip -> LEDStrip.setCurrentAnimation(() -> LEDStrip.staticColor(color)), ledStrips);
runForLEDs(ledStrip -> ledStrip.setCurrentAnimation(() -> ledStrip.staticColor(color)), ledStrips);
},
() -> runForLEDs(LEDStrip::clearLEDColors, ledStrips),
ledStrips
Expand All @@ -42,7 +42,7 @@ public static Command getBlinkingCommand(Color firstColor, double speed, LEDStri
return new StartEndCommand(
() -> {
runForLEDs((LEDStrip::clearLEDColors), ledStrips);
runForLEDs(LEDStrip -> LEDStrip.setCurrentAnimation(() -> LEDStrip.blink(firstColor, speed)), ledStrips);
runForLEDs(ledStrip -> ledStrip.setCurrentAnimation(() -> ledStrip.blink(firstColor, speed)), ledStrips);
},
() -> runForLEDs(LEDStrip::clearLEDColors, ledStrips),
ledStrips
Expand All @@ -64,7 +64,7 @@ public static Command getBreatheCommand(Color color, int amountOfBreathingLEDs,
return new StartEndCommand(
() -> {
runForLEDs((LEDStrip::clearLEDColors), ledStrips);
runForLEDs(LEDStrip -> LEDStrip.setCurrentAnimation(() -> LEDStrip.breathe(color, amountOfBreathingLEDs, speed, inverted, bounceMode)), ledStrips);
runForLEDs(ledStrip -> ledStrip.setCurrentAnimation(() -> ledStrip.breathe(color, amountOfBreathingLEDs, speed, inverted, bounceMode)), ledStrips);
},
() -> runForLEDs(LEDStrip::clearLEDColors, ledStrips),
ledStrips
Expand All @@ -84,7 +84,7 @@ public static Command getColorFlowCommand(Color color, double speed, boolean inv
return new StartEndCommand(
() -> {
runForLEDs((LEDStrip::clearLEDColors), ledStrips);
runForLEDs(LEDStrip -> LEDStrip.setCurrentAnimation(() -> LEDStrip.colorFlow(color, speed, inverted)), ledStrips);
runForLEDs(ledStrip -> ledStrip.setCurrentAnimation(() -> ledStrip.colorFlow(color, speed, inverted)), ledStrips);
},
() -> runForLEDs(LEDStrip::clearLEDColors, ledStrips),
ledStrips
Expand All @@ -103,7 +103,7 @@ public static Command getAlternateColorCommand(Color firstColor, Color secondCol
return new StartEndCommand(
() -> {
runForLEDs((LEDStrip::clearLEDColors), ledStrips);
runForLEDs(LEDStrip -> LEDStrip.setCurrentAnimation(() -> LEDStrip.alternateColor(firstColor, secondColor)), ledStrips);
runForLEDs(ledStrip -> ledStrip.setCurrentAnimation(() -> ledStrip.alternateColor(firstColor, secondColor)), ledStrips);
},
() -> runForLEDs(LEDStrip::clearLEDColors, ledStrips),
ledStrips
Expand All @@ -121,7 +121,7 @@ public static Command getSectionColorCommand(Supplier<Color>[] colors, LEDStrip.
return new StartEndCommand(
() -> {
runForLEDs((LEDStrip::clearLEDColors), ledStrips);
runForLEDs(LEDStrip -> LEDStrip.setCurrentAnimation(() -> LEDStrip.sectionColor(colors)), ledStrips);
runForLEDs(ledStrip -> ledStrip.setCurrentAnimation(() -> ledStrip.sectionColor(colors)), ledStrips);
},
() -> runForLEDs(LEDStrip::clearLEDColors, ledStrips),
ledStrips
Expand All @@ -141,15 +141,15 @@ public static Command getRainbowCommand(double brightness, double speed, boolean
return new StartEndCommand(
() -> {
runForLEDs((LEDStrip::clearLEDColors), ledStrips);
runForLEDs(LEDStrip -> LEDStrip.setCurrentAnimation(() -> LEDStrip.rainbow(brightness, speed, inverted)), ledStrips);
runForLEDs(ledStrip -> ledStrip.setCurrentAnimation(() -> ledStrip.rainbow(brightness, speed, inverted)), ledStrips);
},
() -> runForLEDs(LEDStrip::clearLEDColors, ledStrips),
ledStrips
).ignoringDisable(true);
}

private static void runForLEDs(Consumer<LEDStrip> action, LEDStrip... ledStrips) {
for (LEDStrip LEDStrip : ledStrips)
action.accept(LEDStrip);
for (LEDStrip ledStrip : ledStrips)
action.accept(ledStrip);
}
}
Loading
Loading