Codes

Final Code:

Finalized code (Fast, 224):

reverse(1);

motorSpeed(4,35);

goToAbsolutePosition(-215);

reverse(4);

motorSpeed(4,49);

goFor(1.5);

brake(4);

goFor(6.5);

 

// Gate 1

reverse(4);

motorSpeed(4,30);

goToRelativePosition(-82);

brake(4);

goFor(1.9);

reverse(4);

motorSpeed(4,28);

goFor(.75);

brake(4);

goFor(11);

motorSpeed(4,40);

goToRelativePosition(250);

reverse(4);

motorSpeed(4,29);

goFor(1.5);

brake(4);

goFor(7);

 

// Gate 2

 

reverse(4);

motorSpeed(4,55);

goToRelativePosition(100);

brake(4);

goFor(1.5);

reverse(4);

motorSpeed(4,40);

goFor(1.5);

brake(4);

_____________________________________________________________

Performance Testing Code:

Performance Test 1 Code:

This code was used for prototype 1:

reverse(1); //reverse motor 1

celerate(4,0,30,2); //accelerate motors

motorSpeed(4,30); //Set all motor speeds to 30

goFor(3.57); //notice that this goFor is less than the goFor for prototype 2

reverse(4);  //reverse all motors to prepare for breaking

  motorSpeed(4,30); //set power braking speed

goFor(2.8); //Time for motors to power break

  brake(4); //Shut all motors off

  goFor(6); //Have brake run for 6 seconds (stopping at gate. Has to be 6 seconds since time was spent during power break)

  reverse(4); //reverse motors to allow AEV to go forward once again (exiting gate)

  celerate(4,0,30,3);

motorSpeed(4,30);

goFor(1.5);

brake(4);

_______________________________________________________________________

This code was used for prototype 2:

   //code is the same as the one used for prototype 1 other than the goFor that is commented on

  reverse(1);

celerate(4,0,30,2);

motorSpeed(4,30);

goFor(3.7);

reverse(4);

motorSpeed(4,30);

  goFor(2.8); //notice that this goFor is more than the goFor for prototype 1

  brake(4);

goFor(6);

reverse(4);

celerate(4,0,30,3);

motorSpeed(4,30);

goFor(1.5);

brake(4);

 

Different codes were used for prototype one and two to make sure that both still completed the test. The one that was more efficient was still produced from these results. because the objective was kept in mind.

_______________________________________________________________________

Performance Test 2 Code:

1:

reverse(1);

celerate(4,0,30,2);

motorSpeed(4,30);

goFor(3.57);

reverse(4);

motorSpeed(4,30);

goFor(2.6);

brake(4);

goFor(6);

reverse(4);

celerate(4,0,30,3);

motorSpeed(4,30);

goFor(1.5);

brake(4);

goFor(1.5);

reverse(4);

motorSpeed(4,30);

goFor(0.5);

brake(4);

goFor(12);

celerate(4,0,35,2);

motorSpeed(4,35);

goFor(3);

 

For performance test 2, code was added to account for picking up the caboose. The same idea was kept in mind, using a brake for an allotted time while passengers would get on and then accelerating to a motor speed on the way back.

_______________________________________________________________________

Final Performance Test Code:

 New code:

  //224:

  reverse(1);

  motorSpeed(4,25);

  goToAbsolutePosition(-258);

  reverse(4);

  motorSpeed(4,35);

  goFor(1.5);

  brake(4);

  goFor(6.5);

  

  // Gate 1

 

  reverse(4);

  motorSpeed(4,30);

  goToRelativePosition(-80);

  reverse(4);

  motorSpeed(4,30);

  goFor(.75);

  brake(4);

  goFor(11);

  motorSpeed(4,40);

  goToRelativePosition(250);

  reverse(4);

  motorSpeed(4,29);

  goFor(1.5);

  brake(4);

  goFor(7);

  

  // Gate 2

  

  reverse(4);

  motorSpeed(4,50);

  goToRelativePosition(100);

  reverse(4);

  motorSpeed(4,45);

  goFor(2);

  brake(4);

 

The motor speed function were mostly taken out for performance test 3. This was to account for inconsistency between runs. Motor speed functions were still put in place for reverses, so that the ratio from power to brake was upheld. The Braking was also improved upon for the purpose of better precision.

_______________________________________________________________________

  //308:

  reverse(1);

  motorSpeed(4,25);

  goToAbsolutePosition(-254);

  reverse(4);

  motorSpeed(4,35);

  goFor(1.5);

  brake(4);

  goFor(6.5);

  

  // Gate 1

 

  reverse(4);

  motorSpeed(4,30);

  goToRelativePosition(-80);

  brake(4);

  goFor(1.9);

  reverse(4);

  motorSpeed(4,35);

  goFor(.75);

  brake(4);

  goFor(11);

  motorSpeed(4,40);

  goToRelativePosition(254);

  reverse(4);

  motorSpeed(4,29);

  goFor(1.5);

  brake(4);

  goFor(7);

  

  // Gate 2

  

  reverse(4);

  motorSpeed(4,55);

  goToRelativePosition(100);

  brake(4);

  goFor(1.5);

  reverse(4);

  motorSpeed(4,40);

  goFor(1.5);

  brake(4);

 

