1818import edu .wpi .first .math .geometry .Translation2d ;
1919import edu .wpi .first .math .geometry .Translation3d ;
2020import edu .wpi .first .math .kinematics .ChassisSpeeds ;
21+ import edu .wpi .first .math .util .Units ;
2122import edu .wpi .first .wpilibj2 .command .SubsystemBase ;
2223
2324public class GamePieceSim extends SubsystemBase {
@@ -95,10 +96,10 @@ public void periodic () {
9596 );
9697 } else if (this .coralTransform .getX () > 0.130 ) {
9798
98- this .coralTransform = this .project (this .coralTransform , this .coralIntakeVelocitySupplier .get () * 0.02 , new Rotation3d (0.0 , 30.0 * ( Math . PI / 180 .0 ), 0.0 ));
99+ this .coralTransform = this .project (this .coralTransform , this .coralIntakeVelocitySupplier .get () * 0.02 , new Rotation3d (0.0 , Units . degreesToRadians ( 30 .0 ), 0.0 ));
99100 } else {
100101
101- this .coralTransform = this .project (this .coralTransform , this .funnelVelocitySupplier .get () * 0.02 , new Rotation3d (0.0 , 30.0 * ( Math . PI / 180 .0 ), 0.0 ));
102+ this .coralTransform = this .project (this .coralTransform , this .funnelVelocitySupplier .get () * 0.02 , new Rotation3d (0.0 , Units . degreesToRadians ( 30 .0 ), 0.0 ));
102103 }
103104 } else {
104105
@@ -115,13 +116,13 @@ public void periodic () {
115116
116117 if (this .coralTransform .getZ () > 0.178 ) {
117118
118- this .coralTransform = this .project (this .coralTransform , this .fallingVelocity * 0.02 , new Rotation3d (0.0 , 30.0 * ( Math . PI / 180 .0 ), 0.0 ));
119- this .coralTransform = this .project (this .coralTransform , this .fallingGravity * 0.02 , new Rotation3d (0.0 , 90.0 * ( Math . PI / 180 .0 ), 0.0 ));
119+ this .coralTransform = this .project (this .coralTransform , this .fallingVelocity * 0.02 , new Rotation3d (0.0 , Units . degreesToRadians ( 30 .0 ), 0.0 ));
120+ this .coralTransform = this .project (this .coralTransform , this .fallingGravity * 0.02 , new Rotation3d (0.0 , Units . degreesToRadians ( 90 .0 ), 0.0 ));
120121 this .fallingGravity += (9.8 * 0.02 );
121122 } else {
122123
123124 this .coralStatus = CoralStatus .STUCK ;
124- this .coralTransform = new Transform3d (new Translation3d (0.216 , 0.0 , 0.076 ), new Rotation3d (0.0 , 0.0 , Math . PI / 2.0 ));
125+ this .coralTransform = new Transform3d (new Translation3d (0.216 , 0.0 , 0.076 ), new Rotation3d (0.0 , 0.0 , Units . degreesToRadians ( 90.0 ) ));
125126 }
126127 }
127128
@@ -133,31 +134,38 @@ public void periodic () {
133134
134135 if (this .coralStatus == CoralStatus .INDEXING ) {
135136
136- Translation3d elevatorTranslation = new Translation3d (0 , 0 , this .elevatorHeightSupplier .get () - 0.139 );
137+ Translation3d elevatorTranslation = new Translation3d (0.0 , 0. 0 , this .elevatorHeightSupplier .get () - 0.139 );
137138 transform = transform .plus (new Transform3d (elevatorTranslation , new Rotation3d ()));
138139 }
139140
140141 coral .add (new Pose3d (this .robotPoseSupplier .get ()).plus (transform ));
141142 }
142143
143144 Logger .recordOutput ("Visualization/Coral" , coral .toArray (new Pose3d [0 ]));
145+ Logger .recordOutput ("Visualization/Algae" , SimulatedArena .getInstance ().getGamePiecesArrayByType ("Algae" ));
144146 }
145147
146- public void loadFunnel () {
148+ public void loadCoral () {
147149
148150 if (this .coralStatus == null ) {
149151
150152 this .coralStatus = CoralStatus .FUNNELING ;
151- this .coralTransform = new Transform3d (new Translation3d (-0.145 , 0.0 , 0.495 ), new Rotation3d (0.0 , 30.0 * ( Math . PI / 180 .0 ), 0.0 ));
153+ this .coralTransform = new Transform3d (new Translation3d (-0.145 , 0.0 , 0.495 ), new Rotation3d (0.0 , Units . degreesToRadians ( 30 .0 ), 0.0 ));
152154 }
153155 }
154156
157+ public void preloadCoral () {
158+
159+ this .coralStatus = CoralStatus .INDEXING ;
160+ this .coralTransform = new Transform3d (new Translation3d (0.214 , 0.0 , 0.269 ), new Rotation3d (0.0 , Units .degreesToRadians (30.0 ), 0.0 ));
161+ }
162+
155163 public void removeCoral () {
156164
157165 this .coralStatus = null ;
158166 }
159167
160- public boolean getCoralBeambreak () {
168+ public static boolean getCoralBeambreak () {
161169
162170 return coralBeambreak ;
163171 }
0 commit comments