Skip to content

Commit

Permalink
R: Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JJTech0130 committed Feb 9, 2024
1 parent b65229f commit 8c28beb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static double getMotorVelocityF(double ticksPerSecond) {
public static double X_MULTIPLIER = 1;
public static double Y_MULTIPLIER = 1;
public static double FORWARD_OFFSET = -3.0;
public static double LATERAL_DISTANCE = 16;
public static double LATERAL_DISTANCE = 16.083;
public static double DW_GEAR_RATIO = 1;
public static double DW_WHEEL_RADIUS = 0.944882;
public static double DW_TICKS_PER_REV = 2000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@ private class ServoCounter extends Thread {
private int count = 0;

public void run() {
android.util.Log.w("AXON_THREAD", "Starting thread");
double lastPosition = getCurrentPosition();
while (!GlobalOpMode.opMode.isStopRequested()) {
//android.util.Log.w("AXON_THREAD", "LOOP");
Thread.yield();
double currentPosition = getCurrentPosition();
// Positive wrap-around from 0 -> 360
if (currentPosition > 180 && lastPosition < 180 && innerServo.getPower() > 0) {
count--;
try {
android.util.Log.w("AXON_THREAD", "Starting thread");
double lastPosition = getCurrentPosition();
while (!GlobalOpMode.opMode.isStopRequested()) {
//android.util.Log.w("AXON_THREAD", "LOOP");
Thread.yield();
double currentPosition = getCurrentPosition();
// Positive wrap-around from 0 -> 360
if (currentPosition > 180 && lastPosition < 180 && innerServo.getPower() > 0) {
count--;
}
// Negative wrap-around from 360 -> 0
if (currentPosition < 180 && lastPosition > 180 && innerServo.getPower() < 0) {
count++;
}
lastPosition = currentPosition;
}
// Negative wrap-around from 360 -> 0
if (currentPosition < 180 && lastPosition > 180 && innerServo.getPower() < 0) {
count++;
}
lastPosition = currentPosition;
} catch (Exception e) {
android.util.Log.e("AXON_THREAD", "Crashed with error: " + e);
}
}

Expand Down

0 comments on commit 8c28beb

Please sign in to comment.