Skip to content

Commit 80b31be

Browse files
authored
Merge pull request #24 from wmironpatriots/feat/elevator-subsystem
Feat/elevator subsystem
2 parents 621cb78 + e2bd3eb commit 80b31be

File tree

15 files changed

+875
-13
lines changed

15 files changed

+875
-13
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ jobs:
3434
git commit -m "auto generated"
3535
git push
3636
- name: Build Robot Code
37-
run: ./gradlew build
37+
run: ./gradlew build
38+
- name: Run Tests
39+
run: ./gradlew test

build.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,19 @@ deploy {
3535
jvmArgs.add("-XX:+UseSerialGC")
3636
jvmArgs.add("-XX:MaxGCPauseMillis=50")
3737

38+
// Enable VisualVM connection
39+
jvmArgs.add("-Dcom.sun.management.jmxremote=true")
40+
jvmArgs.add("-Dcom.sun.management.jmxremote.port=1198")
41+
jvmArgs.add("-Dcom.sun.management.jmxremote.local.only=false")
42+
jvmArgs.add("-Dcom.sun.management.jmxremote.ssl=false")
43+
jvmArgs.add("-Dcom.sun.management.jmxremote.authenticate=false")
44+
jvmArgs.add("-Djava.rmi.server.hostname=10.64.23.2")
45+
3846
// RIO 2.0 ONLY
39-
final MAX_JAVA_HEAP_SIZE_MB = 100;
40-
jvmArgs.add("-Xmx" + MAX_JAVA_HEAP_SIZE_MB + "M")
41-
jvmArgs.add("-Xms" + MAX_JAVA_HEAP_SIZE_MB + "M")
42-
jvmArgs.add("-XX:+AlwaysPreTouch")
47+
// final MAX_JAVA_HEAP_SIZE_MB = 100;
48+
// jvmArgs.add("-Xmx" + MAX_JAVA_HEAP_SIZE_MB + "M")
49+
// jvmArgs.add("-Xms" + MAX_JAVA_HEAP_SIZE_MB + "M")
50+
// jvmArgs.add("-XX:+AlwaysPreTouch")
4351
}
4452

4553

src/main/java/org/frc6423/lib/types/CanDeviceId.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package org.frc6423.lib.types;
88

