Preliminary Research and Design Code:
Lab 1 Code
celerate(1, 0, 15, 2.5); //accelerate motor 1 from zero to 15 percent power in 2.5 seconds
motorSpeed(1, 15); //motor 1 set to 15 percent power
goFor(1); //motor 1 goes for 1 second at set speed
brake(1); // brake motor 1
celerate(2, 0, 27, 4); //accelerate motor 2 from zero to 27 percent power in 4 seconds
motorSpeed(2, 27); //motor 2 power set to 27 percent
goFor(4); //motor 2 goes for 4 seconds at set power
celerate(2, 27, 15, 1); /*motor 2 decelerates from 27 percent power to 15 percent power in one second*/
brake(2); //brake motor 2
reverse(2); //reverse motor 2
celerate(4, 0, 31, 2); //accelerate both motors from 0 to 31 percent in 2 seconds
motorSpeed(4, 35); //both motors set to 35 percent power
goFor(1); //both motors go for 1 second at set power
brake(2); //brake both motors
motorSpeed(1, 35); //motor 1 set to 35 percent power
goFor(3); //motor 1 goes for 3 seconds at set power
brake(4); //brake both motors
goFor(1); //wait for 1 second
reverse(1); //reverse both motors
celerate(1, 0, 19, 2); //accelerate motor 1 from 0 to 19 percent power in 2 seconds
motorSpeed(2, 35); //set motor 2 to 35 percent power
motorSpeed(1, 19); //set motor 1 to 19 percent power
goFor(2); //both motors go for 2 seconds at set powers
motorSpeed(1, 19); //set motor 1 to 19 percent power
motorSpeed(2, 19); //set motor 2 to 19 percent power
goFor(2); //go for 2 seconds at set power for both motors
celerate(4, 19, 0, 3); //decelerate both motors from 19 percent power to 0 in 3 seconds
brake(4); //brake both motors
Lab 2 Code
motorSpeed(4, 25); //both motors set to 25 percent power
goFor(2); //both motors go for 2 seconds at set power
motorSpeed(4, 20); //both motors set to 20 percent power
goToAbsolutePosition(24.6); //go to absolute position 24.6 ticks
reverse(4); //reverse both motors
motorSpeed(4, 30); //both motors set to 30 percent power
goFor(1.5); //both motors go for 1.5 seconds at set power
brake(4); //brake both motors
Lab 3 Code
celerate(4, 0, 25, 3); //accelerate both motors from 0 to 25 percent power in 3 seconds
motorSpeed(4, 25); //set both motors to 25 percent power
goFor(1); //both motors go for 1 second at set power
motorSpeed(4, 20); //set both motors to 20 percent power
goFor(2); //both motors go for 2 seconds at set power
reverse(4); //reverse both motors
motorSpeed(4, 25); //set both motors to 25 percent power
goFor(2); //both motors go for 2 seconds at set power
brake(4); //brake both motors
Advanced R&D Code
This was the code used to complete Performance Test 1:
celerate(4,0,70,2); //accelerate all motors from 0 to 70 percent power in 2 seconds
goToAbsolutePosition(-255); //Go to 255 ticks in the negative direction
brake(4); //Brake all motors
reverse(4); //reverse all motors
motorSpeed(4,75); //set all motors to 75 percent power
goFor(1); //go for 1 second
brake(4); //brake all motors
reverse(4); //reverse all motors
motorSpeed(4,0); //all motors set to zero percent power
goFor(7); //stand still for 7 seconds
celerate(4,0,70,2); //accelerate all motors from 0 to 70 percent power in 2 seconds
motorSpeed(4,70); //set all motors to 70 percent power
goFor(2); //go for 2 seconds at set power
brake(4); //brake all motors
This was the code used to complete Performance Test 2:
celerate(4,0,38,2); //accelerate from 0 to 48 percent power in 2 seconds
goToAbsolutePosition(-240); //go 240 ticks from start, absolute position -240
brake(4); //brake all motors
reverse(4); //reverse all motors
motorSpeed(4,55); //set all motors to 55 percent power
goFor(1); //go for 1 second at 55 percent power
brake(4); //brake all motors
reverse(4); //reverse all motors
motorSpeed(4,0); //set motors to 0 percent power
goFor(7); //wait for 7 seconds for gate
motorSpeed(4,38); //all motors set to 38 percent power
goToAbsolutePosition(-465); //go to absolute position -465 ticks
brake(4); //brake all motors
reverse(4); //reverse all motors
motorSpeed(4, 40); //set all motors to 40 percent power
goFor(1); //go for 1 second at 40 percent power
reverse(4); //reverse all motors
motorSpeed(4,0); //all motors set to zero percent power
goFor(8); //wait for 8 seconds to latch to caboose
reverse(4); //reverse motors
motorSpeed(4, 52); //set all motors to 52 percent power
goFor(3); //go for 3 seconds at 52 percent power to leave station with caboose
brake(4); //brake all motors
This was the code used to complete the Final Performance Test:
This was the code used to complete a random run, to collect data on the power used by the AEV at different speeds, and ensure that the reflectance sensors were working as expected:
celerate(4,0,70,4); //accelerate all motors from 0 to 70 percent power in 4 seconds
goToAbsolutePosition(-110); //Go 110 ticks
brake(4); //brake all motors
reverse(4); //reverse direction of all motors
motorSpeed(4,70); //set all motors to 70 percent power
goToAbsolutePosition(100); //go 100 ticks back towards start
brake(4); //brake all motors
This was the code used to run the distance test for advanced research and design part 3:
motorSpeed(4, 50) // all motors run with 50% power on all motors
goFor(10) // goes for 10 seconds
motorSpeed(4, 25) //all motors run with 25% power, for tests requiring 25% power
goFor(10) // runs motors at 25% power for 10 seconds