Skip to content
This repository has been archived by the owner on Dec 24, 2018. It is now read-only.

Commit

Permalink
Add more auto mode options
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Mar 4, 2018
1 parent 77cd156 commit 72bf2bc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/sert2521/powerup/autonomous/Autonomous.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,22 @@ object Auto : RobotLifecycle {
TurnToAngle(-SCALE_TO_SWITCH_TURN) and SendToSwitch() then
findAndDeliverCube

AutoMode.LEFT_TO_RIGHT_SCALE -> LeftToRightScale() and SendToSwitch() and
AutoMode.LEFT_TO_RIGHT_SCALE_PICKUP -> LeftToRightScale() and SendToSwitch() and
SendToScale().waitUntil(isReadyToSendToScale) then
EjectBlock() then TurnToAngle(-SCALE_TO_SWITCH_TURN) and SendToSwitch() then
findCube

AutoMode.RIGHT_TO_LEFT_SCALE_PICKUP -> RightToLeftScale() and SendToSwitch() and
SendToScale().waitUntil(isReadyToSendToScale) then
EjectBlock() then TurnToAngle(SCALE_TO_SWITCH_TURN) and SendToSwitch() then
findCube

AutoMode.LEFT_TO_RIGHT_SCALE_SWITCH -> LeftToRightScale() and SendToSwitch() and
SendToScale().waitUntil(isReadyToSendToScale) then
EjectBlock() then TurnToAngle(-SCALE_TO_SWITCH_TURN) and SendToSwitch() then
findAndDeliverCube

AutoMode.RIGHT_TO_LEFT_SCALE -> RightToLeftScale() and SendToSwitch() and
AutoMode.RIGHT_TO_LEFT_SCALE_SWITCH -> RightToLeftScale() and SendToSwitch() and
SendToScale().waitUntil(isReadyToSendToScale) then
EjectBlock() then TurnToAngle(SCALE_TO_SWITCH_TURN) and SendToSwitch() then
findAndDeliverCube
Expand Down
42 changes: 32 additions & 10 deletions src/main/java/org/sert2521/powerup/util/Modes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import org.sert2521.powerup.util.AutoMode.End
import org.sert2521.powerup.util.AutoMode.LEFT_TO_LEFT_SCALE_PICKUP
import org.sert2521.powerup.util.AutoMode.LEFT_TO_LEFT_SCALE_SWITCH
import org.sert2521.powerup.util.AutoMode.LEFT_TO_LEFT_SWITCH
import org.sert2521.powerup.util.AutoMode.LEFT_TO_RIGHT_SCALE
import org.sert2521.powerup.util.AutoMode.LEFT_TO_RIGHT_SCALE_PICKUP
import org.sert2521.powerup.util.AutoMode.LEFT_TO_RIGHT_SCALE_SWITCH
import org.sert2521.powerup.util.AutoMode.MIDDLE_TO_LEFT_SWITCH
import org.sert2521.powerup.util.AutoMode.MIDDLE_TO_RIGHT_SWITCH
import org.sert2521.powerup.util.AutoMode.RIGHT_TO_LEFT_SCALE
import org.sert2521.powerup.util.AutoMode.RIGHT_TO_LEFT_SCALE_PICKUP
import org.sert2521.powerup.util.AutoMode.RIGHT_TO_LEFT_SCALE_SWITCH
import org.sert2521.powerup.util.AutoMode.RIGHT_TO_RIGHT_SCALE_PICKUP
import org.sert2521.powerup.util.AutoMode.RIGHT_TO_RIGHT_SCALE_SWITCH
import org.sert2521.powerup.util.AutoMode.RIGHT_TO_RIGHT_SWITCH
Expand Down Expand Up @@ -48,11 +50,19 @@ val autoMode: AutoMode
End.SCALE -> LEFT_TO_LEFT_SCALE_SWITCH
else -> error("Unknown mode: $endChoice")
}
OwnedSide.RIGHT -> RIGHT_TO_RIGHT_SWITCH
OwnedSide.RIGHT -> when (endChoice) {
End.SWITCH -> LEFT_TO_LEFT_SWITCH
End.SCALE -> LEFT_TO_RIGHT_SCALE_PICKUP
else -> error("Unknown mode: $endChoice")
}
else -> error("Impossible condition: $scaleSide")
}
Start.RIGHT -> when (scaleSide) {
OwnedSide.LEFT -> RIGHT_TO_LEFT_SCALE
OwnedSide.LEFT -> when (endChoice) {
End.SWITCH -> RIGHT_TO_LEFT_SCALE_PICKUP
End.SCALE -> RIGHT_TO_LEFT_SCALE_SWITCH
else -> error("Unknown mode: $endChoice")
}
OwnedSide.RIGHT -> RIGHT_TO_RIGHT_SCALE_PICKUP
else -> error("Impossible condition: $scaleSide")
}
Expand All @@ -61,11 +71,19 @@ val autoMode: AutoMode
Start.MIDDLE -> MIDDLE_TO_RIGHT_SWITCH
Start.LEFT -> when (scaleSide) {
OwnedSide.LEFT -> LEFT_TO_LEFT_SCALE_PICKUP
OwnedSide.RIGHT -> LEFT_TO_RIGHT_SCALE
OwnedSide.RIGHT -> when (endChoice) {
End.SWITCH -> LEFT_TO_RIGHT_SCALE_PICKUP
End.SCALE -> LEFT_TO_RIGHT_SCALE_SWITCH
else -> error("Unknown mode: $endChoice")
}
else -> error("Impossible condition: $scaleSide")
}
Start.RIGHT -> when (scaleSide) {
OwnedSide.LEFT -> RIGHT_TO_RIGHT_SWITCH
OwnedSide.LEFT -> when (endChoice) {
End.SWITCH -> RIGHT_TO_RIGHT_SWITCH
End.SCALE -> RIGHT_TO_LEFT_SCALE_PICKUP
else -> error("Unknown mode: $endChoice")
}
OwnedSide.RIGHT -> when (endChoice) {
End.SWITCH -> RIGHT_TO_RIGHT_SWITCH
End.SCALE -> RIGHT_TO_RIGHT_SCALE_SWITCH
Expand All @@ -91,8 +109,10 @@ enum class AutoMode {
CROSS_BASELINE,
LEFT_TO_LEFT_SWITCH, RIGHT_TO_RIGHT_SWITCH,
MIDDLE_TO_LEFT_SWITCH, MIDDLE_TO_RIGHT_SWITCH,
LEFT_TO_LEFT_SCALE_PICKUP, LEFT_TO_LEFT_SCALE_SWITCH, LEFT_TO_RIGHT_SCALE,
RIGHT_TO_RIGHT_SCALE_PICKUP, RIGHT_TO_RIGHT_SCALE_SWITCH, RIGHT_TO_LEFT_SCALE,
LEFT_TO_LEFT_SCALE_PICKUP, LEFT_TO_LEFT_SCALE_SWITCH,
LEFT_TO_RIGHT_SCALE_PICKUP, LEFT_TO_RIGHT_SCALE_SWITCH,
RIGHT_TO_RIGHT_SCALE_PICKUP, RIGHT_TO_RIGHT_SCALE_SWITCH,
RIGHT_TO_LEFT_SCALE_PICKUP, RIGHT_TO_LEFT_SCALE_SWITCH,
TEST_LEFT, TEST_RIGHT;

enum class Start {
Expand Down Expand Up @@ -121,8 +141,10 @@ object Modes : RobotLifecycle {
"Right to Right Scale with Pickup" to RIGHT_TO_RIGHT_SCALE_PICKUP,
"Left to Left Scale with Switch" to LEFT_TO_LEFT_SCALE_SWITCH,
"Right to Right Scale with Switch" to RIGHT_TO_RIGHT_SCALE_SWITCH,
"Left to Right Scale" to LEFT_TO_RIGHT_SCALE,
"Right to Left Scale" to RIGHT_TO_LEFT_SCALE,
"Left to Right Scale with Pickup" to LEFT_TO_RIGHT_SCALE_PICKUP,
"Right to Left Scale with Pickup" to RIGHT_TO_LEFT_SCALE_PICKUP,
"Left to Right Scale with Switch" to LEFT_TO_RIGHT_SCALE_SWITCH,
"Right to Left Scale with Switch" to RIGHT_TO_LEFT_SCALE_SWITCH,

"Test Left" to TEST_LEFT,
"Test Right" to TEST_RIGHT
Expand Down

0 comments on commit 72bf2bc

Please sign in to comment.