class MotorController
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private boolean |
closed
Indicates fork position.
|
private int |
downCorrection
Correction that needs to be added to execute a clockwise rotation by 90 degrees of cube's down face precisely (down()-move).
|
private int |
downInvertedCorrection
Correction that needs to be added to execute a counter-clockwise rotation by 90 degrees of cube's down face precisely (downInverted()-move).
|
private int |
forkIdleAngle
Fork's idle position.
|
private EV3LargeRegulatedMotor |
forkMotor
Large motor that is connected to the fork and rotates it.
|
private int |
FORKMOVERANGLE
forkMover needs to rotate by this angle to push fork against cube.
|
private int |
FORKSPEED
Speed of forkMotor.
|
private int |
frontTurnAngleLeft
Angle that needs to be added to fork's idle position to finish a counter clockwise rotation by 90 degrees of cube's front face.
|
private int |
frontTurnAngleRight
Angle that needs to be added to fork's idle position to finish a clockwise rotation by 90 degrees of cube's front face (front()-move).
|
private EV3MediumRegulatedMotor |
moverMotor
Medium motor that moves the fork back and forth.
|
private int |
MOVERSPEED
Speed of moverMotor.
|
private static int |
OVERSHOOT
Additional angle to prevent mechanical movement failure.
|
private int |
startScanningAngle
tableMotor's angle before scanning rotation is executed.
|
private int |
switchDownCorrection
Correction that needs to be added to execute a clockwise rotation of cube's down face by 180 degrees precisely (switchDown()-move).
|
private int |
tableAngle
Current wanted position of tableMotor.
|
private EV3LargeRegulatedMotor |
tableMotor
Large EV3-motor that is connected to the table and rotates it.
|
private int |
TABLESPEED
Speed of tableMotor.
|
Constructor and Description |
---|
MotorController() |
Modifier and Type | Method and Description |
---|---|
protected void |
applyMoves(AllMoves[] maneuver,
boolean scanning)
Execute given moves on physical cube.
|
protected void |
applyMoves(AllMoves[] maneuver,
int manIndex,
boolean scanning)
Execute given moves on physical cube.
|
protected void |
calibrate()
Manual calibration method of fork and table.
|
private void |
calibrateFork()
Manual calibration of forkMotor.
|
private void |
calibrateTable()
Manual Calibration of tableMotor.
|
protected void |
down(boolean nextRotate,
int overshoot)
Rotates cube's down face by 90 degrees clockwise (looking at the bottom of the cube).
|
protected void |
downInverted(boolean nextRotate,
int overshoot)
Rotates cube's down face by 90 degrees counter clockwise (looking at the bottom of the cube).
|
protected void |
front(int overshoot)
Rotates cube's front face by 90 degrees clockwise.
|
protected void |
frontInverted(int overshoot)
Rotates cube's front face by 90 degrees counter clockwise.
|
protected int |
getTableTachoCount()
Used to determine which element is located under EV3ColorSensor while tableTurnScan() is executed.
|
protected void |
init()
Initializes CubeSolver's motors.
|
private void |
initFork()
Initialization of forkMotor.
|
private void |
initForkMover()
Initialization of moverMotor.
|
private void |
initTable()
Initialization of tableMotor.
|
private void |
moveFork(boolean immediateReturn)
Pushes fork towards cube or pulls it back.
|
protected int |
overshoot(AllMoves[] maneuver,
int thisMove,
int manIndex)
Calculates additional angle to prevent mechanical failure.
|
protected void |
reallignTable()
Rotate table to current wanted tableAngle.
|
protected void |
rotate()
Rotates the whole cube by 90 degrees clockwise (looking at the bottom of the cube).
|
protected void |
rotateInverted()
Rotates the whole cube by 90 degrees counter clockwise (looking at the bottom of the cube).
|
protected void |
switchDown(boolean nextRotate,
int overshoot)
Rotates cube's down face by 180 degrees clockwise (looking at the bottom of the cube).
|
protected void |
switchFront(int overshoot)
Rotates cube's front face by 180 degrees clockwise.
|
protected void |
switchRotate()
Rotates the whole cube by 180 degrees clockwise (looking at the bottom of the cube).
|
protected void |
tableTurnScan()
Rotate table by 450 degrees.
|
protected void |
waitCompleteTable()
Wait until tableMotor completes movement.
|
private final EV3LargeRegulatedMotor tableMotor
private final EV3LargeRegulatedMotor forkMotor
private final EV3MediumRegulatedMotor moverMotor
private final int FORKMOVERANGLE
private final int FORKSPEED
private final int TABLESPEED
private final int MOVERSPEED
private static final int OVERSHOOT
private int frontTurnAngleRight
private int frontTurnAngleLeft
private int downCorrection
private int downInvertedCorrection
private int switchDownCorrection
private int forkIdleAngle
private int tableAngle
private int startScanningAngle
private boolean closed
protected void init()
protected void calibrate()
private void initFork()
init()
private void calibrateFork()
private void initForkMover()
private void initTable()
private void calibrateTable()
private void moveFork(boolean immediateReturn)
immediateReturn
- true: method returns immediately, movement is finished in background. false: method returns after movement is finished.protected void tableTurnScan()
protected int getTableTachoCount()
protected void waitCompleteTable()
protected void reallignTable()
protected void front(int overshoot)
overshoot
- Additional rotation angle, that prevents mechanical failures.protected void frontInverted(int overshoot)
overshoot
- Additional rotation angle, that prevents mechanical failures.protected void switchFront(int overshoot)
overshoot
- Additional rotation angle, that prevents mechanical failures.protected void down(boolean nextRotate, int overshoot)
nextRotate
- Indicates if next move is a rotation of whole cube.overshoot
- Additional rotation angle, that prevents mechanical failures.protected void downInverted(boolean nextRotate, int overshoot)
nextRotate
- Indicates if next move is a rotation of whole cube.overshoot
- Additional rotation angle, that prevents mechanical failures.protected void switchDown(boolean nextRotate, int overshoot)
nextRotate
- Indicates if next move is a rotation of whole cube.overshoot
- Additional rotation angle, that prevents mechanical failures.protected void rotate()
protected void rotateInverted()
protected void switchRotate()
protected int overshoot(AllMoves[] maneuver, int thisMove, int manIndex)
maneuver
- Array that contains moves.thisMove
- Current move to calculate overshoot for.manIndex
- manIndex -1 is last move in Arrayprotected void applyMoves(AllMoves[] maneuver, int manIndex, boolean scanning)
maneuver
- Array that contains moves.manIndex
- manIndex -1 is last move that is executed.scanning
- Shows if method is called during scanning processprotected void applyMoves(AllMoves[] maneuver, boolean scanning)
maneuver
- Array that contains moves.scanning
- shows if method is called during scanning process