Skip to content

Commit 5489c24

Browse files
committed
healthcheck, elevator algae l2, climb pos and no safety, l2/3 coral eject slower
1 parent f976d6f commit 5489c24

File tree

13 files changed

+94
-20
lines changed

13 files changed

+94
-20
lines changed

src/main/java/frc/robot/RobotContainer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import frc.robot.commands.robotState.SetScoreSideRightCommand;
5353
import frc.robot.commands.robotState.SetScoringLevelCommand;
5454
import frc.robot.commands.robotState.StopAllAxisCommand;
55+
import frc.robot.commands.robotState.StopOpenLoopCommand;
5556
import frc.robot.commands.robotState.StowCommand;
5657
import frc.robot.commands.robotState.ToggleAlgaeHeightCommand;
5758
import frc.robot.commands.robotState.ToggleAutoPlacingCommand;
@@ -619,6 +620,7 @@ private void configurePitDashboard() {
619620
.add(
620621
"Health Check",
621622
new DepthChargeHealthCheckCommand(
623+
robotStateSubsystem,
622624
swerve,
623625
driveSubsystem,
624626
funnelIO,
@@ -633,6 +635,13 @@ private void configurePitDashboard() {
633635
biscuitSubsystem))
634636
.withPosition(6, 1)
635637
.withSize(1, 1);
638+
639+
Shuffleboard.getTab("Pit")
640+
.add(
641+
"Stop Open Loop",
642+
new StopOpenLoopCommand(robotStateSubsystem, coralSubsystem, funnelIO, algaeIO))
643+
.withPosition(7, 1)
644+
.withSize(1, 1);
636645
}
637646

638647
public void configTestDash() {
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
package frc.robot.commands.drive;
22

3-
import edu.wpi.first.wpilibj2.command.InstantCommand;
3+
import edu.wpi.first.wpilibj2.command.Command;
44
import frc.robot.subsystems.drive.DriveSubsystem;
55

6-
public class SpinUpWheelsCommand extends InstantCommand {
6+
public class SpinUpWheelsCommand extends Command {
77
private DriveSubsystem driveSubsystem;
88

99
public SpinUpWheelsCommand(DriveSubsystem driveSubsystem) {
1010
this.driveSubsystem = driveSubsystem;
11+
12+
addRequirements(driveSubsystem);
1113
}
1214

1315
@Override
1416
public void initialize() {
1517
driveSubsystem.setAzimuthVel(0.2);
1618
}
19+
20+
@Override
21+
public boolean isFinished() {
22+
return false;
23+
}
1724
}

src/main/java/frc/robot/commands/robotState/DepthChargeHealthCheckCommand.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package frc.robot.commands.robotState;
22

3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
34
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
45
import frc.robot.subsystems.algae.AlgaeIOFX;
56
import frc.robot.subsystems.algae.AlgaeSubsystem;
@@ -13,6 +14,8 @@
1314
import frc.robot.subsystems.elevator.ElevatorSubsystem;
1415
import frc.robot.subsystems.funnel.FunnelIOFXS;
1516
import frc.robot.subsystems.funnel.FunnelSubsystem;
17+
import frc.robot.subsystems.robotState.RobotStateSubsystem;
18+
import frc.robot.subsystems.robotState.RobotStateSubsystem.RobotStates;
1619
import java.util.List;
1720
import org.strykeforce.healthcheck.IOHealthCheckCommand;
1821

@@ -31,6 +34,7 @@ public class DepthChargeHealthCheckCommand extends SequentialCommandGroup {
3134
private BiscuitSubsystem biscuitSubsystem;
3235

3336
public DepthChargeHealthCheckCommand(
37+
RobotStateSubsystem robotStateSubsystem,
3438
SwerveFXS swerve,
3539
DriveSubsystem driveSubsystem,
3640
FunnelIOFXS funnelIOFXS,
@@ -59,6 +63,10 @@ public DepthChargeHealthCheckCommand(
5963

6064
addCommands(
6165
new ResetCaseHealthCheckCommand(),
66+
new InstantCommand(() -> robotStateSubsystem.setState(RobotStates.IDLE, false)),
67+
new InstantCommand(() -> coralSubsystem.healthCheck()),
68+
new InstantCommand(() -> funnelIOFXS.setPct(0)),
69+
new InstantCommand(() -> algaeIOFXS.setPct(0)),
6270
new IOHealthCheckCommand(
6371
List.of(
6472
driveSubsystem,
@@ -73,6 +81,12 @@ public DepthChargeHealthCheckCommand(
7381
algaeIOFXS,
7482
elevatorIOFX,
7583
biscuitIOFXS),
76-
new LockWheelsCommand(driveSubsystem));
84+
new LockWheelsCommand(driveSubsystem),
85+
new StowCommand(
86+
robotStateSubsystem,
87+
elevatorSubsystem,
88+
coralSubsystem,
89+
biscuitSubsystem,
90+
algaeSubsystem));
7791
}
7892
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package frc.robot.commands.robotState;
2+
3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
4+
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
5+
import frc.robot.subsystems.algae.AlgaeIOFX;
6+
import frc.robot.subsystems.coral.CoralSubsystem;
7+
import frc.robot.subsystems.funnel.FunnelIOFXS;
8+
import frc.robot.subsystems.robotState.RobotStateSubsystem;
9+
import frc.robot.subsystems.robotState.RobotStateSubsystem.RobotStates;
10+
11+
public class StopOpenLoopCommand extends SequentialCommandGroup {
12+
public StopOpenLoopCommand(
13+
RobotStateSubsystem robotStateSubsystem,
14+
CoralSubsystem coralSubsystem,
15+
FunnelIOFXS funnelIOFXS,
16+
AlgaeIOFX algaeIOFXS) {
17+
addCommands(
18+
new ResetCaseHealthCheckCommand(),
19+
new InstantCommand(() -> robotStateSubsystem.setState(RobotStates.IDLE, false)),
20+
new InstantCommand(() -> coralSubsystem.healthCheck()),
21+
new InstantCommand(() -> funnelIOFXS.setPct(0)),
22+
new InstantCommand(() -> algaeIOFXS.setPct(0)));
23+
}
24+
}

src/main/java/frc/robot/constants/ClimbConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ClimbConstants {
2929
public static int kCageAlignedDIOId = 11;
3030

3131
public static final double kPivotArmCloseEnough = 0.01; // fixme
32-
public static final double kArmMaxFwd = 0;
32+
public static final double kArmMaxFwd = 0.01;
3333
public static final double kArmMaxRev = -0.29;
3434
public static final Angle kArmZeroTicks = Degrees.of(1530);
3535

src/main/java/frc/robot/constants/ElevatorConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ElevatorConstants {
4242
// Idle
4343

4444
// Algae removal
45-
public static final Angle kL2AlgaeSetpoint = Rotations.of(6.308);
45+
public static final Angle kL2AlgaeSetpoint = Rotations.of(5.826); // was 6.308
4646
public static final Angle kL3AlgaeSetpoint = Rotations.of(17.513);
4747

4848
public static final Angle kL2AlgaeRemovalSetpoint = kL2AlgaeSetpoint;

src/main/java/frc/robot/subsystems/algae/AlgaeIOFX.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class AlgaeIOFX implements AlgaeIO, Checkable {
2323

2424
@HealthCheck
2525
@Timed(
26-
percentOutput = {-0.1, -1},
26+
percentOutput = {0.5, 0.04, -1},
2727
duration = 2)
2828
private TalonFXS talonFXS;
2929

src/main/java/frc/robot/subsystems/biscuit/BiscuitIOFXS.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ public class BiscuitIOFXS implements BiscuitIO, Checkable {
3232

3333
@HealthCheck
3434
@Position(
35-
percentOutput = {-0.1, 0.1},
36-
encoderChange = 40)
35+
percentOutput = {0.05, -0.10},
36+
encoderChange = 20)
3737
private TalonFXS talon;
3838

3939
private final Angle sensorInitial;
@@ -48,7 +48,7 @@ public class BiscuitIOFXS implements BiscuitIO, Checkable {
4848
private Alert rangeAlert = new Alert("Biscuit overextended! Shuting down!", AlertType.kError);
4949
private boolean lastHadAlgae = false;
5050

51-
TalonFXSConfigurator configurator;
51+
private TalonFXSConfigurator configurator;
5252
private MotionMagicDutyCycle positionRequest =
5353
new MotionMagicDutyCycle(0).withEnableFOC(false).withFeedForward(0);
5454

@@ -133,7 +133,8 @@ public String getName() {
133133

134134
@BeforeHealthCheck
135135
@AfterHealthCheck
136-
public void healthCheckPos() {
136+
public boolean healthCheckPos() {
137137
setPosition(Rotations.of(0), false);
138+
return Math.abs(position.refresh().getValueAsDouble()) < BiscuitConstants.kCloseEnough;
138139
}
139140
}

src/main/java/frc/robot/subsystems/coral/CoralSubsystem.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import edu.wpi.first.units.measure.AngularVelocity;
66
import frc.robot.constants.CoralConstants;
77
import frc.robot.standards.ClosedLoopSpeedSubsystem;
8+
import frc.robot.subsystems.robotState.RobotStateSubsystem.ScoringLevel;
89
import java.util.Set;
910
import org.littletonrobotics.junction.Logger;
1011
import org.slf4j.LoggerFactory;
@@ -99,10 +100,14 @@ public void intake() {
99100
setState(CoralState.INTAKING);
100101
}
101102

102-
public void eject() {
103+
public void eject(ScoringLevel level) {
103104
io.enableFwdLimitSwitch(false);
104105
// setSpeed(CoralConstants.kEjectingSpeed);
105-
setPct(1);
106+
107+
switch (level) {
108+
case L1, L2, L3 -> setPct(0.8);
109+
case L4 -> setPct(1);
110+
}
106111
setState(CoralState.EJECTING);
107112
}
108113

@@ -152,6 +157,11 @@ public Set<Measure> getMeasures() {
152157
return Set.of(new Measure("State", () -> curState.ordinal()));
153158
}
154159

160+
public void healthCheck() {
161+
setState(CoralState.IDLE);
162+
setPct(0);
163+
}
164+
155165
public enum CoralState {
156166
IDLE,
157167
HAS_CORAL,

src/main/java/frc/robot/subsystems/elevator/ElevatorIOFX.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package frc.robot.subsystems.elevator;
22

3+
import static edu.wpi.first.units.Units.Rotations;
4+
35
import com.ctre.phoenix6.BaseStatusSignal;
46
import com.ctre.phoenix6.StatusSignal;
57
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
@@ -28,7 +30,7 @@ public class ElevatorIOFX implements ElevatorIO, Checkable {
2830

2931
@HealthCheck
3032
@Position(
31-
percentOutput = {-0.1, 0.1},
33+
percentOutput = {-0.05, 0.1},
3234
encoderChange = 10)
3335
private TalonFX talonFxFront;
3436

@@ -118,8 +120,12 @@ public void zero() {
118120

119121
@BeforeHealthCheck
120122
@AfterHealthCheck
121-
public void healthCheckPos() {
123+
public boolean healthCheckPos() {
122124
setPosition(ElevatorConstants.kHealthCheck);
125+
return Math.abs(
126+
currPosition.refresh().getValueAsDouble()
127+
- ElevatorConstants.kHealthCheck.in(Rotations))
128+
< ElevatorConstants.kCloseEnoughRotations;
123129
}
124130

125131
@Override

0 commit comments

Comments
 (0)