Arduino Code Index

The AEV brakes, and to assist with braking the AEV reverses at 30% power for 1.2 seconds.Function Definitions:

*  Information found in Preliminary R&D 

celerate(m,p1,p2,t) – Accelerates or decelerates the input motor (m) from an initial power (p1) to a final power (p2) a for a given amount of time, in seconds (t). To accelerate or decelerate all motors at once use 4 for the input motor.

motorSpeed(m,p) – Initializes motor(s) at percent power

goFor(t) – Maintains the last state of the motors for t seconds.

brake(m) – Cuts power to the input motor. Input 4 to cut the power to all motors.

reverse(m) – Reverses the input motor. Input 4 to reverse all motors.

goToRelativePosition(n) – Allows the vehicle to travel a certain number of marks from its current position

goToAbsolutePosition(n) – Allows vehicle to travel a certain number of marks from the overall starting position

 

Scenario 1:

celerate(1,0,15,2.5); //accelerate motor 1
goFor(1); //continue motor 1 at set speed for 1 second
brake(1); //cut motor 1
celerate(2,0,27,4); //accelerate motor 2
goFor(2.7); //hold state for 2.7 seconds
celerate(2,27,15,1); //decelerate motor 2
brake(2); //cut motor 2
reverse(2); //reverse motor 2
celerate(4,0,31,2); //accelerate all motors
celerate(4,0,35,1); //accelerate all motors
goFor(1); //hold state for 1 second
brake(2); //cut motor 2
celerate(1,35,35,1); //accelerate motor 1
goFor(3); //hold state for 3 seconds
brake(4); //cut all motors
goFor(1); //hold state for 1 second
reverse(1); //reverse motor 1
celerate(1,0,19,0); //accelerate motor 1
celerate(2,0,35,0); //accelerate motor 2
goFor(2); //hold state for 2 seconds
celerate(2,35,19,0); //decelerate motor 2
goFor(2); //hold state for 2 seconds
celerate(4,19,0,3); //decelerate motor 1
brake(4); //cut all motors

 

Scenario 2:

The AEV was accelerated to 25% power and then dropped back down to 20% power after movement. Then, the AEV went to 295.2332137 marks and then reversed and went for 1.5 seconds and then stopped.

celerate(4,0,25,2);
motorSpeed(4,20);
goToAbsolutePosition(295.2332137);
reverse(4);
motorSpeed(4,30);
goFor(1.5);
brake(4);

 

Scenario 3:

The AEV was accelerated to 25% power, and then the speed was held for a total of 4 seconds and then the power was dropped to 20% and continued for 2 seconds. Afterwards, the AEV reversed, went to 25% and went for 2 seconds before stopping

celerate(4,25,3);

motorSpeed(4,25);

goFor(1);

motorSpeed(4,20);

goFor(2);

reverse(4);

motorSpeed(4,25);

goFor(2);

brake(4);

 

Advanced R&D 1:

The AEV was run for 78 marks at 30%

motorSpeed(4,30);

goToAbsolutePosition(78);

 

Advanced R&D 2:

The AEV was run for 150 marks at 30% power.

motorSpeed(4,30);

goToAbsolutePosition(150);

 

Advanced R&D 3:

The AEV was run for 150 marks at 30% power.

motorSpeed(4,30);

goToAbsolutePosition(150);

 

Performance Test 1:

The AEV was run at 28% power, went for 4 seconds, braked, waited for 9 seconds, and then went past the gate at 35% power for 2 seconds.

reverse(4);
motorSpeed(4,28);
goFor(4);
brake(4);
goFor(9);
motorSpeed(4,35);
goFor(2);

Performance Test 2:

The AEV was run at 28% power for 4.08 seconds and then brakes for 9 seconds. The AEV is then run at 28% power for 1 seconds and then decelerated at 25% power in 2.8 seconds and then the AEV brakes and sits for 7 seconds. Afterwards, the AEV reverses at 5% power and goes for 2 seconds.

reverse(4);

motorSpeed(4,28);

goFor(4.08);

brake(4);

goFor(9);

motorSpeed(4,28);

goFor(1);

celerate(4,28,25,2.8);

brake(4);

goFor(7);

reverse(4);

motorSpeed(4,35);

goFor(2);

brake(4);

Final Performance Test:

The AEV moves at 32% power and goes to240 marks. The AEV brakes, and to assist with braking the AEV reverses at 30% power for 1.2 seconds. The AEV is reversed and if the vehicle is less than 322 marks, it will move towards that distance at 18% power. The AEV then brakes and sits in front of the gate for 9 seconds and then accelerates at 35% power for 260 marks. The AEV brakes, and to assist with braking the AEV reverses at 35% power for 1.2 seconds. The AEV reverses again and  and if it is less than 450 marks it moves to 450 marks at 15% power and then brakes. The AEV then goes to -260 marks at 45% power. The AEV brakes, and to assist with braking the AEV reverses at 35% power for 1.5 seconds. The AEV then reverses and if it is less than 350 marks, the AEV goes to 350 marks at 28% power and then brakes. Finally, the AEV goes to 100 marks at 35 % power. The AEV brakes, and to assist with braking the AEV reverses at 30% power for 1.5 seconds and comes to a stop.

reverse(4);
motorSpeed(4,32);
goToRelativePosition(240);
brake(4);
reverse(4);
motorSpeed(4,30);
goFor(1.2);
reverse(4);
if(getVehiclePostion()<322){
motorSpeed(4,18);
goToRelativePosition(322-getVehiclePostion());
}
brake(4);
goFor(9);
motorSpeed(4,35);
goToRelativePosition(260);
reverse(4);
motorSpeed(4,35);
goFor(1.2);
reverse(4);
//if (getVehiclePostion()<450){
//motorSpeed(4,15);
//goToRelativePosition(450-getVehiclePostion());
//}
brake(4);
goFor(7);
reverse(4);
motorSpeed(4,45);
goToRelativePosition(-260);
reverse(4);
motorSpeed(4,35);
goFor(1.5);
reverse(4);
//if (getVehiclePostion()>350){
//motorSpeed(4,28);
// goToAbsolutePosition(350);
//}
brake(4);
goFor(9);
motorSpeed(4,35);
goToAbsolutePosition(100);
brake(4);
reverse(4);
motorSpeed(4,30);
goFor(1.5);
brake(4);