A new code for the other room, room 308, was developed to account for more inconsistencies. The tracks were slightly different, so a second iteration with the exact same process was put into place with different speed percentages and times.

_______________________________________________________________________

New code (Fast, 224):

  reverse(1);

  motorSpeed(4,35);

  goToAbsolutePosition(-215);

  reverse(4);

  motorSpeed(4,49);

  goFor(1.5);

  brake(4);

  goFor(6.5);

 

  // Gate 1

  reverse(4);

  motorSpeed(4,30);

  goToRelativePosition(-82);

  brake(4);

  goFor(1.9);

  reverse(4);

  motorSpeed(4,28);

  goFor(.75);

  brake(4);

  goFor(11);

  motorSpeed(4,40);

  goToRelativePosition(250);

  reverse(4);

  motorSpeed(4,29);

  goFor(1.5);

  brake(4);

  goFor(7);

 

  // Gate 2

 

  reverse(4);

  motorSpeed(4,55);

  goToRelativePosition(100);

  brake(4);

  goFor(1.5);

  reverse(4);

  motorSpeed(4,40);

  goFor(1.5);

  brake(4);

To gear the focus back towards speed and efficiency, the power was kicked up from 25% to 35%. This change surpassed our earliest iteration of 30% power as well. The brake was also kicked up on the power side to keep the stop precise.

_____________________________________________________________

Preliminary and Advanced R&D Testing Code:

Lab 1 – Test Code:

// Accelerate motor 1 from 0 to 15 percent power for 2.5 seconds

celerate(1,0,15,2.5);

// Run motor 1 on 15 percent power for 1 second.

motorSpeed(1,15);

goFor(1);

// Brake motor one.

brake(1);

// Accelerate motor 2 from start to 27 percent over 2.7 seconds.

celerate(2,0,27,2.7);

// Run for 2.7 seconds.

goFor(2.7);

// Decelerate motor 2.

celerate(2,27,15,1);

brake(2);

// Reverse motor 2.

reverse(2);

celerate(4,0,31,2);

// Set all motor speeds to 35 percent power.

motorSpeed(4,35);

// Run and brake motors.

goFor(1);

brake(2);

goFor(3);

brake(4);

goFor(1);

reverse(1);

// Accelerate motor one while running motor two.

celerate(1,0,19,2);

motorSpeed(2,35);

goFor(2);

motorSpeed(2,19);

goFor(2);

// Decelerate and brake all motors.

celerate(4,19,0,3);

brake(4);

 

Lab 2 – Reflectance Sensor Function Test:

reflectanceSensorTest();

// Run all motors on 25 percent power for two seconds.

motorSpeed(4,25);

goFor(2);

motorSpeed(4,20);

// Travel distance of 12 feet.

goToAbsolutePosition(70);

// Travel in reverse at 30 percent speed for 1.5 seconds

reverse(4);

motorSpeed(4,30);

goFor(1.5);

// Break motors.

brake(4);

 

Lab 4  – Test Code:

// Accelerate all motors from start to 25 percent power in three seconds.

celerate(4,0,25,3);

// Run all motors at speeds and times.

motorSpeed(4,25);

goFor(1);

motorSpeed(4,20);

goFor(2);

// Reverse and run motors.

reverse(4);

motorSpeed(4,25);

goFor(2);

brake(4);


Lab 6 – Propeller Configuration Code:

Propeller configuration 1:

reverse(1);

celerate(4,0,30,3);

motorSpeed(25);

goFor(5);

reverse(4);

motorSpeed(30);

goFor(3);

brake(4);

 

Propeller configuration 2:

reverse(1);

celerate(4,0,30,3);

motorSpeed(25);

goFor(5);

reverse(4);

motorSpeed(30);

goFor(3);

brake(4);

 

Propeller configuration 3:

reverse(1);

celerate(4,0,30,3);

motorSpeed(25);

goFor(5);

reverse(4);

motorSpeed(30);

goFor(3);

brake(4);

 

Propeller configuration 4:

reverse(2);

celerate(4,0,30,3);

motorSpeed(25);

goFor(5);

reverse(4);

motorSpeed(30);

goFor(3);

brake(4);

 

Lab 7 – Battery testing Code:

reverse(2);

celerate(4,0,30,3);

motorSpeed(25);

goFor(5);

reverse(4);

motorSpeed(30);

goFor(3);

brake(4);