I am running into the issue that I can not do other robot things while my kickBall method is running. I am using this way currently for threading, but it crashes as is. I have also tried using the kickBall method to call just kickThread.run(); but that doesn't let me do anything else while the servo is moving.
Code:
Thread kickThread = new Thread() {
public void run() {
int i = 0;
for (; i < 20; i++) {
if (i == 1) {
setKickAngle(RobotMap.kickDefaultAngle);
doneKicking = false;
} else if (i == 4) {
setKickAngle(RobotMap.kickHitAngle);
doneKicking = false;
} else if (i == 15) {
setKickAngle(RobotMap.kickDefaultAngle);
doneKicking = true;
}
Timer.delay(0.05);
}
doneKicking = true;
kickThread.interrupt();
}
};
public void autoKick() {
if (!kickThread.isAlive() && kickThread.isInterrupted()) {
kickThread.start();
} else {
kickThread.run();
}
}
Full code at my
github
Thanks for any input you guys have!