2 ms·
You could have used Kotlin if you wanted to stay on the JVM and use coroutines. Your desired pseudo-code in Java would look like this in Kotlin: coroutine
by gavinray 3y ago
You could have used Kotlin if you wanted to stay on the JVM and use coroutines.
Your desired pseudo-code in Java would look like this in Kotlin:
coroutineScope {
// Drive backward
launch {
while (drivetrain.getDistanceInches() > -48) {
drivetrain.arcadeDrive(-0.5, 0)
}
drivetrain.arcadeDrive(0, 0)
}
// Grab for two seconds
launch {
val grabTimer = Timer()
while (grabTimer.get() < 2) {
intake.grab()
}
intake.stopGrabbing()
}
// Drive forward
launch {
while (drivetrain.getDistanceInches() < 0) {
drivetrain.arcadeDrive(0.5, 0)
}
drivetrain.arcadeDrive(0, 0)
}
}