@@ -47,7 +47,7 @@ public class Odometry extends Subsystem {
47
47
private final Field2d field ;
48
48
49
49
/** List of functions to be called when pose is manually updated. */
50
- private final List <Consumer <Pose2d >> poseUpdateConsumers ;
50
+ private final List <Consumer <Rotation2d >> yawUpdateConsumers ;
51
51
52
52
/** Creates a new instance of the odometry subsystem. */
53
53
private Odometry () {
@@ -73,7 +73,7 @@ private Odometry() {
73
73
74
74
field = new Field2d ();
75
75
76
- poseUpdateConsumers = new ArrayList <Consumer <Pose2d >>();
76
+ yawUpdateConsumers = new ArrayList <Consumer <Rotation2d >>();
77
77
}
78
78
79
79
/**
@@ -110,7 +110,8 @@ public void addToShuffleboard(ShuffleboardTab tab) {
110
110
111
111
position .addDouble ("X (m)" , () -> getPosition ().getX ());
112
112
position .addDouble ("Y (m)" , () -> getPosition ().getY ());
113
- position .addDouble ("Rotation (deg)" , () -> getPosition ().getRotation ().getDegrees ());
113
+ position .addDouble ("Field Rotation (deg)" , () -> getFieldRelativeHeading ().getDegrees ());
114
+ position .addDouble ("Driver Rotation (deg)" , () -> getDriverRelativeHeading ().getDegrees ());
114
115
115
116
ShuffleboardLayout velocity = Telemetry .addColumn (tab , "Velocity" );
116
117
@@ -150,13 +151,7 @@ public Rotation2d getFieldRelativeHeading() {
150
151
* alliance.
151
152
*/
152
153
public Rotation2d getDriverRelativeHeading () {
153
- Rotation2d fieldRelativeHeading = getFieldRelativeHeading ();
154
-
155
- if (AllianceFlipHelper .shouldFlip ()) {
156
- return fieldRelativeHeading .plus (Rotation2d .fromDegrees (180 ));
157
- }
158
-
159
- return fieldRelativeHeading ;
154
+ return Rotation2d .fromRotations (gyroscopeValues .yawRotations );
160
155
}
161
156
162
157
/**
@@ -187,25 +182,21 @@ public void setRotation(Rotation2d rotation) {
187
182
*
188
183
* @param consumer consumer for when pose is manually updated.
189
184
*/
190
- public void onPoseUpdate (Consumer <Pose2d > consumer ) {
191
- poseUpdateConsumers .add (consumer );
185
+ public void onYawUpdate (Consumer <Rotation2d > consumer ) {
186
+ yawUpdateConsumers .add (consumer );
192
187
}
193
188
194
189
/**
195
- * Tares the rotation of the robot.
190
+ * Zeroes the driver-relative rotation of the robot.
196
191
*
197
- * @return a command that zeroes the rotation of the robot.
192
+ * @return a command that zeroes the driver-relative rotation of the robot.
198
193
*/
199
194
public Command tare () {
200
195
return Commands .runOnce (
201
196
() -> {
202
- if (AllianceFlipHelper .shouldFlip ()) {
203
- setRotation (Rotation2d .fromDegrees (180 ));
204
- } else {
205
- setRotation (Rotation2d .fromDegrees (0 ));
206
- }
197
+ gyroscope .setYaw (0.0 );
207
198
208
- poseUpdateConsumers .forEach (consumer -> consumer .accept (getPosition ( )));
199
+ yawUpdateConsumers .forEach (consumer -> consumer .accept (Rotation2d . fromDegrees ( 0 )));
209
200
});
210
201
}
211
202
0 commit comments