Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0d38f0a
Added Mechanism2D display of claw, arm pivot, and elevator
RobototesProgrammers May 30, 2025
517f0d6
Spotless
RobototesProgrammers May 30, 2025
ed09bbe
Merge branch 'main' into Mechanisms
Jetblackdragon Aug 26, 2025
83839ad
Added mechanism config file to robot code for easy access WIP
RobototesProgrammers Oct 3, 2025
5c5fb1f
Added networktables entry for elevator pose3d WIP
RobototesProgrammers Oct 3, 2025
7a86d58
elastic camera fix
RobototesProgrammers Oct 18, 2025
c8fcedc
autoScore stuff
RobototesProgrammers Oct 18, 2025
3cf57f5
Merge branch 'GGCOMPB' of https://github.com/robototes/Reefscape2025 …
RobototesProgrammers Oct 18, 2025
1014c22
l1 auto align
RobototesProgrammers Oct 18, 2025
0d2405e
ee
RobototesProgrammers Oct 18, 2025
f0f2c2f
Merge branch 'GGCOMPB' of https://github.com/robototes/Reefscape2025 …
RobototesProgrammers Oct 18, 2025
e00f827
c
RobototesProgrammers Oct 18, 2025
088c917
super jank code to get auto l1 auto extake
RobototesProgrammers Oct 18, 2025
e1b832a
c
RobototesProgrammers Oct 18, 2025
c183519
ds changes
RobototesProgrammers Oct 19, 2025
0bcbd20
quick hand off fix
RobototesProgrammers Oct 19, 2025
3212b7e
Merge branch 'GGCOMPB' of https://github.com/robototes/Reefscape2025 …
RobototesProgrammers Oct 19, 2025
b2d6687
log + spot
Jetblackdragon Oct 20, 2025
061e0ee
Girls gen stuff added
SnappleRamen Oct 20, 2025
1ce5960
Added smoothing factor to claw position(DEBUG AND TESTING WIP)
SnappleRamen Oct 22, 2025
c9eb0b1
Merge branch 'Mechanisms' of https://github.com/robototes/Reefscape20…
SnappleRamen Oct 22, 2025
6aab30c
Claw position fixed, elevator height offset kinda working WIP
SnappleRamen Oct 29, 2025
5fa4bb0
Added positional smoothing
SnappleRamen Nov 7, 2025
db5ca1e
Sort of decent claw
SnappleRamen Nov 14, 2025
c59dc10
Better debug elevator presets
SnappleRamen Nov 15, 2025
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
1,170 changes: 320 additions & 850 deletions src/main/deploy/elastic-layout.json

Large diffs are not rendered by default.

60 changes: 45 additions & 15 deletions src/main/java/frc/robot/Controls.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ public Controls(Subsystems s, Sensors sensors, SuperStructure superStructure) {
configureGroundSpinnyBindings();
configureGroundArmBindings();
configureSoloControllerBindings();
Shuffleboard.getTab("Elevator")
.addBoolean("Intaking mode Algae", () -> intakeMode == ScoringMode.ALGAE);
Shuffleboard.getTab("Elevator")
.addString("Scoring Mode", () -> getSoloScoringMode().toString());
}

public SoloScoringMode getSoloScoringMode() {
return soloScoringMode;
}

private Trigger connected(CommandXboxController controller) {
Expand Down Expand Up @@ -394,12 +402,7 @@ private void configureSuperStructureBindings() {
case ALGAE -> soloScoringMode = SoloScoringMode.ALGAE_IN_CLAW;
}
})
.withName("Set solo scoring mode"));

