This page contains all AEV code used during research and development.
Exercise 1
//Accelerate motor one from start to 15% power in 2.5 seconds.
celerate(1,0,15,2.5);
//Run motor one at a constant speed (15% power) for 1 second.
motorSpeed(1,15);
goFor(1);
// Brake motor one.
brake(1);
//Accelerate motor two from start to 27% power in 4 seconds.
celerate(2,0,27,4);
//Run motor two at a constant speed (27% power) for 2.7 seconds.
motorSpeed(2,27);
goFor(2.7);
//Decelerate motor two to 15% power in 1 second.
celerate(2,27,15,1);
//Brake motor two.
brake(2);
//Reverse the direction of only motor 2.
reverse(2);
//Accelerate all motors from start to 31% power in 2 seconds.
celerate(4,0,31,2);
//Run all motors at a constant speed of 35% power for 1 second.
motorSpeed(4,35);
goFor(1);
//Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds.
brake(2);
//Brake all motors for 1 second.
brake(4);
goFor(1);
//Reverse the direction of motor 1
reverse(1);
//Accelerate motor one from start to 19% power over 2 seconds.
celerate(1,0,19,2);
//Run motor two at 35% power while simultaneously running motor one at 19% power for 2 seconds
motorSpeed(2,35);
motorSpeed(1,19);
goFor(2);
//Run both motors at 19% power for 2 seconds
motorSpeed(4,19);
goFor(2);
//Decelerate both motors to 0% in 3 seconds
celerate(4,19,0,3);
//Brake all motors
brake(4);
Exercise 2
//Run all motors at 25% power for 2 seconds
motorSpeed(4,25);
goFor(2);
// Run all motors at 20% and use the goToAbsolutePosition function to travel a total distance of 12 feet, then stop
motorSpeed(4,20);
goToAbsolutePosition(295);
brake(4);
//reverse the motors
reverse(4);
//Run all motors at a constant speed of 30% power for 1.5 sec
motorSpeed(4,30);
goFor(1.5);
//brake all motors
brake(4);
Exercise 4
//Accelerate all motors from start to 25% in 3 seconds.
celerate(4,0,25,3);
//Run all motors at a constant speed (25% power) for 1 second.
motorSpeed(4,25);
goFor(1);
//Run all motors at 20% power for 2 seconds.
motorSpeed(4,20);
goFor(2);
//Reverse all motors.
reverse(4);
//Run all motors at a constant speed (25% power) for 2 second.
motorSpeed(4,25);
goFor(2);
//Brake all motors.
brake(4);
aR&D Coasting
(also used as Double Motor)
//Accelerate all motors from start to 35% in 3 seconds.
celerate(4,0,35,3);
//Run all motors at a constant speed (35% power) for 2 seconds.
motorSpeed(4,35);
goFor(2);
//Brake all motors.
brake(4);
aR&D Power Braking
//Accelerate all motors from start to 35% in 3 seconds.
celerate(4,0,35,3);
//Run all motors at a constant speed (35% power) for 2 seconds.
motorSpeed(4,35);
goFor(2);
//Brake all motors.
brake(4);
//Reverse all motors.
reverse(4);
//Run all motors at a constant speed (20% power) for 2 seconds.
motorSpeed(4,20);
goFor(2);
//Brake all motors.
brake(4);
aR&D Single Motor
//Accelerate all motors from start to 35% in 3 seconds.
celerate(1,0,35,3);
//Run all motors at a constant speed (35% power) for 2 seconds.
motorSpeed(1,35);
goFor(2);
//Brake all motors.
brake(4);
Mark II performance Test 1
// Run all motors from rest to 35% power in 2.5 seconds
celerate(4,0,35,2.5);
// go to relative position from start
goToRelativePosition(-94);
//start power break
brake(4);
reverse(4);
motorSpeed(4,20);
goFor(2);
brake(4);
//wait for stop sign
goFor(7);
//accelerate from stop
reverse(4);
celerate(4,0,35,2.5);
goToRelativePosition(-25);
brake(4);
Mark III – Performance Test 1:
//initially reverse motors
reverse(4);
// Run all motors from rest to 35% power in 2.5 seconds
celerate(4,0,35,2.5);
// go to relative position from start
goToRelativePosition(-135);
//start power break
brake(4);
reverse(4);
motorSpeed(4,35);
goFor(2.5);
brake(4);
//wait for stop sign
goFor(7);
//reverse to go forward
reverse(4);
//go to caboose
celerate(4,0,35,2.5);
goToRelativePosition(-25);
//brake to attach
brake(4);
Mark III – Performance Test 2 (lab):
//initially reverse motors
reverse(4);
// Run all motors from rest to 35% power in 2.5 seconds
celerate(4,0,35,2.5);
// go to relative position from start
goToRelativePosition(-167);
//start power break
brake(4);
reverse(4);
motorSpeed(4,35);
goFor(2.5);
brake(4);
//wait for stop sign
goFor(6);
//reverse to go forward
reverse(4);
//go to caboose
celerate(4,0,35,2.5);
goToRelativePosition(-70);
//brake to attach
brake(4);
goToRelativePosition(-150);
//reverse motors towards station
reverse(4);
motorSpeed(4,25);
goFor(2.5);
brake(4);
goFor(5);
motorSpeed(4,40);
goFor(6);
brake(4);
Mark IV – Final Code:
//initially reverse motors
reverse(4);
// Run all motors from rest to 45% power in 2.5 seconds
celerate(4,0,45,2.5);
// go to relative position from start. -167 lab, -129 class
goToRelativePosition(-134);
//start power break
brake(4);
reverse(4);
motorSpeed(4,47);
goFor(2);
brake(4);
//wait for stop sign
goFor(6);
//reverse to go forward
reverse(4);
//go to caboose
celerate(4,0,45,2);
goToRelativePosition(-60);
//brake to attach
brake(4);
goToRelativePosition(-144);
//reverse motors towards station for power brake
reverse(4);
motorSpeed(4,28);
goFor(2.5);
//wait for 5 seconds with caboose
brake(4);
goFor(5);
//drive back towards gate. 235 lab, 239 class
motorSpeed(4,60);
goToRelativePosition(223);
brake(4);
//power braking start
reverse(4);
motorSpeed(4,50);
goFor(1.5);
//wait for stop sign
brake(4);
goFor(7.5);
//go to the final spot
reverse(4);
motorSpeed(4,60);
goToRelativePosition(140);
brake(4);
//final power braking
goToRelativePosition(140);
reverse(4);
motorSpeed(4,50);
goFor(1.6);
//end
brake(4);