Evolution of Code

[Tutorial Code]

This wasn’t Team G’s code, but rather the initial code Team G was told to program in t0 0btain an understanding of how Arduino worked.

celerate(4,0,100,3);

motorSpeed(4,100);

goFor(1);

motorSpeed(4,100);

goFor(2);

reverse(4);

motorSpeed(4,25);

goFor(2);

 

[performance test 1.0]

This was the first stab in the dark at performance test 1. The AEV’s design was heavily modified just after this, including reversing the engines.

celerate(4,0,25,2);

motorSpeed(4,25);

goToRelativePosition(100);

celerate(4,0,25,2);

motorSpeed(4,25);

goToRelativePosition(170);

reverse(4);

celerate(4,25,0,2);

 

[Performance Test 1.2]

A more fully formed version. The first five lines would remain almost unchanged however. This version established the basic formula Team G would need to complete the track.

reverse(4);

celerate(4,0,34,3);

motorSpeed(4,34);

goToRelativePosition(270);

reverse(4);

celerate(4,50,0,1.2);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,35,1.5);

motorSpeed(4,35);

goFor(2);

 

[Full Track Draft]

More hardware updates occurred, resulting in Simon Crowell trying to lay out the entirety of the final code. While large swaths of this code went unused, it is included for the sake of thoroughness. It did have some use as a rough guideline for what the AEV needed to ‘know’ about what it was doing, rather than looking at the task from a human perspective.

reverse(4);

celerate(4,0,34,3);

motorSpeed(4,34);

goToRelativePosition(270);

reverse(4);

celerate(4,50,0,1.2);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,37,1.5);

motorSpeed(4,37);

goFor(1.75);

brake(4);

goFor(10.25);

reverse(4);

celerate(4,0,39.25,1.5);

motorSpeed(4,39.25);

//goToRelativePosition(-255);

goToAbsolutePosition(400);

reverse(4);

//celerate(4,55,0,0.5);

motorSpeed(4,60);

goFor(1);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,52,1.0);

motorSpeed(4,52);

goToAbsolutePosition(150);

reverse(4);

motorSpeed(4,52);

goFor(3);

[draft code for performance test 3]

celerate(4,0,25,2);

motorSpeed(4,25);

goToRelativePosition(170);

reverse(4);

celrate(4,25,0,2);

goToAbsolutePosition(332);

brake(4);

goFor(7);

reverse(4);

celerate(4,0,20,2);

motorSpeed(4,20);

goToRelativePosition(147.75);

reverse(4);

motorSpeed(4,20);

goFor(2);

reverse(4)

motorSpeed(4,10);

goToAbsolutePosition(590);

brake(4);

reverse(4);

celerate(4,0,25,2);

motorSpeed(4,25);

goToRelativePosition(-170);

reverse(4);

celrate(4,25,0,2);

goToAbsolutePosition(-162);

brake(4);

goFor(7);

reverse(4);

celerate(4,0,25,2);

motorSpeed(4,25);

goToRelativePosition(-170);

reverse(4);

celerate(4,25,0,2);

brake(4);

 

 

[Performance Test 2 final version]

New version of the code after hardware updates. Some small portions of the previous draft code were adapted and added in where possible.  Simon Crowell begins to experiment with commenting portions of the code.

reverse(4);

celerate(4,0,34,3);

motorSpeed(4,34);

goToRelativePosition(275);

reverse(4);

celerate(4,50,0,1.2);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,37,1.5);

motorSpeed(4,37);

goFor(2.5);

brake(4);

goFor(10.25);

reverse(4);

celerate(4,0,37,1.5);

motorSpeed(4,37);

//goToRelativePosition(-255);

goToAbsolutePosition(380);

reverse(4);

celerate(4,50,0,1.1);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,35,1.5);

motorSpeed(4,35);

goToAbsolutePosition(100);

 

[Full Track Draft]

More hardware updates occurred, resulting in Simon Crowell trying to lay out the entirety of the final code. While large swaths of this code went unused, it is included for the sake of thoroughness. It did have some use as a rough guideline for what the AEV needed to ‘know’ about what it was doing, rather than looking at the task from a human perspective.