sensors
.armSensor
.inClaw()
.and(RobotModeTriggers.teleop())
.withName("Set solo scoring mode"))
.onFalse(
Commands.runOnce(
() -> {
Expand Down Expand Up @@ -457,19 +460,36 @@ private Command getCoralBranchHeightCommand() {
};
}

private Command getSoloCoralBranchHeightCommand() {
private Command getSoloCoralBranchHeightCommandL() {
return switch (branchHeight) {
case CORAL_LEVEL_FOUR -> superStructure
.coralLevelFour(soloController.rightBumper())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_THREE -> superStructure
.coralLevelThree(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_TWO -> superStructure
.coralLevelTwo(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_ONE -> superStructure
.coralLevelOne(soloController.rightBumper(), () -> AutoAlign.poseInPlaceL1L())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
};
}

private Command getSoloCoralBranchHeightCommandR() {
return switch (branchHeight) {
case CORAL_LEVEL_FOUR -> superStructure
.coralLevelFour(soloController.rightBumper())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_THREE -> superStructure
.coralLevelThree(soloController.rightBumper())
.coralLevelThree(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_TWO -> superStructure
.coralLevelTwo(soloController.rightBumper())
.coralLevelTwo(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_ONE -> superStructure
.coralLevelOne(soloController.rightBumper())
.coralLevelOne(soloController.rightBumper(), () -> AutoAlign.poseInPlaceL1R())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
};
}
Comment on lines +463 to 495

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The methods getSoloCoralBranchHeightCommandL and getSoloCoralBranchHeightCommandR are nearly identical, with the only difference being the BooleanSupplier passed to superStructure.coralLevelOne. You can refactor them into a single method that accepts the BooleanSupplier as a parameter. This reduces code duplication and improves maintainability.

You can then call this new method from configureSoloControllerBindings like getSoloCoralBranchHeightCommand(() -> AutoAlign.poseInPlaceL1L()) and getSoloCoralBranchHeightCommand(() -> AutoAlign.poseInPlaceL1R()).

Suggested change
private Command getSoloCoralBranchHeightCommandL() {
return switch (branchHeight) {
case CORAL_LEVEL_FOUR -> superStructure
.coralLevelFour(soloController.rightBumper())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_THREE -> superStructure
.coralLevelThree(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_TWO -> superStructure
.coralLevelTwo(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_ONE -> superStructure
.coralLevelOne(soloController.rightBumper(), () -> AutoAlign.poseInPlaceL1L())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
};
}
private Command getSoloCoralBranchHeightCommandR() {
return switch (branchHeight) {
case CORAL_LEVEL_FOUR -> superStructure
.coralLevelFour(soloController.rightBumper())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_THREE -> superStructure
.coralLevelThree(soloController.rightBumper())
.coralLevelThree(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_TWO -> superStructure
.coralLevelTwo(soloController.rightBumper())
.coralLevelTwo(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_ONE -> superStructure
.coralLevelOne(soloController.rightBumper())
.coralLevelOne(soloController.rightBumper(), () -> AutoAlign.poseInPlaceL1R())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
};
}
private Command getSoloCoralBranchHeightCommand(BooleanSupplier l1PoseSupplier) {
return switch (branchHeight) {
case CORAL_LEVEL_FOUR -> superStructure
.coralLevelFour(soloController.rightBumper())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_THREE -> superStructure
.coralLevelThree(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_TWO -> superStructure
.coralLevelTwo(soloController.rightBumper(), () -> AutoAlign.poseInPlace())
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
case CORAL_LEVEL_ONE -> superStructure
.coralLevelOne(soloController.rightBumper(), l1PoseSupplier)
.andThen(() -> soloScoringMode = soloScoringMode.NO_GAME_PIECE);
};
}

Expand Down Expand Up @@ -926,7 +946,7 @@ private void configureSoloControllerBindings() {
switch (soloScoringMode) {
case CORAL_IN_CLAW -> {
scoreCommand =
getSoloCoralBranchHeightCommand()
getSoloCoralBranchHeightCommandL()
.until(
() ->
soloController.a().getAsBoolean()
Expand Down Expand Up @@ -969,6 +989,11 @@ private void configureSoloControllerBindings() {
.and(() -> soloScoringMode == soloScoringMode.CORAL_IN_CLAW)
.and(() -> branchHeight != BranchHeight.CORAL_LEVEL_ONE)
.whileTrue(AutoAlign.autoAlignLeft(s.drivebaseSubsystem, this));
soloController
.leftTrigger()
.and(() -> soloScoringMode == soloScoringMode.CORAL_IN_CLAW)
.and(() -> branchHeight == BranchHeight.CORAL_LEVEL_ONE)
.whileTrue(AutoAlign.autoAlignL1L(s.drivebaseSubsystem, this));
// Processor + Auto align right + Select scoring mode Coral
soloController
.rightTrigger()
Expand All @@ -977,7 +1002,7 @@ private void configureSoloControllerBindings() {
() -> {
Command scoreCommand =
switch (soloScoringMode) {
case CORAL_IN_CLAW -> getSoloCoralBranchHeightCommand()
case CORAL_IN_CLAW -> getSoloCoralBranchHeightCommandR()
.until(
() ->
soloController.a().getAsBoolean()
Expand Down Expand Up @@ -1006,6 +1031,11 @@ private void configureSoloControllerBindings() {
.and(() -> soloScoringMode == soloScoringMode.CORAL_IN_CLAW)
.and(() -> branchHeight != BranchHeight.CORAL_LEVEL_ONE)
.whileTrue(AutoAlign.autoAlignRight(s.drivebaseSubsystem, this));
soloController
.rightTrigger()
.and(() -> soloScoringMode == soloScoringMode.CORAL_IN_CLAW)
.and(() -> branchHeight == BranchHeight.CORAL_LEVEL_ONE)
.whileTrue(AutoAlign.autoAlignL1R(s.drivebaseSubsystem, this));
// Ground Intake
soloController
.leftBumper()
Expand Down Expand Up @@ -1095,11 +1125,11 @@ private void configureSoloControllerBindings() {
.startMovingVoltage(
() -> Volts.of(ElevatorSubsystem.UP_VOLTAGE * -soloController.getLeftY()))
.withName("Elevator Manual Control"));
// Ready to score rumble
Trigger readyToScore = new Trigger(() -> AutoAlign.poseInPlace());
// Ready to score rumble (Removal for autoscoring)
/* Trigger readyToScore = new Trigger(() -> AutoAlign.poseInPlace());
readyToScore.onTrue(
Commands.runOnce(() -> soloController.setRumble(RumbleType.kBothRumble, 1.0)));
readyToScore.onFalse(
Commands.runOnce(() -> soloController.setRumble(RumbleType.kBothRumble, 0.0)));
Commands.runOnce(() -> soloController.setRumble(RumbleType.kBothRumble, 0.0))); */
Comment on lines +1129 to +1133

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code has been commented out with the note (Removal for autoscoring). If it's no longer needed, it's better to remove it completely to improve code clarity. Version control can be used to retrieve it if needed in the future.

}
}
26 changes: 26 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import au.grapplerobotics.CanBridge;
import com.pathplanner.lib.commands.FollowPathCommand;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.net.WebServer;
import edu.wpi.first.wpilibj.DataLogManager;
import edu.wpi.first.wpilibj.DriverStation;
Expand All @@ -16,7 +17,12 @@
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.smartdashboard.Mechanism2d;
import edu.wpi.first.wpilibj.smartdashboard.MechanismLigament2d;
import edu.wpi.first.wpilibj.smartdashboard.MechanismRoot2d;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.util.Color;
import edu.wpi.first.wpilibj.util.Color8Bit;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import frc.robot.Subsystems.SubsystemConstants;
import frc.robot.subsystems.SuperStructure;
Expand All @@ -43,6 +49,11 @@ public static Robot getInstance() {
public final SuperStructure superStructure;
private final PowerDistribution PDH;

Mechanism2d mech;
MechanismRoot2d root;
MechanismLigament2d m_elevator;
MechanismLigament2d m_wrist;
Comment on lines +52 to +55
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nicer to encapsulate the Mechanism (and similar "report physical position") code in a different class instead of adding it to the main Robot class. These are generally called 'digital twins', so could use something like DigitalTwin.java and have robotPeriodic() simply call an update() function on it.


protected Robot() {
// non public for singleton. Protected so test class can subclass

Expand All @@ -52,6 +63,19 @@ protected Robot() {
PDH = new PowerDistribution(Hardware.PDH_ID, ModuleType.kRev);
LiveWindow.disableAllTelemetry();
LiveWindow.enableTelemetry(PDH);
mech = new Mechanism2d(1, 2);
root = mech.getRoot("climber", 0.5 + Units.inchesToMeters(5.5), Units.inchesToMeters(19.5));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? Not sure what the "climber" is, as this year's robot isn't supposed to climb.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funnel pivot?

SmartDashboard.putData("Mechanism", mech);
m_elevator =
root.append(new MechanismLigament2d("elevator", 1, 90, 2, new Color8Bit(Color.kRed)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth a comment that this is a single-stage elevator even though the robot actually uses a multi-stage elevator.

var pivot =
m_elevator.append(
new MechanismLigament2d(
"pivot offset", Units.inchesToMeters(4), -90, 2, new Color8Bit(Color.kDarkRed)));
m_wrist =
pivot.append(
new MechanismLigament2d(
"wrist", Units.inchesToMeters(14.5), 270, 6, new Color8Bit(Color.kFirstRed)));
Comment on lines +67 to +78

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The initialization of the Mechanism2d uses several magic numbers for dimensions (e.g., 5.5, 19.5, 4, 14.5) and visualization properties (e.g., 1, 2, 90, -90, 270, 6). It would be better to define these as named constants in a relevant constants class (e.g., SubsystemConstants or a new RobotDimensions class). This improves readability and makes it easier to update these values.


sensors = new Sensors();
subsystems = new Subsystems(sensors);
Expand Down Expand Up @@ -117,6 +141,8 @@ public void robotPeriodic() {
if (subsystems.visionSubsystem != null) {
subsystems.visionSubsystem.update();
}
m_elevator.setLength(subsystems.elevatorSubsystem.getHeightMeters());
m_wrist.setAngle(subsystems.armPivotSubsystem.getAngle());
}

@Override
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/subsystems/ArmPivot.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.filter.Debouncer;
import edu.wpi.first.math.filter.Debouncer.DebounceType;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.units.measure.Voltage;
import edu.wpi.first.wpilibj.Alert;
Expand Down Expand Up @@ -146,6 +147,10 @@ private double getCurrentPosition() {
return curPos.getValueAsDouble();
}

public Rotation2d getAngle() { // 0 is forward, + is up
return Rotation2d.fromRotations(getCurrentPosition());
}
// preset command placeholder
/* moves arm to the input position
- sets the target position to the inputted position
- shrinks the difference between the current position and the target position until they are close enough to work
Expand Down
61 changes: 58 additions & 3 deletions src/main/java/frc/robot/subsystems/ElevatorSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.filter.Debouncer;
import edu.wpi.first.math.filter.Debouncer.DebounceType;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Pose3d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Rotation3d;
import edu.wpi.first.networktables.DoublePublisher;
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.networktables.StructPublisher;
import edu.wpi.first.units.Units;
import edu.wpi.first.units.measure.MutVoltage;
import edu.wpi.first.units.measure.Time;
import edu.wpi.first.units.measure.Voltage;
import edu.wpi.first.wpilibj.Alert;
import edu.wpi.first.wpilibj.Alert.AlertType;
import edu.wpi.first.wpilibj.RobotBase;
import edu.wpi.first.wpilibj.RobotController;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj.sysid.SysIdRoutineLog;
import edu.wpi.first.wpilibj2.command.Command;
Expand All @@ -24,6 +33,12 @@
import edu.wpi.first.wpilibj2.command.button.Trigger;
import edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine;
import frc.robot.Hardware;
import frc.robot.Robot;
import frc.robot.sensors.ArmSensor;
import frc.robot.subsystems.auto.AutoLogic;
import jdk.jfr.Timestamp;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The import jdk.jfr.Timestamp is unused in this file and should be removed.


import java.util.concurrent.TimeUnit;
import java.util.function.DoubleConsumer;
import java.util.function.DoubleSupplier;
import java.util.function.Supplier;
Expand Down Expand Up @@ -52,6 +67,7 @@ public class ElevatorSubsystem extends SubsystemBase {
public static final double CORAL_QUICK_INTAKE = 1.6;
public static final double MIN_EMPTY_GROUND_INTAKE = 4.5;
public static final double MIN_FULL_GROUND_INTAKE = 8.0;
private static final double MOTOR_ROTATIONS_PER_METER = 19.68; // Inaccurate
public static final double MANUAL = 0.1;
private static final double POS_TOLERANCE = 0.1;
private final double ELEVATOR_KP = 7.804;
Expand Down Expand Up @@ -90,6 +106,11 @@ public class ElevatorSubsystem extends SubsystemBase {
new Alert("Elevator", "Motor 2 not connected", AlertType.kError);
private final Debouncer notConnectedDebouncerOne = new Debouncer(.1, DebounceType.kBoth);
private final Debouncer notConnectedDebouncerTwo = new Debouncer(.1, DebounceType.kBoth);
private StructPublisher<Pose3d> elevatorPose3d = NetworkTableInstance.getDefault().getStructTopic("elevator/heightPose", Pose3d.struct).publish();
public StructPublisher<Pose3d> TESTpose = NetworkTableInstance.getDefault().getStructTopic("debug/TEST", Pose3d.struct).publish();
//public StructPublisher<Pose3d> TESTpose2 = NetworkTableInstance.getDefault().getStructTopic("debug/TEST2", Pose3d.struct).publish();
Comment on lines +109 to +111

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This section contains commented-out code and inconsistent formatting. The commented-out publisher for TESTpose2 should be removed if it's not needed. Also, the extra spaces before StructPublisher can be removed for consistent formatting.

Suggested change
private StructPublisher<Pose3d> elevatorPose3d = NetworkTableInstance.getDefault().getStructTopic("elevator/heightPose", Pose3d.struct).publish();
public StructPublisher<Pose3d> TESTpose = NetworkTableInstance.getDefault().getStructTopic("debug/TEST", Pose3d.struct).publish();
//public StructPublisher<Pose3d> TESTpose2 = NetworkTableInstance.getDefault().getStructTopic("debug/TEST2", Pose3d.struct).publish();
private StructPublisher<Pose3d> elevatorPose3d = NetworkTableInstance.getDefault().getStructTopic("elevator/heightPose", Pose3d.struct).publish();
public StructPublisher<Pose3d> TESTpose = NetworkTableInstance.getDefault().getStructTopic("debug/TEST", Pose3d.struct).publish();




// Creates a SysIdRoutine
SysIdRoutine routine =
Expand All @@ -107,6 +128,8 @@ public ElevatorSubsystem() {
motorConfigs();

Shuffleboard.getTab("Elevator").addDouble("Motor Current Position", () -> getCurrentPosition());
//Elevator pose test

Shuffleboard.getTab("Elevator").addDouble("Target Position", () -> getTargetPosition());
Shuffleboard.getTab("Elevator")
.addDouble("M1 supply current", () -> m_motor.getSupplyCurrent().getValueAsDouble());
Expand All @@ -133,6 +156,16 @@ public ElevatorSubsystem() {
"M2 at reverse softstop", () -> m_motor2.getFault_ReverseSoftLimit().getValue());
Shuffleboard.getTab("Elevator")
.addDouble("Elevator Speed", () -> m_motor.getVelocity().getValueAsDouble());

// Test commands
Shuffleboard.getTab("Elevator")
.add("Move to Level Four", setLevel(CORAL_LEVEL_FOUR_PRE_POS));
Shuffleboard.getTab("Elevator")
.add("Move to Level Three", setLevel(CORAL_LEVEL_THREE_PRE_POS));
Shuffleboard.getTab("Elevator")
.add("Move to Level Two", setLevel(CORAL_LEVEL_TWO_PRE_POS));
Shuffleboard.getTab("Elevator")
.add("Move to Level One", setLevel(CORAL_LEVEL_ONE_POS));
}

public Command sysIdQuasistatic(SysIdRoutine.Direction direction) {
Expand Down Expand Up @@ -249,6 +282,10 @@ private double getCurrentPosition() {
return curPos;
}

public double getHeightMeters() { // Elevator height converted to Meters
return getCurrentPosition() / MOTOR_ROTATIONS_PER_METER;
}

private void setCurrentPosition(double pos) {
m_motor.setPosition(pos);
}
Expand All @@ -270,6 +307,7 @@ public Command setLevel(double pos) {
return runOnce(
() -> {
if (hasBeenZeroed) {
System.out.println("Setting elevator level to: " + pos);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using System.out.println for logging is generally discouraged in robot code as it can be slow and doesn't integrate with the standard FRC logging framework. Consider using DataLogManager or publishing to SmartDashboard for debugging information, or remove this line if it's no longer needed.

m_motor.setControl(m_request.withPosition(pos));
m_motor2.setControl(new Follower(m_motor.getDeviceID(), true));
targetPos = pos;
Expand Down Expand Up @@ -360,16 +398,33 @@ public Command stop() {
.ignoringDisable(true)
.withName("ElevatorStop");
}

double smoothedAngleZ = 0.4;
double smoothingFactor = 0.1;
Comment on lines +401 to +402

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These member variables smoothedAngleZ and smoothingFactor are declared but never used. They should be removed to clean up the code.

@Override
public void periodic() {
NotConnectedError.set(
notConnectedDebouncerOne.calculate(!m_motor.getMotorVoltage().hasUpdated()));
NotConnectedError2.set(
notConnectedDebouncerTwo.calculate(!m_motor2.getMotorVoltage().hasUpdated()));
if (RobotBase.isSimulation()) {
m_motorOneSimState.setRawRotorPosition(targetPos);
m_motorTwoSimState.setRawRotorPosition(targetPos);
if (!Robot.getInstance().sensors.armSensor.booleanInClaw()) {
}
Comment on lines +410 to +411

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This if statement has an empty body and should be removed.

m_motorOneSimState.setRawRotorPosition(targetPos);
m_motorTwoSimState.setRawRotorPosition(targetPos);
//elevatorPose3d.set(new Pose3d(0.0, 0.0, getHeightMeters(), new Rotation3d()));

double curPos = getCurrentPosition();
double smoothingFactor = 0.5;// Percentage Scaler
double bottomZ = 0.2;
double topZ = 1.55;
double minPos = 0.0;
double maxPos = 37.5;
double targetZ = (bottomZ + ((curPos - minPos) / (maxPos - minPos)) * (topZ - bottomZ));
Comment on lines +417 to +422

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These lines use several magic numbers for an interpolation calculation (e.g., 0.5, 0.2, 1.55, 0.0, 37.5). These should be defined as named constants with descriptive names to improve readability and maintainability.


TESTpose.set(new Pose3d(
0.2, 0.0, targetZ,
new Rotation3d(0.0, 0.0, -135)));
Comment on lines +424 to +426

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The Rotation3d constructor takes radians, but is being passed -135. This is likely intended to be degrees and should be converted using Units.degreesToRadians(-135). Using -135 directly results in a very large and incorrect rotation in radians.

Suggested change
TESTpose.set(new Pose3d(
0.2, 0.0, targetZ,
new Rotation3d(0.0, 0.0, -135)));
TESTpose.set(new Pose3d(
0.2, 0.0, targetZ,
new Rotation3d(0.0, 0.0, edu.wpi.first.math.util.Units.degreesToRadians(-135))));

}

}
}
Loading