Lab 9

 

Code

// Reverse all motors.

reverse(4);

 

// Accelerate all motors to 47% power and travel to mark 100.

motorSpeed(4,47);

goToAbsolutePosition(100);

 

// Cut power to all motors and travel to mark 378.

motorSpeed(4,0);

goToAbsolutePosition(378);

 

// Rotate servo to halt AEV at gate for 7.5 seconds.

rotateServo(30);

goFor(7.5);

 

// Reverse servo, accelerate all motors to 47% power, and travel to mark 650.

rotateServo(-30);

motorSpeed(4,47);

goToAbsolutePosition(500);

 

// Cut power to all motors and travel to mark 760.

motorSpeed(4,0);

goToAbsolutePosition(760);

 

// Reverse motors, power at 25% for 1.5 seconds, then glide into loading station.

reverse(4);

motorSpeed(4,25);

goFor(1.5);

 

// Brake for 6 seconds to allow R2-D2 to be attached.

brake(4);

goFor(6);

 

// Accelerate all motors to 65% and travel to mark 650.

motorSpeed(4,65);

goToAbsolutePosition(650);

 

// Cut power to all motors and travel to mark 438.

motorSpeed(4,0);

goToAbsolutePosition(438);

 

// Rotate servo to brake AEV at gate and wait for 7 seconds.

rotateServo(30);

brake(4);

goFor(7);

 

// Reverse servo, accelerate all motors to 65% power, and travel to mark 150.

rotateServo(-30);

motorSpeed(4,65);

goToAbsolutePosition(250);

 

// Cut power to engines and travel to mark 35.

motorSpeed(4,0);

goToAbsolutePosition(35);

 

// Rotate servo to brake AEV at rebel base.

rotateServo(30);

brake(4);