Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
68e6872
Started adding the vision subsystem
Huck-Richardson Jan 25, 2025
4418911
Started adding vision filters
Huck-Richardson Jan 28, 2025
4fc6b57
Added getter methods for tag info
Huck-Richardson Jan 28, 2025
52e57e3
Added the function for standard deviation finding
Huck-Richardson Jan 29, 2025
24297e5
Finished adding filters and started working on periodic
Huck-Richardson Jan 31, 2025
1925044
Continued to work on the periodic
Huck-Richardson Feb 1, 2025
87d9662
Finished main portion of vision. No logging yet
Huck-Richardson Feb 4, 2025
a08da79
Adding logging and documentation
Huck-Richardson Feb 5, 2025
1d5571b
Fixed a few comments
Huck-Richardson Feb 5, 2025
30b23a8
Fixed some minor issues
Huck-Richardson Feb 6, 2025
6f11667
Small fixes
Huck-Richardson Feb 6, 2025
1f148df
Added a docs folder and the vision filter spreadsheets
Huck-Richardson Feb 7, 2025
ce76c5d
merge main
ds12a Feb 10, 2025
0d7a1ef
merge everything, initial align testing
ds12a Feb 11, 2025
ca391b2
merge gone terribly
ds12a Feb 11, 2025
5f49d99
Adding more logging
Huck-Richardson Feb 11, 2025
ccd99cb
more testing
ds12a Feb 12, 2025
7aa34ae
Added debugging logging
PotatoBoyH4 Feb 12, 2025
ae9ad7e
odometry broken
ds12a Feb 14, 2025
30ad53d
debugging
ds12a Feb 14, 2025
369f356
fix odometry
ds12a Feb 15, 2025
78797eb
tag align testing
ds12a Feb 15, 2025
73feef0
fix bugs, banish math.hypot
ds12a Feb 15, 2025
ad0005c
filled reef
ds12a Feb 16, 2025
1189aec
tuning
ds12a Feb 18, 2025
31d3123
tuning
ds12a Feb 18, 2025
b8778d0
Merge branch 'robot-state' into tag-align
ds12a Feb 20, 2025
cf7b8e6
reef algae
ds12a Feb 21, 2025
8110922
Merge branch 'main' into tag-align
mwitcpalek Feb 22, 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
Binary file added docs/camsAgreeWithWheels.xlsx
Binary file not shown.
Binary file added docs/getStdFactor Upper.xlsx
Binary file not shown.
Binary file added docs/stdDevDecay.xlsx
Binary file not shown.
4 changes: 3 additions & 1 deletion src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public void robotPeriodic() {
}

@Override
public void disabledInit() {}
public void disabledInit() {
m_robotContainer.stopTagAlign();
}

@Override
public void disabledPeriodic() {}
Expand Down
74 changes: 55 additions & 19 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.ConditionalCommand;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.commands.algae.IntakeAlgaeCommand;
Expand All @@ -28,6 +29,7 @@
import frc.robot.commands.elevator.JogElevatorCommand;
import frc.robot.commands.elevator.SetElevatorPositionCommand;
import frc.robot.commands.elevator.ZeroElevatorCommand;
import frc.robot.commands.robotState.AutoReefCycleCommand;
import frc.robot.commands.robotState.FloorAlgaeCommand;
import frc.robot.commands.robotState.HPAlgaeCommand;
import frc.robot.commands.robotState.InterruptAutoCommand;
Expand Down Expand Up @@ -182,10 +184,18 @@ private void configureDriverBindings() {
new JoystickButton(driveJoystick, Button.SWD.id)
.onTrue(
new StowCommand(
robotStateSubsystem, elevatorSubsystem, coralSubsystem, biscuitSubsystem))
robotStateSubsystem,
elevatorSubsystem,
coralSubsystem,
biscuitSubsystem,
algaeSubsystem))
.onFalse(
new StowCommand(
robotStateSubsystem, elevatorSubsystem, coralSubsystem, biscuitSubsystem));
robotStateSubsystem,
elevatorSubsystem,
coralSubsystem,
biscuitSubsystem,
algaeSubsystem));
new JoystickButton(driveJoystick, Button.SWA.id)
.onTrue(new InterruptAutoCommand(robotStateSubsystem))
.onFalse(new InterruptAutoCommand(robotStateSubsystem));
Expand All @@ -197,14 +207,26 @@ private void configureDriverBindings() {
.onFalse(new ZeroElevatorCommand(elevatorSubsystem));

// other stuff

new JoystickButton(driveJoystick, Button.M_SWH.id)
.onTrue(
new ReefCycleCommand(
robotStateSubsystem,
elevatorSubsystem,
coralSubsystem,
biscuitSubsystem,
algaeSubsystem));
new ConditionalCommand(
new AutoReefCycleCommand(
robotStateSubsystem,
elevatorSubsystem,
coralSubsystem,
driveSubsystem,
tagAlignSubsystem,
biscuitSubsystem,
algaeSubsystem),
new ReefCycleCommand(
robotStateSubsystem,
elevatorSubsystem,
coralSubsystem,
biscuitSubsystem,
algaeSubsystem),
() -> robotStateSubsystem.getIsAutoPlacing()));