9+
@Deprecated
910
public class CanDeviceId {
1011
private final String busName;
1112
private final int canId;

src/main/java/org/frc6423/lib/utilities/TestUtils.java

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66

77
package org.frc6423.lib.utilities;
88

9+
import static edu.wpi.first.units.Units.Seconds;
10+
911
import edu.wpi.first.hal.AllianceStationID;
1012
import edu.wpi.first.hal.HAL;
13+
import edu.wpi.first.units.measure.Time;
1114
import edu.wpi.first.wpilibj.simulation.DriverStationSim;
1215
import edu.wpi.first.wpilibj.simulation.SimHooks;
16+
import edu.wpi.first.wpilibj2.command.Command;
1317
import edu.wpi.first.wpilibj2.command.CommandScheduler;
18+
import org.frc6423.robot.Constants.Flags;
1419

15-
/** Contains static methods for creating tests */
20+
/** Contains static methods for creating tests "Inspired" by FRC 1155 */
1621
public class TestUtils {
1722
/** Set up DS and initalizes HAL with default values and asserts that it doesn't fail */
1823
public static void setupTest() {
@@ -38,4 +43,67 @@ public static void reset(AutoCloseable... subsystems) throws Exception {
3843
subsystem.close();
3944
}
4045
}
46+
47+
/**
48+
* Runs CommandScheduler and updates timer repeatedly to fast forward subsystems and run commands.
49+
*
50+
* @param ticks The number of times CommandScheduler is run
51+
*/
52+
public static void fastForward(int ticks) {
53+
for (int i = 0; i < ticks; i++) {
54+
CommandScheduler.getInstance().run();
55+
SimHooks.stepTiming(Flags.PERIOD.in(Seconds));
56+
}
57+
}
58+
59+
/**
60+
* Fasts forward in time by running CommandScheduler and updating timer.
61+
*
62+
* @param time
63+
*/
64+
public static void fastForward(Time time) {
65+
fastForward((int) (time.in(Seconds) / Flags.PERIOD.in(Seconds)));
66+
}
67+
68+
/**
69+
* Runs CommandScheduler and updates timer to fast forward subsystems by 4 seconds and run
70+
* commands.
71+
*/
72+
public static void fastForward() {
73+
fastForward(Seconds.of(4));
74+
}
75+
76+
/**
77+
* Schedules and runs a command.
78+
*
79+
* @param command The command to run.
80+
*/
81+
public static void run(Command command) {
82+
run(command, 1);
83+
}
84+
85+
/**
86+
* Schedules and runs a command.
87+
*
88+
* @param command The command to run.
89+
* @param runs The number of times CommandScheduler is run.
90+
*/
91+
public static void run(Command command, int runs) {
92+
command.schedule();
93+
fastForward(runs);
94+
}
95+
96+
/**
97+
* Schedules a command and runs it until it ends. Be careful -- if the command you give never
98+
* ends, this will be an infinite loop!
99+
*
100+
* @param command
101+
*/
102+
public static void runToCompletion(Command command) {
103+
command.schedule();
104+
fastForward(1);
105+
while (command.isScheduled()) {
106+
fastForward(1);
107+
}
108+
}
41109
}

src/main/java/org/frc6423/robot/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Flags {
2828
}
2929

3030
/** Constants representing port IDs that devices are connected to */
31+
@Deprecated
3132
public class Ports {
3233
// * CANIVORE LOOP
3334
public static final CANBus CANCHAN = new CANBus("CANchan"); // :3

src/main/java/org/frc6423/robot/subsystems/superstructure/arm/ArmPivot.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ public class ArmPivot extends SubsystemBase implements AutoCloseable {
4747

4848
private final LinearFilter pivotCurrentFilter = LinearFilter.movingAverage(5);
4949

50-
@Logged(name = "Filted Pivot Motor Current (Amps)")
50+
@Logged(name = "Filted Pivot Motor Stator Current (Amps)")
5151
private double filteredPivotCurrent;
5252

53-
@Logged(name = "Is Zeroed (bool)")
5453
private boolean isZeroed = false;
5554

5655
private final Mechanism2d canvas =
@@ -78,6 +77,14 @@ public void periodic() {
7877
Rotation2d.fromRadians(hardware.getAngleRads()).unaryMinus().rotateBy(Rotation2d.k180deg));
7978
}
8079

80+
/**
81+
* @return true if arm has been homed
82+
*/
83+
@Logged(name = "Is Zeroed (bool)")
84+
public boolean isZeroed() {
85+
return isZeroed;
86+
}
87+
8188
/**
8289
* @return true if arm is within a certain tolerance of the setpoint angle
8390
*/
@@ -94,10 +101,7 @@ public boolean isNearSetpointAngle() {
94101
*/
95102
// TODO CHECK VALUES
96103
public Command runCurrentHoming() {
97-
return this.run(
98-
() -> {
99-
hardware.setVolts(-2.5);
100-
})
104+
return this.run(() -> hardware.setVolts(-2.5))
101105
.until(() -> Math.abs(filteredPivotCurrent) > 50.0)
102106
.finallyDo(
103107
(interupted) -> {

src/main/java/org/frc6423/robot/subsystems/superstructure/arm/ArmPivotIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface ArmPivotIO extends AutoCloseable {
3232
public double getStatorCurrentAmps();
3333

3434
/**
35-
* Reset relative encoder to specified position
35+
* Reset relative encoder of pivot motor to specified position
3636
*
3737
* @param poseRads position to reset to in radians
3838
*/

src/main/java/org/frc6423/robot/subsystems/superstructure/arm/ArmPivotIOSim.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import edu.wpi.first.wpilibj.simulation.SingleJointedArmSim;
1919
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
2020

21+
/** Simulated {@link ArmPivotIOReal} */
2122
public class ArmPivotIOSim implements ArmPivotIO {
2223
private final DCMotor pivotModel = DCMotor.getKrakenX60Foc(1);
2324
// TODO stddevs

0 commit comments

Comments
 (0)