use of spacesettlers.actions.MoveAction in project spacesettlers by amymcgovern.
the class TestMoveAction method testpdControlOrientToGoal.
/**
* Test orienting in both directions
*
* (40, 40)
* (50,50)
* (40, 60)
*
* @throws SpaceSettlersActionException
*/
@Test
public void testpdControlOrientToGoal() throws SpaceSettlersActionException {
// first to -3pi/4
Position currentLoc = new Position(50, 50);
Position goalLoc = new Position(40, 40);
moveAction = new MoveAction();
double accel = moveAction.pdControlOrientToGoal(space, goalLoc, currentLoc, 0);
Movement movement = new Movement();
while (Math.abs(accel) > MoveAction.TARGET_REACHED_ACCEL) {
movement.setAngularAccleration(accel);
currentLoc = space.applyMovement(currentLoc, movement, timestep);
accel = moveAction.pdControlOrientToGoal(space, goalLoc, currentLoc, 0);
}
assertEquals(currentLoc.getOrientation(), -(3 * Math.PI) / 4, 0.01);
// then to 3pi/4
currentLoc = new Position(50, 50);
currentLoc.setOrientation(0);
goalLoc = new Position(40, 60);
accel = moveAction.pdControlOrientToGoal(space, goalLoc, currentLoc, 0);
movement = new Movement();
while (Math.abs(accel) > MoveAction.TARGET_REACHED_ACCEL) {
movement.setAngularAccleration(accel);
currentLoc = space.applyMovement(currentLoc, movement, timestep);
accel = moveAction.pdControlOrientToGoal(space, goalLoc, currentLoc, 0);
}
assertEquals(currentLoc.getOrientation(), (3 * Math.PI) / 4, 0.01);
}
Aggregations