new JoystickButton(driveJoystick, Button.M_SWE.id)
.onTrue(
new ScoreAlgaeCommand(
Expand All @@ -226,6 +248,22 @@ private void configureDriverBindings() {
}

private void configureOperatorBindings() {
// Set Levels
new Trigger(() -> xboxController.getLeftTriggerAxis() > RobotConstants.kTriggerDeadband)
.onTrue(new SetScoringLevelCommand(robotStateSubsystem, ScoringLevel.L1));
new JoystickButton(xboxController, XboxController.Button.kLeftBumper.value)
.onTrue(new SetScoringLevelCommand(robotStateSubsystem, ScoringLevel.L2));
new JoystickButton(xboxController, XboxController.Button.kRightBumper.value)
.onTrue(new SetScoringLevelCommand(robotStateSubsystem, ScoringLevel.L3));
new Trigger(() -> xboxController.getRightTriggerAxis() > RobotConstants.kTriggerDeadband)
.onTrue(new SetScoringLevelCommand(robotStateSubsystem, ScoringLevel.L4));

// Set scoring side
// new JoystickButton(xboxController, XboxController.Button.kLeftStick.value)
// .onTrue(new SetScoreSideCommand(robotStateSubsystem, ScoreSide.LEFT));
// new JoystickButton(xboxController, XboxController.Button.kRightStick.value)
// .onTrue(new SetScoreSideCommand(robotStateSubsystem, ScoreSide.RIGHT));

// Move biscuit
new Trigger((() -> xboxController.getRightY() < -RobotConstants.kTestingDeadband))
.onTrue(
Expand All @@ -250,21 +288,15 @@ private void configureOperatorBindings() {
elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmountDown, Rotations)))
.onFalse(new HoldElevatorCommand(elevatorSubsystem));

// Set Levels
new Trigger(() -> xboxController.getLeftTriggerAxis() > RobotConstants.kTriggerDeadband)
.onTrue(new SetScoringLevelCommand(robotStateSubsystem, ScoringLevel.L1));
new JoystickButton(xboxController, XboxController.Button.kLeftBumper.value)
.onTrue(new SetScoringLevelCommand(robotStateSubsystem, ScoringLevel.L2));
new JoystickButton(xboxController, XboxController.Button.kRightBumper.value)
.onTrue(new SetScoringLevelCommand(robotStateSubsystem, ScoringLevel.L3));
new Trigger(() -> xboxController.getRightTriggerAxis() > RobotConstants.kTriggerDeadband)
.onTrue(new SetScoringLevelCommand(robotStateSubsystem, ScoringLevel.L4));

// Stow
new JoystickButton(xboxController, XboxController.Button.kBack.value)
.onTrue(
new StowCommand(
robotStateSubsystem, elevatorSubsystem, coralSubsystem, biscuitSubsystem));
robotStateSubsystem,
elevatorSubsystem,
coralSubsystem,
biscuitSubsystem,
algaeSubsystem));

// Algae
new JoystickButton(xboxController, XboxController.Button.kY.value)
Expand Down Expand Up @@ -400,4 +432,8 @@ public void configurePitDashboard() {
public Command getAutonomousCommand() {
return Commands.print("No autonomous command configured");
}

public void stopTagAlign() {
tagAlignSubsystem.terminate();
}
}
20 changes: 20 additions & 0 deletions src/main/java/frc/robot/commands/drive/ResetOdometryCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package frc.robot.commands.drive;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import frc.robot.subsystems.drive.DriveSubsystem;

