Skip to content
This repository was archived by the owner on May 19, 2024. It is now read-only.

Commit 3325109

Browse files
authored
Merge pull request #35 from Gongoliers/3_18_2024_superstructure_state
3 18 2024 superstructure state
2 parents eb56cc2 + 6bef304 commit 3325109

21 files changed

+890
-861
lines changed

simgui-ds.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,10 @@
9898
],
9999
"robotJoysticks": [
100100
{
101-
"guid": "78696e70757401000000000000000000",
102101
"useGamepad": true
103102
},
104103
{
105-
"useGamepad": true
104+
"guid": "Keyboard0"
106105
}
107106
]
108107
}

simgui.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@
7777
},
7878
"Velocity": {
7979
"open": true
80-
},
81-
"open": true
80+
}
8281
},
8382
"Shooter": {
8483
"Flywheel": {
@@ -88,6 +87,18 @@
8887
"open": true
8988
}
9089
},
90+
"Superstructure": {
91+
"Goal": {
92+
"open": true
93+
},
94+
"Measurement": {
95+
"open": true
96+
},
97+
"open": true,
98+
"setpoint": {
99+
"open": true
100+
}
101+
},
91102
"Swerve": {
92103
"Constants": {
93104
"open": true

src/main/deploy/pathplanner/autos/amp.full.auto

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/main/deploy/pathplanner/autos/amp.shootLeave.auto

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,22 @@
1818
}
1919
},
2020
{
21-
"type": "named",
21+
"type": "deadline",
2222
"data": {
23-
"name": "shootNote"
23+
"commands": [
24+
{
25+
"type": "wait",
26+
"data": {
27+
"waitTime": 3.0
28+
}
29+
},
30+
{
31+
"type": "named",
32+
"data": {
33+
"name": "shootNote"
34+
}
35+
}
36+
]
2437
}
2538
},
2639
{

src/main/java/frc/robot/Robot.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ public void robotInit() {
1818
robotContainer = RobotContainer.getInstance();
1919
swerve = Swerve.getInstance();
2020

21-
// new Trigger(this::isEnabled).whileTrue(Arm.getInstance().home());
22-
2321
new Trigger(this::isDisabled)
2422
.debounce(RobotConstants.DISABLE_COAST_DELAY)
2523
.onTrue(Commands.runOnce(() -> swerve.setBrake(false), swerve).ignoringDisable(true));

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import frc.robot.intake.Intake;
1111
import frc.robot.odometry.Odometry;
1212
import frc.robot.shooter.Shooter;
13+
import frc.robot.superstructure.Superstructure;
1314
import frc.robot.swerve.Swerve;
1415

1516
/** Initializes subsystems and commands. */
@@ -24,6 +25,7 @@ public class RobotContainer {
2425
private final Intake intake;
2526
private final Odometry odometry;
2627
private final Shooter shooter;
28+
private final Superstructure superstructure;
2729
private final Swerve swerve;
2830

2931
private final CommandXboxController driverController, operatorController;
@@ -36,6 +38,7 @@ private RobotContainer() {
3638
intake = Intake.getInstance();
3739
odometry = Odometry.getInstance();
3840
shooter = Shooter.getInstance();
41+
superstructure = Superstructure.getInstance();
3942
swerve = Swerve.getInstance();
4043

4144
driverController = new CommandXboxController(0);
@@ -61,31 +64,26 @@ public static RobotContainer getInstance() {
6164

6265
/** Initializes subsystem telemetry. */
6366
private void initializeTelemetry() {
64-
Telemetry.initializeTabs(arm, auto, climber, intake, odometry, shooter, swerve);
67+
Telemetry.initializeTabs(arm, auto, climber, intake, odometry, shooter, superstructure, swerve);
6568
SmartDashboard.putData("Mechanism", RobotMechanisms.getInstance().getMechanism());
6669
}
6770

6871
/** Configures subsystem default commands. */
6972
private void configureDefaultCommands() {
70-
arm.setDefaultCommand(arm.stow());
71-
intake.setDefaultCommand(intake.stow());
7273
swerve.setDefaultCommand(swerve.driveWithController(driverController));
7374
}
7475

7576
/** Configures controller bindings. */
7677
private void configureBindings() {
77-
driverController.a().whileTrue(swerve.forwards());
78-
driverController.b().whileTrue(swerve.sideways());
79-
driverController.x().whileTrue(swerve.cross());
8078
driverController.y().onTrue(odometry.tare());
8179

82-
operatorController.leftTrigger().whileTrue(auto.intakePosition().andThen(auto.intakeNote()));
83-
operatorController.leftBumper().whileTrue(intake.unstow().andThen(intake.outtake()));
80+
operatorController.leftTrigger().onTrue(superstructure.intake());
81+
operatorController.rightTrigger().onTrue(superstructure.shoot());
8482

85-
operatorController.rightTrigger().whileTrue(auto.shootPosition().andThen(shooter.spin()));
86-
operatorController.rightBumper().whileTrue(shooter.serialize());
87-
88-
operatorController.a().whileTrue(arm.amp());
83+
operatorController.a().onTrue(superstructure.amp());
84+
operatorController.b().onTrue(superstructure.intake());
85+
operatorController.x().onTrue(superstructure.stow());
86+
operatorController.y().onTrue(superstructure.shoot());
8987
}
9088

9189
/**

src/main/java/frc/robot/RobotMechanisms.java

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import edu.wpi.first.wpilibj.util.Color8Bit;
1111
import frc.lib.InterpolatableColor;
1212
import frc.robot.arm.ArmConstants.ShoulderMotorConstants;
13-
import frc.robot.arm.ArmState;
1413
import frc.robot.intake.IntakeConstants.PivotMotorConstants;
1514
import frc.robot.intake.IntakeConstants.RollerMotorConstants;
1615
import frc.robot.shooter.ShooterConstants.FlywheelConstants;
1716
import frc.robot.shooter.ShooterConstants.SerializerConstants;
17+
import frc.robot.superstructure.SuperstructureState;
1818

1919
/** Helper class for rendering robot mechanisms. */
2020
public class RobotMechanisms {
@@ -23,7 +23,7 @@ public class RobotMechanisms {
2323

2424
private final Mechanism2d mechanism;
2525

26-
private MechanismLigament2d shoulder, shooter, serializer, intake;
26+
private MechanismLigament2d shoulder, flywheel, serializer, pivot;
2727

2828
private final double WIDTH =
2929
2
@@ -34,9 +34,12 @@ public class RobotMechanisms {
3434

3535
private final Translation2d ORIGIN = new Translation2d(WIDTH / 2, 0);
3636

37+
public static final Translation2d SHOULDER_TO_ORIGIN =
38+
new Translation2d(Units.inchesToMeters(-11.361), Units.inchesToMeters(7.721));
39+
3740
private final Color8Bit DEFAULT_COLOR = new Color8Bit(Color.kLightGray);
3841

39-
private final InterpolatableColor shooterColor =
42+
private final InterpolatableColor flywheelColor =
4043
new InterpolatableColor(Color.kLightGray, Color.kSalmon);
4144
private final InterpolatableColor serializerColor =
4245
new InterpolatableColor(Color.kLightGray, Color.kCornflowerBlue);
@@ -47,12 +50,13 @@ private RobotMechanisms() {
4750
mechanism = new Mechanism2d(WIDTH, HEIGHT);
4851

4952
initializeArmMechanism();
50-
initializeFramePerimeterMechanisms();
5153
initializeIntakeMechanism();
54+
55+
initializeFramePerimeterMechanisms();
5256
}
5357

5458
private void initializeArmMechanism() {
55-
Translation2d armRootTranslation = ORIGIN.plus(ShoulderMotorConstants.SHOULDER_TO_ORIGIN);
59+
Translation2d armRootTranslation = ORIGIN.plus(SHOULDER_TO_ORIGIN);
5660

5761
double armThickness = Units.inchesToMeters(2) * 100;
5862

@@ -67,7 +71,7 @@ private void initializeArmMechanism() {
6771
0,
6872
armThickness,
6973
DEFAULT_COLOR));
70-
shooter =
74+
flywheel =
7175
shoulder.append(
7276
new MechanismLigament2d(
7377
"wrist", Units.inchesToMeters(4.321), 0, armThickness, DEFAULT_COLOR));
@@ -103,7 +107,7 @@ private void initializeFramePerimeterMechanisms() {
103107
private void initializeIntakeMechanism() {
104108
double intakeThickness = Units.inchesToMeters(3) * 100;
105109

106-
intake =
110+
pivot =
107111
mechanism
108112
.getRoot(
109113
"intake",
@@ -126,9 +130,9 @@ public Mechanism2d getMechanism() {
126130
return mechanism;
127131
}
128132

129-
public void updateArm(ArmState state) {
130-
Rotation2d shoulderRotation = Rotation2d.fromRotations(state.shoulder().position);
131-
Rotation2d wristRotation = Rotation2d.fromRotations(state.wrist().position);
133+
public void updateSuperstructure(SuperstructureState state) {
134+
Rotation2d shoulderRotation = Rotation2d.fromRotations(state.shoulderAngleRotations().position);
135+
Rotation2d wristRotation = Rotation2d.fromRotations(state.wristAngleRotations().position);
132136

133137
shoulder.setAngle(shoulderRotation);
134138

@@ -138,32 +142,28 @@ public void updateArm(ArmState state) {
138142
Rotation2d shooterRotation = offsetWristRotation;
139143
Rotation2d serializerRotation = offsetWristRotation.plus(Rotation2d.fromDegrees(180));
140144

141-
shooter.setAngle(shooterRotation);
142-
serializer.setAngle(serializerRotation);
143-
}
144-
145-
public void updateIntake(Rotation2d pivotAngle, double rollerVelocityRotationsPerSecond) {
146-
Color color =
147-
intakeColor.sample(
148-
Math.abs(rollerVelocityRotationsPerSecond), 0, RollerMotorConstants.MAXIMUM_SPEED);
149-
150-
intake.setAngle(pivotAngle);
151-
intake.setColor(new Color8Bit(color));
152-
}
153-
154-
public void updateShooter(double velocityMetersPerSecond) {
155-
Color color =
156-
shooterColor.sample(
157-
Math.abs(velocityMetersPerSecond), 0, FlywheelConstants.MAXIMUM_TANGENTIAL_SPEED);
158-
159-
shooter.setColor(new Color8Bit(color));
160-
}
145+
pivot.setAngle(Rotation2d.fromRotations(state.pivotAngleRotations().position));
146+
pivot.setColor(
147+
new Color8Bit(
148+
intakeColor.sample(
149+
Math.abs(state.rollerVelocityRotationsPerSecond()),
150+
0,
151+
RollerMotorConstants.MAXIMUM_SPEED)));
161152

162-
public void updateSerializer(double velocityMetersPerSecond) {
163-
Color color =
164-
serializerColor.sample(
165-
Math.abs(velocityMetersPerSecond), 0, SerializerConstants.MAXIMUM_TANGENTIAL_SPEED);
153+
flywheel.setAngle(shooterRotation);
154+
flywheel.setColor(
155+
new Color8Bit(
156+
flywheelColor.sample(
157+
Math.abs(state.flywheelVelocityRotationsPerSecond()),
158+
0,
159+
FlywheelConstants.MAXIMUM_TANGENTIAL_SPEED)));
166160

167-
serializer.setColor(new Color8Bit(color));
161+
serializer.setAngle(serializerRotation);
162+
serializer.setColor(
163+
new Color8Bit(
164+
serializerColor.sample(
165+
Math.abs(state.serializerVelocityRotationsPerSecond()),
166+
0,
167+
SerializerConstants.MAXIMUM_TANGENTIAL_SPEED)));
168168
}
169169
}

0 commit comments

Comments
 (0)