10
10
import edu .wpi .first .wpilibj .util .Color8Bit ;
11
11
import frc .lib .InterpolatableColor ;
12
12
import frc .robot .arm .ArmConstants .ShoulderMotorConstants ;
13
- import frc .robot .arm .ArmState ;
14
13
import frc .robot .intake .IntakeConstants .PivotMotorConstants ;
15
14
import frc .robot .intake .IntakeConstants .RollerMotorConstants ;
16
15
import frc .robot .shooter .ShooterConstants .FlywheelConstants ;
17
16
import frc .robot .shooter .ShooterConstants .SerializerConstants ;
17
+ import frc .robot .superstructure .SuperstructureState ;
18
18
19
19
/** Helper class for rendering robot mechanisms. */
20
20
public class RobotMechanisms {
@@ -23,7 +23,7 @@ public class RobotMechanisms {
23
23
24
24
private final Mechanism2d mechanism ;
25
25
26
- private MechanismLigament2d shoulder , shooter , serializer , intake ;
26
+ private MechanismLigament2d shoulder , flywheel , serializer , pivot ;
27
27
28
28
private final double WIDTH =
29
29
2
@@ -34,9 +34,12 @@ public class RobotMechanisms {
34
34
35
35
private final Translation2d ORIGIN = new Translation2d (WIDTH / 2 , 0 );
36
36
37
+ public static final Translation2d SHOULDER_TO_ORIGIN =
38
+ new Translation2d (Units .inchesToMeters (-11.361 ), Units .inchesToMeters (7.721 ));
39
+
37
40
private final Color8Bit DEFAULT_COLOR = new Color8Bit (Color .kLightGray );
38
41
39
- private final InterpolatableColor shooterColor =
42
+ private final InterpolatableColor flywheelColor =
40
43
new InterpolatableColor (Color .kLightGray , Color .kSalmon );
41
44
private final InterpolatableColor serializerColor =
42
45
new InterpolatableColor (Color .kLightGray , Color .kCornflowerBlue );
@@ -47,12 +50,13 @@ private RobotMechanisms() {
47
50
mechanism = new Mechanism2d (WIDTH , HEIGHT );
48
51
49
52
initializeArmMechanism ();
50
- initializeFramePerimeterMechanisms ();
51
53
initializeIntakeMechanism ();
54
+
55
+ initializeFramePerimeterMechanisms ();
52
56
}
53
57
54
58
private void initializeArmMechanism () {
55
- Translation2d armRootTranslation = ORIGIN .plus (ShoulderMotorConstants . SHOULDER_TO_ORIGIN );
59
+ Translation2d armRootTranslation = ORIGIN .plus (SHOULDER_TO_ORIGIN );
56
60
57
61
double armThickness = Units .inchesToMeters (2 ) * 100 ;
58
62
@@ -67,7 +71,7 @@ private void initializeArmMechanism() {
67
71
0 ,
68
72
armThickness ,
69
73
DEFAULT_COLOR ));
70
- shooter =
74
+ flywheel =
71
75
shoulder .append (
72
76
new MechanismLigament2d (
73
77
"wrist" , Units .inchesToMeters (4.321 ), 0 , armThickness , DEFAULT_COLOR ));
@@ -103,7 +107,7 @@ private void initializeFramePerimeterMechanisms() {
103
107
private void initializeIntakeMechanism () {
104
108
double intakeThickness = Units .inchesToMeters (3 ) * 100 ;
105
109
106
- intake =
110
+ pivot =
107
111
mechanism
108
112
.getRoot (
109
113
"intake" ,
@@ -126,9 +130,9 @@ public Mechanism2d getMechanism() {
126
130
return mechanism ;
127
131
}
128
132
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 );
132
136
133
137
shoulder .setAngle (shoulderRotation );
134
138
@@ -138,32 +142,28 @@ public void updateArm(ArmState state) {
138
142
Rotation2d shooterRotation = offsetWristRotation ;
139
143
Rotation2d serializerRotation = offsetWristRotation .plus (Rotation2d .fromDegrees (180 ));
140
144
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 )));
161
152
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 )));
166
160
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 )));
168
168
}
169
169
}
0 commit comments