public class ResetOdometryCommand extends InstantCommand {
private DriveSubsystem driveSubsystem;
private Pose2d pose;

public ResetOdometryCommand(DriveSubsystem driveSubsystem, Pose2d pose) {
this.driveSubsystem = driveSubsystem;
this.pose = pose;
}

@Override
public void initialize() {
driveSubsystem.resetOdometry(pose);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package frc.robot.commands.robotState;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.algae.AlgaeSubsystem;
import frc.robot.subsystems.biscuit.BiscuitSubsystem;
import frc.robot.subsystems.coral.CoralSubsystem;
import frc.robot.subsystems.drive.DriveSubsystem;
import frc.robot.subsystems.elevator.ElevatorSubsystem;
import frc.robot.subsystems.robotState.RobotStateSubsystem;
import frc.robot.subsystems.tagAlign.TagAlignSubsystem;

public class AutoReefCycleCommand extends Command {
private RobotStateSubsystem robotStateSubsystem;
private TagAlignSubsystem tagAlignSubsystem;
private DriveSubsystem driveSubsystem;
private boolean scoringCoral;

public AutoReefCycleCommand(
RobotStateSubsystem robotStateSubsystem,
ElevatorSubsystem elevatorSubsystem,
CoralSubsystem coralSubsystem,
DriveSubsystem driveSubsystem,
TagAlignSubsystem tagAlignSubsystem,
BiscuitSubsystem biscuitSubsystem,
AlgaeSubsystem algaeSubsystem) {
this.robotStateSubsystem = robotStateSubsystem;
this.tagAlignSubsystem = tagAlignSubsystem;
this.driveSubsystem = driveSubsystem;

addRequirements(elevatorSubsystem, coralSubsystem, biscuitSubsystem, algaeSubsystem);
}

@Override
public void initialize() {
driveSubsystem.setIgnoreSticks(true);
robotStateSubsystem.toReefAlign();
scoringCoral = robotStateSubsystem.hasCoral();
}

@Override
public void end(boolean interrupted) {
tagAlignSubsystem.terminate();
driveSubsystem.setIgnoreSticks(false);
}

@Override
public boolean isFinished() {
return scoringCoral && !robotStateSubsystem.hasCoral()
|| !scoringCoral && robotStateSubsystem.hasAlgae();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import frc.robot.subsystems.algae.AlgaeSubsystem;
import frc.robot.subsystems.biscuit.BiscuitSubsystem;
import frc.robot.subsystems.coral.CoralSubsystem;
import frc.robot.subsystems.drive.DriveSubsystem;
import frc.robot.subsystems.elevator.ElevatorSubsystem;
import frc.robot.subsystems.robotState.RobotStateSubsystem;
import frc.robot.subsystems.robotState.RobotStateSubsystem.RobotStates;

public class ReefCycleCommand extends Command {
private RobotStateSubsystem robotStateSubsystem;
private ElevatorSubsystem elevatorSubsystem;
private DriveSubsystem driveSubsystem;
private RobotStates startingRobotState;
private boolean startingElevatorFinished;
private boolean isAutoPlacing;
Expand All @@ -23,14 +25,16 @@ public ReefCycleCommand(
AlgaeSubsystem algaeSubsystem) {
this.robotStateSubsystem = robotStateSubsystem;
this.elevatorSubsystem = elevatorSubsystem;

addRequirements(elevatorSubsystem, coralSubsystem, biscuitSubsystem, algaeSubsystem);
}

@Override
public void initialize() {
startingRobotState = robotStateSubsystem.getState();
startingElevatorFinished = elevatorSubsystem.isFinished();
isAutoPlacing = robotStateSubsystem.getAutoPlaceOnCycle();
isAutoPlacing = robotStateSubsystem.getIsAutoPlacing();

robotStateSubsystem.toPrepCoral();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public boolean isFinished() {
} else {
return robotStateSubsystem.getState() == RobotStates.BARGE_ALGAE
|| robotStateSubsystem.getState() == RobotStates.PROCESSOR_ALGAE
|| !robotStateSubsystem.isBargeSafe;
|| !robotStateSubsystem.getIsBargeSafe();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ScoreReefManualCommand(
public void initialize() {
startingRobotState = robotStateSubsystem.getState();
startingElevatorFinished = elevatorSubsystem.isFinished();
robotStateSubsystem.setAutoPlaceOnCycle(false);
robotStateSubsystem.setIsAutoPlacing(false);
robotStateSubsystem.setGetAlgaeOnCycle(false);
robotStateSubsystem.toPrepCoral();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package frc.robot.commands.robotState;

import edu.wpi.first.wpilibj2.command.InstantCommand;
import frc.robot.subsystems.robotState.RobotStateSubsystem;
import frc.robot.subsystems.robotState.RobotStateSubsystem.ScoreSide;

public class SetScoreSideCommand extends InstantCommand {
private RobotStateSubsystem robotState;
private ScoreSide side;

public SetScoreSideCommand(RobotStateSubsystem robotState, ScoreSide side) {
this.robotState = robotState;
this.side = side;
}

@Override
public void initialize() {
robotState.setScoreSide(side);
}
}
6 changes: 4 additions & 2 deletions src/main/java/frc/robot/commands/robotState/StowCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package frc.robot.commands.robotState;

import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.algae.AlgaeSubsystem;
import frc.robot.subsystems.biscuit.BiscuitSubsystem;
import frc.robot.subsystems.coral.CoralSubsystem;
import frc.robot.subsystems.elevator.ElevatorSubsystem;
Expand All @@ -14,9 +15,10 @@ public StowCommand(
RobotStateSubsystem robotState,
ElevatorSubsystem elevatorSubsystem,
CoralSubsystem coralSubsystem,
BiscuitSubsystem biscuitSubsystem) {
BiscuitSubsystem biscuitSubsystem,
AlgaeSubsystem algaeSubsystem) {
this.robotState = robotState;
addRequirements(elevatorSubsystem, coralSubsystem, biscuitSubsystem);
addRequirements(elevatorSubsystem, coralSubsystem, biscuitSubsystem, algaeSubsystem);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
import frc.robot.subsystems.robotState.RobotStateSubsystem;

public class ToggleAutoCommand extends InstantCommand {
RobotStateSubsystem robotState;
private RobotStateSubsystem robotStateSubsystem;

public ToggleAutoCommand(RobotStateSubsystem robotState) {
this.robotState = robotState;
this.robotStateSubsystem = robotState;
}

@Override
public void initialize() {
if (robotState.getAutoPlaceOnCycle() == false) {
robotState.setAutoPlaceOnCycle(true);
} else {
robotState.setAutoPlaceOnCycle(false);
}
robotStateSubsystem.setIsAutoPlacing(!robotStateSubsystem.getIsAutoPlacing());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public ToggleGetAlgaeCommand(RobotStateSubsystem robotStateSubsystem) {

@Override
public void initialize() {
robotStateSubsystem.ToggleGetAlgaeOnCycle();
robotStateSubsystem.toggleGetAlgaeOnCycle();
}
}
26 changes: 26 additions & 0 deletions src/main/java/frc/robot/commands/tagAlign/TagAlignCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package frc.robot.commands.tagAlign;

import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.subsystems.drive.DriveSubsystem;
import frc.robot.subsystems.tagAlign.TagAlignSubsystem;
import frc.robot.subsystems.tagAlign.TagAlignSubsystem.TagAlignStates;

public class TagAlignCommand extends Command {
private TagAlignSubsystem tagAlignSubsystem;

public TagAlignCommand(TagAlignSubsystem tagAlignSubsystem, DriveSubsystem driveSubsystem) {
this.tagAlignSubsystem = tagAlignSubsystem;
addRequirements(driveSubsystem);
}

@Override
public void initialize() {
tagAlignSubsystem.start(Alliance.Blue, true);
}

@Override
public boolean isFinished() {
return tagAlignSubsystem.getState() == TagAlignStates.DONE;
}
}
12 changes: 7 additions & 5 deletions src/main/java/frc/robot/constants/BiscuitConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public class BiscuitConstants {
public static final double kTicksPerRot = 160;
public static final int talonID = 25;
public static final double kCloseEnough = 0.05;
public static final Angle kMaxFwd = Rotations.of(51.04735 + 5);
public static final Angle kMaxRev = Rotations.of(-12.3489 - 5);
public static final double kSafeToStowUpper = 40;
public static final double kSafeToStowLower = -5;

Expand All @@ -40,11 +38,11 @@ public class BiscuitConstants {
public static final Angle kPrestageSetpoint = kStowSetpoint;

// Algae removal
public static final Angle kL2AlgaeSetpoint = Rotations.of(20.848);
public static final Angle kL2AlgaeSetpoint = Rotations.of(24.104);
public static final Angle kL3AlgaeSetpoint = Rotations.of(24.562);

public static final Angle kL2AlgaeRemovalSetpoint = Rotations.of(0.0);
public static final Angle kL3AlgaeRemovalSetpoint = Rotations.of(0.0);
public static final Angle kL2AlgaeRemovalSetpoint = kStowSetpoint;
public static final Angle kL3AlgaeRemovalSetpoint = kStowSetpoint;

// Coral score
public static final Angle kL1CoralSetpoint = kStowSetpoint;
Expand All @@ -66,6 +64,10 @@ public class BiscuitConstants {
public static final double kJogAmountUp = 10;
public static final double kJogAmountDown = -10;

// Soft Limits
public static final Angle kMaxFwd = kMicAlgaeSetpoint.plus(Rotations.of(5));
public static final Angle kMaxRev = kBargeBackwardSetpoint.minus(Rotations.of(5));

// Disables the TalonFXS by setting its voltage to zero.
public static VoltageConfigs disableTalon() {
VoltageConfigs voltage =
Expand Down
Loading