Skip to content

Commit 0393d31

Browse files
authored
Merge pull request #4 from ThadHouse/positionfix
2 parents 70f0726 + 8abfd07 commit 0393d31

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

java-robot/src/main/java/frc/robot/subsystems/DriveSubsystem.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class DriveSubsystem extends SubsystemBase {
5353
NetworkTable nt4Table = nt4Instance.getTable("oculus");
5454
private IntegerSubscriber questMiso = nt4Table.getIntegerTopic("miso").subscribe(0);
5555
private IntegerPublisher questMosi = nt4Table.getIntegerTopic("mosi").publish();
56-
56+
5757
// Subscribe to the Network Tables oculus data topics
5858
private IntegerSubscriber questFrameCount = nt4Table.getIntegerTopic("frameCount").subscribe(0);
5959
private DoubleSubscriber questTimestamp = nt4Table.getDoubleTopic("timestamp").subscribe(0.0f);
@@ -142,7 +142,7 @@ public void resetOdometry(Pose2d pose) {
142142
* @param rateLimit Whether to enable rate limiting for smoother control.
143143
*/
144144
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative, boolean rateLimit) {
145-
145+
146146
double xSpeedCommanded;
147147
double ySpeedCommanded;
148148

@@ -158,7 +158,7 @@ public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelativ
158158
} else {
159159
directionSlewRate = 500.0; //some high number that means the slew rate is effectively instantaneous
160160
}
161-
161+
162162

163163
double currentTime = WPIUtilJNI.now() * 1e-6;
164164
double elapsedTime = currentTime - m_prevTime;
@@ -182,7 +182,7 @@ else if (angleDif > 0.85*Math.PI) {
182182
m_currentTranslationMag = m_magLimiter.calculate(0.0);
183183
}
184184
m_prevTime = currentTime;
185-
185+
186186
xSpeedCommanded = m_currentTranslationMag * Math.cos(m_currentTranslationDir);
187187
ySpeedCommanded = m_currentTranslationMag * Math.sin(m_currentTranslationDir);
188188
m_currentRotation = m_rotLimiter.calculate(rot);
@@ -276,9 +276,7 @@ private float getOculusYaw() {
276276

277277
private Translation2d getOculusPosition() {
278278
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]);
282280
}
283281

284282
private Pose2d getOculusPose() {

0 commit comments

Comments
 (0)