Team E Code

All codes for Team E will be shared with team members via CodeShare

https://codeshare.io/5z63qW

Scenario 1 Code:

void myCode()
{
//Run all motors at a constant speed of 25% power for 2 seconds.
motorSpeed(4,25);
goFor(2);
//Run all motors at a constant speed of 20% and using the goToAbsolutePosition
//functiontravel 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.
motorSpeed(4,20);
goToAbsolutePosition(295.38);
//Reverse motors.
reverse(4);
//Run all motors at a constant speed and 30% power for 1.5 seconds.
motorSpeed(4,30);
goFor(1.5);
//Brake all motors.
brake(4);
} // DO NOT REMOVE. end of void myCode()

 

Scenario 2 Code:

void myCode()
{
//accelerates motor 1 – 0->15% for 2.5seconds
celerate(1,0,15,2.5);
//runs initialized motor for 1 second
goFor(1);
//brakes motor 1
brake(1);
//accelerates motor 2 from start to 27% for 4secs
celerate(2,0,27,4);
//runs state of motors for 2.7 secs
goFor(2.7);
//declerates motor 2 from 27 to 15 in a second
celerate(2,27,15,1);
//Brake motor 2
brake(2);
//Reverse motor 2
reverse(2);
//Accelereate all 4 from start to 31%
celerate(4,0,31,2);
//All motors at 35% for one second
motorSpeed(4,35);
goFor(1);
//brakes motor 2
brake(2);
// Motor one goes for 1 second
motorSpeed(1,35);
goFor(3);
// Brakes motors for 1 second
brake(4);
goFor(1);
//Reverse the direction of motor one.
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 a constant speed (19% power) for 2 seconds.
motorSpeed(2,19);
motorSpeed(1,19);
goFor(2);
//Decelerate both motors to 0% power in 3 seconds.
celerate(2,19,0,3);
celerate(1,19,0,3);
//Brake all motors.
brake(1);
brake(2);
} // DO NOT REMOVE. end of void myCode()

First Track Run Code

celerate(4,0,25,3);
motorSpeed(4,25);
goFor(1);
motorSpeed(4,20);
goFor(2);
reverse(4);
brake(4);

Second Track Run Code

reverse(4);
celerate(4,0,25,3);
motorSpeed(4,25);
goFor(1);
motorSpeed(4,20);
goFor(2);
reverse(4);
motorSpeed(4,25);
goFor(2);
brake(4);

Third Track Run Code

reverse(4);
celerate(4,0,25,3);
motorSpeed(4,25);
goFor(1);
motorSpeed(4,30);
goFor(2);
brake(4);
goFor(5);
reverse(4);
motorSpeed(4,25);
goFor(2);
brake(4);

Final Run Code

reverse(4);
celerate(4,0,40,4);
motorSpeed(4,40);
goFor(3);
brake(4);

Energy Analysis Code

energyAnalysis
//code given by lab manual
motorSpeed(4, 30);
goFor(4);
motorSpeed(4, 0);
goFor(10);

 

Performance Test 1 Code

//reverse all motors to ensure correct direction of movement
reverse(4);
//initialize servo to correct direction
rotateServo(10);
//run all motors until vehicle reaches gate
motorSpeed(4,35);
goToAbsolutePosition(280);
//stop all motors and rotate brake to active position until gate opens
brake(4);
rotateServo(48);
goFor(7);
//return servo to rest position, run motor through gate and stop all motors
rotateServo(10);
motorSpeed(4,30);
goToAbsolutePosition(360);
brake(4);

Performance Test 2: Prototype Code 2

//reverse all motors to ensure correct direction of movement
reverse(4);
//initialize servo to correct direction
rotateServo(10);
//run all motors until vehicle reaches gate
motorSpeed(4,35);
goToAbsolutePosition(282);
//stop all motors and rotate brake to active position until gate opens
brake(4);
rotateServo(50);
goFor(7);

//return servo to rest position, run motor through gate and stop all motors
rotateServo(10);

//AEV moves into caboose and brakes
motorSpeed(4,35);
goToAbsolutePosition(592);
brake(4);
rotateServo(50);
goFor(5);

//AEV pushes into caboose briefly to ensure connection
rotateServo(10);
motorSpeed(4,30);
goFor(1);
brake(4);

 

