Skip to content

Commit cfccccf

Browse files
authored
Merge pull request #14 from strykeforce/robot-state
Initial Robot State Subsystem
2 parents 47a5373 + e7110c5 commit cfccccf

File tree

12 files changed

+820
-21
lines changed

12 files changed

+820
-21
lines changed

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,44 @@
1919
import edu.wpi.first.units.measure.Angle;
2020

2121
public class BiscuitConstants {
22-
// FIXME These are all wrong right now because we don't have any actual info
22+
// These are all wrong right now because we don't have any actual info
2323

2424
public static Angle kZero = Rotations.of(42); // Will need to be experimentally determined
2525
public static int talonID = 3;
2626
public static double kCloseEnough = 2137473647; // This is a little out of wack.
2727
public static final Angle kMaxFwd = Rotations.of(100);
2828
public static final Angle kMaxRev = Rotations.of(-100);
29-
// public static Angle Level1 = ;
29+
30+
// Setpoints
31+
// Idle
32+
public static final Angle kStowSetpoint = Rotations.of(0.0);
33+
public static final Angle kFunnelSetpoint = Rotations.of(0.0);
34+
public static final Angle kPrestageSetpoint = Rotations.of(0.0);
35+
36+
// Algae removal
37+
public static final Angle kL2AlgaeSetpoint = Rotations.of(0.0);
38+
public static final Angle kL3AlgaeSetpoint = Rotations.of(0.0);
39+
40+
public static final Angle kL2AlgaeRemovalSetpoint = Rotations.of(0.0);
41+
public static final Angle kL3AlgaeRemovalSetpoint = Rotations.of(0.0);
42+
43+
public static final Angle kSafeAlgaeRemovalSetpoint = Rotations.of(0.0);
44+
public static final Angle kSafeAlgaeRemovalRotateSetpoint = Rotations.of(0.0);
45+
46+
// Coral score
47+
public static final Angle kL1CoralSetpoint = Rotations.of(0.0);
48+
public static final Angle kL2CoralSetpoint = Rotations.of(0.0);
49+
public static final Angle kL3CoralSetpoint = Rotations.of(0.0);
50+
public static final Angle kL4CoralSetpoint = Rotations.of(0.0);
51+
52+
// Algae obtaining
53+
public static final Angle kFloorAlgaeSetpoint = Rotations.of(0.0);
54+
public static final Angle kMicAlgaeSetpoint = Rotations.of(0.0);
55+
public static final Angle kHpAlgaeSetpoint = Rotations.of(0.0);
56+
57+
// Algae scoring
58+
public static final Angle kProcessorSetpoint = Rotations.of(0.0);
59+
public static final Angle kBargeSetpoint = Rotations.of(0.0);
3060

3161
// Disables the TalonFXS by setting it's voltage to zero. Not very shocking.
3262
public static VoltageConfigs disableTalon() {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import edu.wpi.first.math.geometry.Translation2d;
1414

1515
public class DriveConstants {
16+
public static final double kAlgaeRemovalSpeed = 0;
17+
1618
public static final double kDeadbandAllStick = 0.075;
1719
public static final double kExpoScaleYawFactor = 0.75;
1820
public static final double kRateLimitFwdStr = 3.5;

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

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package frc.robot.constants;
22

3+
import static edu.wpi.first.units.Units.Rotations;
4+
35
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
46
import com.ctre.phoenix6.configs.HardwareLimitSwitchConfigs;
57
import com.ctre.phoenix6.configs.MotionMagicConfigs;
@@ -14,14 +16,15 @@
1416
import com.ctre.phoenix6.signals.NeutralModeValue;
1517
import com.ctre.phoenix6.signals.ReverseLimitSourceValue;
1618
import com.ctre.phoenix6.signals.ReverseLimitTypeValue;
19+
import edu.wpi.first.units.measure.Angle;
1720

1821
public class ElevatorConstants {
1922

2023
public static final double kCloseEnoughRotations = 0.0083;
2124
public static final double kMaxFwd = 0; // TODO all of these fields need to be filled out
2225
public static final double kMaxRev = 0;
2326
public static final int kZeroMultiple =
24-
0; // some constant to multiply, add by to turn the analog input into a position
27+
0; // some constant to multiply, add by to turn the analog input into a position
2528
public static final double kZeroSpeed = -.05;
2629
public static final int kZeroCounter = 3;
2730
public static final double kZeroedThreshhold = .0001;
@@ -32,6 +35,37 @@ public class ElevatorConstants {
3235

3336
public static final double kJogAmount = 0.1;
3437

38+
// Setpoints
39+
// Idle
40+
public static final Angle kStowSetpoint = Rotations.of(0.0);
41+
public static final Angle kFunnelSetpoint = Rotations.of(0.0);
42+
public static final Angle kPrestageSetpoint = Rotations.of(0.0);
43+
44+
// Algae removal
45+
public static final Angle kL2AlgaeSetpoint = Rotations.of(0.0);
46+
public static final Angle kL3AlgaeSetpoint = Rotations.of(0.0);
47+
48+
public static final Angle kL2AlgaeRemovalSetpoint = Rotations.of(0.0);
49+
public static final Angle kL3AlgaeRemovalSetpoint = Rotations.of(0.0);
50+
51+
public static final Angle kSafeAlgaeRemovalSetpoint = Rotations.of(0.0);
52+
public static final Angle kSafeAlgaeRemovalRotateSetpoint = Rotations.of(0.0);
53+
54+
// Coral score
55+
public static final Angle kL1CoralSetpoint = Rotations.of(0.0);
56+
public static final Angle kL2CoralSetpoint = Rotations.of(0.0);
57+
public static final Angle kL3CoralSetpoint = Rotations.of(0.0);
58+
public static final Angle kL4CoralSetpoint = Rotations.of(0.0);
59+
60+
// Algae obtaining
61+
public static final Angle kFloorAlgaeSetpoint = Rotations.of(0.0);
62+
public static final Angle kMicAlgaeSetpoint = Rotations.of(0.0);
63+
public static final Angle kHpAlgaeSetpoint = Rotations.of(0.0);
64+
65+
// Algae scoring
66+
public static final Angle kProcessorSetpoint = Rotations.of(0.0);
67+
public static final Angle kBargeSetpoint = Rotations.of(0.0);
68+
3569
public static TalonFXConfiguration getBothFXConfig() {
3670
TalonFXConfiguration fxConfig = new TalonFXConfiguration();
3771

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
public class RobotStateConstants {
44
public static final double[] kNodeAngles = {0.0, 60.0, 120.0, 180.0, -120.0, -60.0};
5+
public static final double kAlgaeRetreatDistance = 0;
6+
7+
public static final double kRedBargeSafeX = 9.5;
8+
public static final double kBlueBargeSafeX = 8;
59
}
Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
package frc.robot.subsystems.algae;
22

3-
public class AlgaeSubsystem {}
3+
public class AlgaeSubsystem {
4+
5+
public static final String kStowSpeed = null;
6+
7+
public boolean hasAlgae() {
8+
// TODO Auto-generated method stub
9+
throw new UnsupportedOperationException("Unimplemented method 'hasAlgae'");
10+
}
11+
12+
public void intake() {
13+
// TODO Auto-generated method stub
14+
throw new UnsupportedOperationException("Unimplemented method 'intake'");
15+
}
16+
17+
public void scoreProcessor() {
18+
// TODO Auto-generated method stub
19+
throw new UnsupportedOperationException("Unimplemented method 'scoreProcessor'");
20+
}
21+
22+
public void scoreBarge() {
23+
// TODO Auto-generated method stub
24+
throw new UnsupportedOperationException("Unimplemented method 'scoreBarge'");
25+
}
26+
}

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,47 @@
44

55
import static edu.wpi.first.units.Units.Rotations;
66

7-
import edu.wpi.first.units.measure.*;
7+
import edu.wpi.first.units.measure.Angle;
8+
import edu.wpi.first.units.measure.AngularVelocity;
89
import frc.robot.constants.BiscuitConstants;
10+
import frc.robot.standards.ClosedLoopPosSubsystem;
911
import java.util.Set;
1012
import org.littletonrobotics.junction.Logger;
1113
import org.strykeforce.telemetry.TelemetryService;
1214
import org.strykeforce.telemetry.measurable.MeasurableSubsystem;
1315
import org.strykeforce.telemetry.measurable.Measure;
1416

15-
public class BiscuitSubsystem extends MeasurableSubsystem {
17+
public class BiscuitSubsystem extends MeasurableSubsystem implements ClosedLoopPosSubsystem {
1618

1719
private BiscuitIO io;
1820
private BiscuitIOInputsAutoLogged inputs = new BiscuitIOInputsAutoLogged();
1921
private Angle setPoint;
2022

23+
@Override
2124
public void setPosition(Angle position) {
2225
io.setPosition(position);
2326
setPoint = position;
2427
}
2528

26-
public Angle getPosition(Angle position) {
29+
@Override
30+
public Angle getPosition() {
2731
return inputs.position;
2832
}
2933

3034
public AngularVelocity getVelocity(AngularVelocity velocity) {
3135
return inputs.velocity;
3236
}
3337

38+
@Override
39+
public void zero() {
40+
io.zero();
41+
}
42+
43+
@Override
44+
public boolean isFinished() {
45+
return setPoint.minus(inputs.position).abs(Rotations) < BiscuitConstants.kCloseEnough;
46+
}
47+
3448
@Override
3549
public void periodic() {
3650
io.updateInputs(inputs);
@@ -45,18 +59,10 @@ public void registerWith(TelemetryService telemetry) {
4559
io.registerWith(telemetry);
4660
}
4761

48-
public boolean isFinished() {
49-
return setPoint.minus(inputs.position).abs(Rotations) <= BiscuitConstants.kCloseEnough;
50-
}
51-
5262
@Override
5363
public Set<Measure> getMeasures() {
5464
return Set.of(
5565
new Measure("Is Biscuit Finished", () -> isFinished() ? 1.0 : 0.0),
5666
new Measure("Biscuit Set Point", () -> setPoint.in(Rotations)));
5767
}
58-
59-
public void zero() {
60-
io.zero();
61-
}
6268
}
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
11
package frc.robot.subsystems.climb;
22

3-
public class ClimbSubsystem {}
3+
public class ClimbSubsystem {
4+
5+
public boolean isFinished() {
6+
// TODO Auto-generated method stub
7+
throw new UnsupportedOperationException("Unimplemented method 'isFinished'");
8+
}
9+
10+
public void prepClimb() {
11+
// TODO Auto-generated method stub
12+
throw new UnsupportedOperationException("Unimplemented method 'prepClimb'");
13+
}
14+
15+
public void climb() {
16+
// TODO Auto-generated method stub
17+
throw new UnsupportedOperationException("Unimplemented method 'climb'");
18+
}
19+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ public boolean isExitBeamBroken() {
6565
return inputs.isRevBeamBroken;
6666
}
6767

68+
public boolean hasCoral() {
69+
switch (curState) {
70+
case CORAL_LOADING, HAS_CORAL, EJECTING -> {
71+
return true;
72+
}
73+
default -> {
74+
return false;
75+
}
76+
}
77+
}
78+
6879
public void intake() {
6980
io.enableRevLimitSwitch(true);
7081
setSpeed(CoralConstants.kIntakingSpeed);

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public ElevatorIOFX() {
5555
public void updateInputs(ElevatorIOInputs inputs) {
5656
BaseStatusSignal.refreshAll(currVelocity, currPosition);
5757
inputs.velocity = currVelocity.getValueAsDouble();
58-
inputs.position =
59-
currPosition
60-
.getValueAsDouble();
58+
inputs.position = currPosition.getValueAsDouble();
6159
}
6260

6361
@Override
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package frc.robot.subsystems.funnel;
2+
3+
public class FunnelSubsystem {
4+
5+
public boolean hasCoral() {
6+
// TODO Auto-generated method stub
7+
throw new UnsupportedOperationException("Unimplemented method 'hasCoral'");
8+
}
9+
}

0 commit comments

Comments
 (0)