Code Archive

Preliminary R&D

Programming Basics

The following code was written on the first day of R&D. The purpose of this code is to test the function of the motors and to demonstrate the use of a program to control the AEV.

celerate(1, 0, 15, 2.5);     //accelerate motor one from start to 15% in 2.5 sec
motorSpeed(1,15);            //run motor one at 15% for 1 second
goFor(1);
brake(1);                    //brake motor one
celerate(2,0,27,4);          //accelerate motor two from start to 27% in 4 sec
motorSpeed(2,27);            //run motor two at 27% for 2.7 seconds
goFor(2.7);
celerate(2,27,14,1);         //decelerate motor two to 15% in 1 sec
brake(2);                    //brake motor two
reverse(2);                  //reverse motor two
celerate(4,0,31,2);          //accelerate all motors from start to 31% in 2 sec
motorSpeed(4,35);            //run all motors at 35% for 1 sec
goFor(1);
brake(2);                    //brake motor two but keep motor one running for 3 seconds
goFor(3);
brake(4);                    //brake all motors for 1 sec
goFor(1);
reverse(1);                  //reverse motor one
celerate(1,0,19,2);          //accelerate motor one from start to 19% in 2 sec
motorSpeed(2,35);            //run motor two at 35% for 2 sec
motorSpeed(1,19);            //run motor one at 19% for 2 sec
goFor(2);                    
motorSpeed(4,19);            //run both motors at 19% for 2 sec
goFor(2);
celerate(4,19,0,3);          //decelerate all motors to 0% in 3 sec
brake(4);                    //brake all motors

Reflectance Sensors

The following code was written the second day of R&D with the purpose of testing the function of the reflectance sensors in a transit scenario.

motorSpeed(4,25);            //run all motors at 25% for 2 sec
goFor(2);
goToAbsolutePosition(295);   //travel 12 feet (295 marks)
reverse(4);                  //reverse motors
motorSpeed(4,30);            //run all motors at 30% for 1.5 sec
goFor(1.5);             
brake(4);                    //brake all motors

Data Analysis

The following code was written the third day of R&D with the purpose of testing the data analysis tool in the given scenario.

celerate(4,0,45,3);          //accelerate all motors from start to 25% in 3 seconds
motorSpeed(4,45);            //run all motors at constant speed 25%
goFor(1);                    //run for 1 second
motorSpeed(4,40);            //run all motors at constant speed 20%
goFor(2);                    //run for 2 seconds
reverse(4);                  //reverse all motors
motorSpeed(4,25);            //run all motors at constant speed 25%
goFor(2);                    //run for 2 seconds
brake(4);                    //brake all motors


Advanced R&D

Power Braking vs. Coasting

The following code was written in the first week of advanced R&D. The purpose of this code is to run the AEV and have it stopped in the power braking method.

reverse(1);                   //reverse motor 1 at the beginning
celerate(4,0,40,3);           //accelerate all motors from start to 40% in 3 seconds
motorSpeed(4,40);             //run all motors at constant speed 40%
goToRelativePosition(200);    //go to absolute position 200 marks
reverse(4);                   //reverse all motors
motorSpeed(4, 20);            //run all motors at constant speed 20%
goFor(3);                     //run all motors for 3 seconds
brake(4);                     //brake all motors

The following code was written in the first week of advanced R&D. The purpose of this code is to run the AEV and have it stopped in the coasting method.

reverse(1);                   //reverse motor 1 at the beginning
celerate(4,0,40,3);           //accelerate all motors from start to 40% in 3 seconds
motorSpeed(4,40);             //run all motors at constant speed 40%
goToRelativePosition(200);    //go to absolute position 200 marks
brake(4);                     //brake all motors


Performance Test

Performance Test 1

The following code was written to test Prototype A for the course in Performance Test 1.

reverse(4);                   //reverse all motors
motorSpeed(4,40);             //initialize all motors to 40% power
goToAbsolutePosition(240);    //go to absolute position 240 marks
reverse(4);                   //reverse all motors
motorSpeed(4,20);             //initialize all motors to 20% power
goFor(3);                     //run the motors at the initialized state for 3 seconds
brake(4);                     //brake all motors
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(7);                     //run the motors at the initialized state for 7 seconds
reverse(4);                   //reverse all motors
motorSpeed(4,40);             //initialize all motors to 40% power
goFor(3);                     //run the motors at the initialized state for 3 seconds
brake(4);                     //brake all motors

The following code was written to test Prototype A for the course in Performance Test 1.

