AEV Codes

Code from Section 1 of Lab

//accelerates the first engine from start to 15% in 2.5 seconds
celerate(1,0,15,2.5);

//Run motor one at constant speed for 1 second
goFor(1);

//Brake motor 1
brake(1);

//accelerate motor 2 from start to 27% in 4 seconds
celerate(2,0,27,4);
//run motor 2 at constant speed for 2.7 seconds
goFor(2.7);
//Decelerate motor 2 to 15% power in 1 second
celerate(2,27,15,1);
//brake motor 2
brake(2);
//reverse direction of motor 2
reverse(2);
//accelerate all motors from start to 31% in 2 sec
celerate(1,0,31,2);
celerate(2,0,31,2);
//run all motors at a constant speed of 35% for 1 sec
motorSpeed(1,35);
motorSpeed(2,35);
goFor(1);
//brake all motors for 1 sec
brake(4);
goFor(1);
//reverse all direction of motor one
reverse(1);
//accelerate motor one from start to 19% over 2 sec
celerate(1,0,19,2);
//run motor 2 at 35% power while simultaneously running motor one at 19% power for 2 sec
motorSpeed(2,35);
motorSpeed(1,19);
goFor(2);
//run both motors at a constant speed for 2 sec
goFor(2);
//decelerate both motors to 0% power in 3 sec
celerate(1,19,0,3);
celerate(2,35,0,3);
//brake all motors
brake(4);

Code from Section 2 of Lab:
void setup() {
  // put your setup code here, to run once:
celerate(4,0,25,2);
motorSpeed(4,20);
goToRelativePosition(12);
reverse(4);
motorSpeed(4,30);
goFor(1.5);
brake(4);
}
1.Run all motors at a constant speed of 25% power for 2 seconds.
2.Run all motors at a constant speed of 20% and using the goToAbsolutePosition function travel a total distance of 12 feet (from the starting point). You will actually rotate the wheel by hand (since you are on the desktop tracks) until the wheel has completed the required distance and the motors stop.
3.Reverse motors.
4.Run all motors at a constant speed of 30% power for 1.5 second.
5.Brake all motors.
Code from Section 3 of Lab
celerate(4,0,25,3); //accelerates motors 1 and 2
goFor(1); //keeps motors going for 1 secondmotorSpeed(4,20); //sets motors 1 and 2 to 20% speedgoFor(2); //keeps motors going for 2 secondsreverse(4); //reverses motors 1 and 2motorSpeed(4,25); //sets motors 1 and 2 to 25% speed

goFor(2); //keeps motors going for 2 seconds

brake(4); //brakes motors 1 and 2

Performance Test 1 Code 

reverse(4); //makes motors go the right way

motorSpeed(4,25); //sets speed to 25%

goFor(5); //goes for 5 seconds

reverse(4); //reverses all motors to brake AEV

motorSpeed(4,30); //sets motor speed to 30%

goFor(0.5); //reverses (to stop AEV) for 0.5 seconds

brake(4); //brakes motors

motorSpeed(4,0); //sets all motor speed to 0%

goFor(12); //keeps AEV stopped for 12 seconds in gate

reverse(4); //makes motors go the right way

motorSpeed(4,25); //sets speed to 25%

goFor(3); //makes all motors go for 3 seconds

brake(4); //stops all motors

 

Performance Test 2 Code

//BEFORE STOP SIGN 1st:

reverse(4); //makes motors go the right way

motorSpeed(4,27); //sets speed to 27%

goFor(5.9); //goes for 5.9 seconds

brake(4); //causes coasting before stop sign

goFor(1); //causes coasting before stop sign

 

//STOPPING FOR STOP SIGN 1st:

reverse(4); //reverses all motors to brake AEV

motorSpeed(4,31); //sets motor speed to 31%

goFor(1); //reverses the motors to stop for 1 seconds

brake(4); //brakes motors

motorSpeed(4,0); //sets all motor speed to 0%

goFor(10); //keeps AEV stopped for 10 seconds in gate

 

//AFTER STOP SIGN 1st:

reverse(4); //makes motors go the right way

 

motorSpeed(4,25); //sets speed to 25%

goFor(4.15); //makes all motors go for 4.15 seconds

brake(4); //stops all motors

goFor(5); //coasts to caboose for 5 seconds

 

reverse(4); //reverse all motors

motorSpeed(4,40); //all motors to 40%

goFor(4); //go for 4 seconds

 

Final Performance Test Code

Code

//BEFORE FIRST STOP
reverse(4); //motors go correct way
motorSpeed(4,29.5); //motor speed to 29.5%
goToRelativePosition(265); //goes a little past first ramp
reverse(4); //prepares for stopping
motorSpeed(4,50); //sets to 50% to stop
goFor(0.8); //brakes for 0.8s
brake(4); //stops motors at gate 1
rotateServo(120); //rotates servo 120 degrees to help brake
goFor(8); //stops at gate for 8 seconds
rotateServo(0); //sets servo back to 0 degrees

//AFTER FIRST STOP
reverse(4); //motors go correct way
motorSpeed(4,20); //motors to 23%
goToRelativePosition(120); //goes 120 marks beyond stop sign
brake(4); //stops all motors

goFor(9); //coasts for 9 seconds

//AFTER PICKING UP CABOOSE
reverse(4); //reverses motors to bring back to start
motorSpeed(4,40); //sets motors to 40%; more weight, more speed needed
goToRelativePosition(-252);
reverse(4); //prepares for stopping
motorSpeed(4,50); //sets to 50% to stop
goFor(1); //brakes for 1s
brake(4); //stops motors
rotateServo(130); //rotates servo 130 degrees to help brake
goFor(8); //stops at gate for 8 seconds
rotateServo(0); //sets servo back to 0 degrees

//AFTER SECOND STOP
reverse(4); //motors go correct way
motorSpeed(4,35); //motors to 35%
goToAbsolutePosition(215); //goes to mark=215
brake(4); //stops all motors
goFor(2.4); //coasts for 2.4s
reverse(4); //reverses motors to stop
motorSpeed(4,50); //prepares motors for braking
goFor(0.6); //brakes for 0.5s
rotateServo(130); //ebrake
brake(4); //stop