reverse(4);

celerate(4,0,34,3);

motorSpeed(4,34);

goToRelativePosition(270);

reverse(4);

celerate(4,50,0,1.2);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,37,1.5);

motorSpeed(4,37);

goFor(1.75);

brake(4);

goFor(10.25);

reverse(4);

celerate(4,0,39.25,1.5);

motorSpeed(4,39.25);

//goToRelativePosition(-255);

goToAbsolutePosition(400);

reverse(4);

//celerate(4,55,0,0.5);

motorSpeed(4,60);

goFor(1);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,52,1.0);

motorSpeed(4,52);

goToAbsolutePosition(150);

reverse(4);

motorSpeed(4,52);

goFor(3);

[draft code for performance test 3]

celerate(4,0,25,2);

motorSpeed(4,25);

goToRelativePosition(170);

reverse(4);

celrate(4,25,0,2);

goToAbsolutePosition(332);

brake(4);

goFor(7);

reverse(4);

celerate(4,0,20,2);

motorSpeed(4,20);

goToRelativePosition(147.75);

reverse(4);

motorSpeed(4,20);

goFor(2);

reverse(4)

motorSpeed(4,10);

goToAbsolutePosition(590);

brake(4);

reverse(4);

celerate(4,0,25,2);

motorSpeed(4,25);

goToRelativePosition(-170);

reverse(4);

celrate(4,25,0,2);

goToAbsolutePosition(-162);

brake(4);

goFor(7);

reverse(4);

celerate(4,0,25,2);

motorSpeed(4,25);

goToRelativePosition(-170);

reverse(4);

celerate(4,25,0,2);

brake(4);

 

[Performance Test 3.0]

New version adding and improving on the old. More use of commenting as code monkey grapples with variations in track.

reverse(4);

celerate(4,0,34,3);

motorSpeed(4,34);

goToRelativePosition(270);

reverse(4);

celerate(4,50,0,1.2);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,37,1.5);

motorSpeed(4,37);

goFor(1.75);

brake(4);

goFor(10.25);

reverse(4);

celerate(4,0,39.25,1.5);

motorSpeed(4,39.25);

//goToRelativePosition(-255);

goToAbsolutePosition(450);

brake(4);

goToAbsolutePosition(415);

reverse(4);

//celerate(4,55,0,0.5);

motorSpeed(4,60);

goFor(1);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,52,1.0);

motorSpeed(4,52);

goToAbsolutePosition(240);

brake(4);

goToAbsolutePosition(50);

reverse(4);

motorSpeed(4,52);

goFor(3);

 

[Performance Test 3.1]

Code Monkey makes a breakthrough in commenting as the onset of finals causes sufficient sleep deprivation that he can no longer rely on his memory to remember how yesterday’s test ran. During the period where this code was undergoing constant adjustment, the AEV was plagued with two issues. Firstly, the drain on the battery was finally sufficient to cause inconsistencies in the code before we had a successful test. Secondly, though this was not realized until later, the reluctance sensors were not maintaining constant contact with the track once the cargo was attached. This point marks a sudden drop in the progress-per-day of this group, a downturn that would persist up till the end of the project.

reverse(4);

celerate(4,0,34,3);

motorSpeed(4,34);

goToRelativePosition(265);

//originally at 270

//works

//maybe have it coast in?

reverse(4);

celerate(4,50,0,1.2);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,37,1.5);

motorSpeed(4,37);

goFor(1.75);

brake(4);

goFor(10.25);

reverse(4);

celerate(4,0,39.25,1.5);

motorSpeed(4,39.25);

//goToRelativePosition(-255);

goToAbsolutePosition(435);

//originally 450

//435 worked. Just barely made it inside.

brake(4);

goToAbsolutePosition(415);

reverse(4);

//celerate(4,55,0,0.5);

motorSpeed(4,60);

goFor(1);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,52,1.0);

motorSpeed(4,50);

//originally 52

goToAbsolutePosition(275);

//originally 240->250->260->275

brake(4);