Performance Test 2: Final Code

//reverse all motors to ensure correct direction of movement
reverse(4);
//initialize servo to correct direction
rotateServo(10);
//run all motors until vehicle reaches gate
motorSpeed(4,35);
goToAbsolutePosition(284);
//stop all motors and rotate brake to active position until gate opens
brake(4);
rotateServo(50);
goFor(7);

//return servo to rest position, run motor through gate and stop all motors
rotateServo(10);

//AEV coasts near caboose and brakes briefly
motorSpeed(4,30);
goFor(4);
brake(4);
motorSpeed(4,0);
goToAbsolutePosition(625);
rotateServo(50);
goFor(2);
rotateServo(10);

//After AEV brakes, push into caboose for 1 second to actually attach
motorSpeed(4,30);
goFor(1);
brake(4);
goFor(6);

//Back AEV out of caboose docking zone
reverse(4);
motorSpeed(4,30);
goFor(4);
brake(4);

 

Final Performance Test Code 1

 

//reverse all motors to ensure correct direction of movement
reverse(4);
//initialize servo to correct direction
rotateServo(0);
//run all motors until vehicle reaches gate
motorSpeed(4,35);
//goToAbsolutePosition(282);
goToAbsolutePosition(288);
//stop all motors and rotate brake to active position until gate opens
brake(4);
rotateServo(25);
motorSpeed(1,0);
motorSpeed(2,0);
goFor(1);
rotateServo(0);
motorSpeed(1,0);
motorSpeed(2,0);
goFor(6);
motorSpeed(1,32);
motorSpeed(2,32);

//AEV coasts into caboose and brakes
goFor(4);
brake(4);
motorSpeed(4,0);
goToAbsolutePosition(622);
rotateServo(17);
motorSpeed(4,0);
goFor(0.5);
rotateServo(0);
motorSpeed(4,35);
goFor(1);
brake(4);
goFor(5);

reverse(4);
motorSpeed(1,42);
motorSpeed(2,42);
goToAbsolutePosition(388);
motorSpeed(1,35);
motorSpeed(2,35);
goToAbsolutePosition(358);
rotateServo(22);
brake(4);
goFor(1);
rotateServo(0);
motorSpeed(4,0);
goFor(6);

motorSpeed(1,42);
motorSpeed(2,42);
goToAbsolutePosition(280);
brake(4);
goToAbsolutePosition(10);
rotateServo(22);
goFor(1);
rotateServo(0);

 

Final PT Code 2:

//reverse all motors to ensure correct direction of movement
reverse(4);
//initialize servo to correct direction
rotateServo(0);
//run all motors until vehicle reaches gate
motorSpeed(4,35);
//goToAbsolutePosition(282);
goToAbsolutePosition(288);
//stop all motors and rotate brake to active position until gate opens
brake(4);
rotateServo(25);
motorSpeed(1,0);
motorSpeed(2,0);
goFor(1);
rotateServo(0);
motorSpeed(1,0);
motorSpeed(2,0);
goFor(6);
motorSpeed(1,32);
motorSpeed(2,32);

//return servo to rest position, run motor through gate and stop all motors

//AEV coasts until near caboose, then brakes briefly
goFor(4.1);
brake(4);
motorSpeed(4,0);
goToAbsolutePosition(618);
rotateServo(17);
motorSpeed(4,0);
goFor(0.5);
rotateServo(0);

//AEV runs briefly to attach to caboose
motorSpeed(1,40);
motorSpeed(2,40);
goFor(1);
brake(4);
goFor(5);

// Reverse motors and move AEV towards gate

reverse(4);
motorSpeed(1,42);
motorSpeed(2,42);
goToAbsolutePosition(384);

//Slow motors until vehicle reaches gate, then brake
motorSpeed(1,30);
motorSpeed(2,30);
goToAbsolutePosition(358);
rotateServo(22);
brake(4);

//return brake to rest position and wait until gate opens
goFor(1);
rotateServo(0);
motorSpeed(4,0);
goFor(6);

//Move AEV through gate, then coast into the loading dock

motorSpeed(1,42);
motorSpeed(2,42);
goToAbsolutePosition(270);
brake(4);
goToAbsolutePosition(0);

//brake AEV when it reaches loading dock
rotateServo(22);
goFor(1);
rotateServo(0);