@@ -53,7 +53,7 @@ public class DriveSubsystem extends SubsystemBase {
53
53
NetworkTable nt4Table = nt4Instance .getTable ("oculus" );
54
54
private IntegerSubscriber questMiso = nt4Table .getIntegerTopic ("miso" ).subscribe (0 );
55
55
private IntegerPublisher questMosi = nt4Table .getIntegerTopic ("mosi" ).publish ();
56
-
56
+
57
57
// Subscribe to the Network Tables oculus data topics
58
58
private IntegerSubscriber questFrameCount = nt4Table .getIntegerTopic ("frameCount" ).subscribe (0 );
59
59
private DoubleSubscriber questTimestamp = nt4Table .getDoubleTopic ("timestamp" ).subscribe (0.0f );
@@ -142,7 +142,7 @@ public void resetOdometry(Pose2d pose) {
142
142
* @param rateLimit Whether to enable rate limiting for smoother control.
143
143
*/
144
144
public void drive (double xSpeed , double ySpeed , double rot , boolean fieldRelative , boolean rateLimit ) {
145
-
145
+
146
146
double xSpeedCommanded ;
147
147
double ySpeedCommanded ;
148
148
@@ -158,7 +158,7 @@ public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelativ
158
158
} else {
159
159
directionSlewRate = 500.0 ; //some high number that means the slew rate is effectively instantaneous
160
160
}
161
-
161
+
162
162
163
163
double currentTime = WPIUtilJNI .now () * 1e-6 ;
164
164
double elapsedTime = currentTime - m_prevTime ;
@@ -182,7 +182,7 @@ else if (angleDif > 0.85*Math.PI) {
182
182
m_currentTranslationMag = m_magLimiter .calculate (0.0 );
183
183
}
184
184
m_prevTime = currentTime ;
185
-
185
+
186
186
xSpeedCommanded = m_currentTranslationMag * Math .cos (m_currentTranslationDir );
187
187
ySpeedCommanded = m_currentTranslationMag * Math .sin (m_currentTranslationDir );
188
188
m_currentRotation = m_rotLimiter .calculate (rot );
@@ -276,9 +276,7 @@ private float getOculusYaw() {
276
276
277
277
private Translation2d getOculusPosition () {
278
278
float [] oculusPosition = questPosition .get ();
279
- return new Translation2d (
280
- Math .sqrt (Math .pow (oculusPosition [0 ], 2 ) + Math .pow (oculusPosition [2 ], 2 )),
281
- Rotation2d .fromRadians (Math .atan (oculusPosition [0 ]*-1 /oculusPosition [2 ]))).unaryMinus ();
279
+ return new Translation2d (oculusPosition [2 ], -oculusPosition [0 ]);
282
280
}
283
281
284
282
private Pose2d getOculusPose () {
0 commit comments