goToAbsolutePosition(120);

//originally 50-70->90->120

reverse(4);

motorSpeed(4,52);

goFor(2.5);

//originally 3

 

[Performance Test 3.2]

Commenting finally resembling something actually helpful. A breakthrough is made in storing different values of code to be swapped out depending on which floor the test is being run on. Post-second gate portion receives fine-tuning.

reverse(4);

celerate(4,0,34,3);

motorSpeed(4,34);

goToAbsolutePosition(270);

//originally at 270, 265 on third floor, 270 on 2nd floor.

//works

//maybe have it coast in?

reverse(4);

celerate(4,50,0,1.2);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,37,1.5);

motorSpeed(4,37);

goFor(1.75);

//maybe reduce this to have it coast longer to hit the caboose? Worries about hitting with enough force.

brake(4);

goFor(10.25);

reverse(4);

celerate(4,0,39.25,1.5);

motorSpeed(4,39.25);

//goToRelativePosition(-255);

goToAbsolutePosition(440);

//originally 450->435->440

//435 worked. Just barely made it inside.

brake(4);

goToAbsolutePosition(415);

reverse(4);

//celerate(4,55,0,0.5);

motorSpeed(4,60);

goFor(1.2594);

//originally at 1, 1.5->1.4->1.2594 for 2nd floor

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,52,1.0);

motorSpeed(4,50);

//originally 52

goToAbsolutePosition(285);

//originally 240->250->260->275->280->285

brake(4);

goToAbsolutePosition(120);

//originally 50-70->90->120

reverse(4);

motorSpeed(4,52);

goFor(1.7);

//originally 3->2.5->2.0->1.5->1.7

//it works!

 

[Performance Test 3.3 – Final Code]

This final coding passed the third Performance Test flawlessly. Post-final gate to end massively overhauled. Several instances of power-braking replaced with coasting to reduce energy consumption as much as possible.

reverse(4);

celerate(4,0,34,3);

motorSpeed(4,34);

goToAbsolutePosition(270);

//NOTCODE comment out above and uncomment below to activate coasting test.

//goToAbsolutePosition(260);

//move back further. Need to fix.

//brake(4);

//goFor(0.5);

//NOTCODE end of coasting test

reverse(4);

celerate(4,50,0,1.2);

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,37,1.5);

motorSpeed(4,37);

goFor(1.75);

//NOTCODEmaybe reduce this to have it coast longer to hit the caboose? Worries about hitting with enough force.

brake(4);

//NOTCODEcommenting out below to test coasting

goFor(10.25);

reverse(4);

celerate(4,0,39.25,1.5);

motorSpeed(4,39.25);

goToAbsolutePosition(440);

//NOTCODE originally 450->435->440

//NOTCODE 435 worked. Just barely made it inside.

brake(4);

goToAbsolutePosition(400);

//goToAbsolutePosition(395); swap between this an motor speed stop

//NOTCODE originally at 415->400->396->390->395 (for decreasing motor speed)

//NOTCODE 415 worked on second floor

reverse(4);

celerate(4,57,0,0.6);

//NOTCODE could probably be used insted of motor speed if power really becomes an issue.

//motorSpeed(4,54); swap between this and celerate

//NOTCODE 60->54

//goFor(1.2594); swap between this and celerate

//NOTCODE 1.5->1.4->1.2594 for 2nd floor

//NOTCODE 1 second for 3rd floor

motorSpeed(4,0);

goFor(7);

reverse(4);

celerate(4,0,52,1.0);

motorSpeed(4,50);

//NOTCODE originally 52

goToAbsolutePosition(285);

//NOTCODE originally 240->250->260->275->280->285

//goToAbsolutePosition(305);

brake(4);

//goToAbsolutePosition(120); swap between this and motor speed

//NOTCODE originally 50-70->90->120

//+goToAbsolutePosition(125);

//NOTCODE above is for celerate

reverse(4);

celerate(4,55,0,2.7);

//motorSpeed(4,52);

//goFor(1.7);

//NOTCODE originally 3->2.5->2.0->1.5->1.7

//NOTCODE it works!