reverse(4);                   //reverse all motors
motorSpeed(4,35);             //initialize all motors to 35% power
goToAbsolutePosition(240);    //go to absolute position 240 marks
reverse(4);                   //reverse all motors
motorSpeed(4,25);             //initialize all motors to 25% power
goFor(3);                     //run the motors at the initialized state for 3 seconds
brake(4);                     //brake all motors
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(7);                     //run the motors at the initialized state for 7 seconds
reverse(4);                   //reverse all motors
motorSpeed(4,40);             //initialize all motors to 40% power
goFor(3);                     //run the motors at the initialized state for 3 seconds
brake(4);                     //brake all motors

Performance Test 2

The following code was written to test AEV for the course in Performance Test 2.

reverse(2);                   //reverse motor 2
motorSpeed(4,35);             //initialize all motors to 35% power
goFor(4.7);                   //run the motors at the initialized state for 4.7 seconds
brake(4);                     //brake all motors
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(2);                     //run the motors at the initialized state for 2 seconds

while ( getVehiclePostion() < 300 ) {
    motorSpeed(4,22);         //initialize all motors to 22% power
}

reverse(4);                   //reverse all motors
motorSpeed(4,16);             //initialize all motors to 16% power
goFor(1);                     //run the motors at the initialized state for 1 second
brake(4);                     //brake all motors
reverse(4);                   //reverse all motors

motorSpeed(4,0);              //initialize all motors to 0 power
goFor(7);                     //run the motors at the initialized state for 7 seconds
motorSpeed(4,30);             //initialize all motors to 30% power
goFor(3);                     //run the motors at the initialized state for 3 seconds

while ( getVehiclePostion() < 608) {
    motorSpeed(4,22);         //initialize all motors to 22% power
}

reverse(4);                   //reverse all motor;
motorSpeed(4,27);             //initialize all motors to 27% power
goFor(1);                     //run the motors at the initialized state for 1 second
brake(4);                     //brake all motors
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(5);                     //run the motors at the initialized state for 5 seconds

motorSpeed(4,40);             //initialize all motors to 40% power
goFor(8);                     //run the motors at the initialized state for 8 seconds

while ( getVehiclePostion() > 407) {
    motorSpeed(4,25);         //initialize all motors to 25% power
}

reverse(4);                   //reverse all motors
motorSpeed(4,30);             //initialize all motors to 30% power
goFor(2);                     //run the motors at the initialized state for 2 seconds
brake(4);                     //brake all motors

 

Performance Test 3

The following code was written to test AEV for the course in Performance Test 3.

reverse(2);                   //reverse motor 2
motorSpeed(4,33);             //initialize all motors to 33% power
goToAbsolutePosition(230);    //go to absolute position 230 marks
brake(4);                     //brake all motors
motorSpeed(4,0);              //initialize all motors to 0 power
goToAbsolutePosition(270);    //go to absolute position 270 marks

while ( getVehiclePostion() < 303 ) {
    motorSpeed(4,22);         //initialize all motors to 22% power
}

reverse(4);                   //reverse all motors
motorSpeed(4,21);             //initialize all motors to 21% power
goFor(1);                     //run the motors at the initialized state for 1 second

brake(4);                     //brake all motors
reverse(4);                   //reverse all motors
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(7);                     //run the motors at the initialized state for 7 seconds

motorSpeed(4,32);             //initialize all motors to 32% power
goToAbsolutePosition(475);    //go to absolute position 475 marks
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(1.5);                   //run the motors at the initialized state for 1.5 seconds
while ( getVehiclePostion() < 611) {
    motorSpeed(4,22);         //initialize all motors to 22% power
}

reverse(4);                   //reverse all motors
motorSpeed(4,27);             //initialize all motors to 27% power
goFor(1);                     //run the motors at the initialized state for 1 second

brake(4);                     //brake all motors
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(5);                     //run the motors at the initialized state for 5 seconds

motorSpeed(4,43);             //initialize all motors to 43% power
goToAbsolutePosition(425);    //go to absolute position 425 marks
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(2.2);                   //run the motors at the initialized state for 2.2 seconds

while ( getVehiclePostion() > 360) {
    motorSpeed(4,42);         //initialize all motors to 42% power
}

reverse(4);                   //reverse all motors
motorSpeed(4,37);             //initialize all motors to 37% power
goFor(1);                     //run the motors at the initialized state for 1 second

brake(4);                     //brake all motors
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(7);                     //run the motors at the initialized state for 7 seconds
reverse(4);                   //reverse all motors
motorSpeed(4,45);             //initialize all motors to 45% power
goToAbsolutePosition(260);    //go to absolute position 260 marks
motorSpeed(4,0);              //initialize all motors to 0 power
goFor(2);                     //run the motors at the initialized state for 2 seconds

while ( getVehiclePostion() > 90) {
    motorSpeed(4,32);         //initialize all motors to 32% power
}

reverse(4);                   //reverse all motors
motorSpeed(4,40);             //initialize all motors to 40% power
goFor(2);                     //run the motors at the initialized state for 2 seconds
brake(4);                     //brake all motors