THE FOLLOWING ARDUINO CODE WAS USED FOR VARIOUS STEPS
IN THE PROCESS TO FIND THE BEST SOLUTION TO THE PROBLEM.
EACH IMPLEMENTATION IS LABELED ACCORDING TO ITS PURPOSE
AND LOCATION OF EXECUTION.
// PT01 Testing - Design (Hitchcock 308) // Scenario designed to travel from the starting position to the gate // in order to test the individual energy usages // of the different designs tested. reverse(4); // Run all motors at 35% power until it reaches a relative position of 68 marks. motorSpeed(4, 35); goToRelativePosition(68); // Stop all motors and wait for 14 seconds // (7 seconds to account for coasting, 7 seconds for gate) motorSpeed(4,0); goFor(14); // PT02 Testing - Efficiency (Hitchcock 308) not full run // Scenario designed to travel from the starting position to the gate, // wait for 7 seconds, travel to the end and connect with the cargo on // the rail. This code is in anticipation of a full // scenario for the project. reverse(4); motorSpeed(4,35); goToRelativePosition(68); motorSpeed(4,0); goFor(14); motorSpeed(4,35); goToRelativePosition(78); motorSpeed(4,0); goFor(5); // PT03 Energy Efficiency and Full Run Testing // Scenario 1 // Orient direction correctly reverse(4); // Start to shutdown point for gliding motorSpeed(4,35); goToRelativePosition(70); // Glide from shutdown position to gate sensor and wait for 7 seconds // start to gate takes about 8 seconds, 7 additional for gate opening motorSpeed(4,0); goFor(15); // Run motors at 35% power until relativePosition of 70 marks motorSpeed(4,35); goToRelativePosition(70); // Glide to cargo and wait 5 seconds for secure connection motorSpeed(4,0); goFor(13); // Reverse motors for trip back reverse(4); // Cargo retrieval area to gate sensor motorSpeed(4,45); goToRelativePosition(132); // Glide to gate and wait 7 seconds motorSpeed(4,0); goFor(14); // 2nd gate glide to end motorSpeed(4,45); goToRelativePosition(140); // HITCHCOCK 224 CODE WITH LOOPS // TRIP FROM START TO END //----------------------- reverse(4); // Start to gate motorSpeed(4,35); goToRelativePosition(137); motorSpeed(4,0); goFor(8); // Correct if short at first gate while (getVehiclePostion() < 465) { motorSpeed(4, 20); goFor(0.5); } // Wait for gate to open motorSpeed(4,0); goFor(9); // Gate glide to end motorSpeed(4,35); goToRelativePosition(143); motorSpeed(4,0); goFor(8); // If short, correct to end while (getVehiclePostion() < 925) { motorSpeed(4, 20); goFor(0.5); } motorSpeed(4,0); goFor(5); // TRIP BACK FROM FINISH TO START //------------------------------------------- // Prepare for trip back by reversing motors reverse(4); // Glide back from end to gate motorSpeed(4,45); goToRelativePosition(-245); motorSpeed(4,0); goFor(6); // If short, correct to gate on the way back while (getVehiclePostion() > 540) { motorSpeed(4, 42); goFor(0.5); } motorSpeed(4,0); goFor(9); // After gate opening, glide to end motorSpeed(4,45); goToRelativePosition(-263); motorSpeed(4,0); goFor(8); // If short, correct to end. while (getVehiclePostion() > 05) { motorSpeed(4, 35); goFor(0.5); } brake(4); // HITCHCOCK 308 CODE WITH LOOPS (V1) // TRIP TO END //----------------------- reverse(4); // Start to gate motorSpeed(4,35); goToRelativePosition(135); motorSpeed(4,0); goFor(8); // Correct if short at first gate while (getVehiclePostion() < 460) { motorSpeed(4, 15); goFor(0.5); } // Wait for gate to open motorSpeed(4,0); goFor(7); // Gate glide to end motorSpeed(4,35); goToRelativePosition(156); motorSpeed(4,0); goFor(8); // If short, correct to end while (getVehiclePostion() < 950) { motorSpeed(4, 15); goFor(0.5); } motorSpeed(4,0); goFor(5); // TRIP BACK TO START //------------------------------------------- // Prepare for trip back by reversing motors reverse(4); // Glide back from end to gate motorSpeed(4,45); goToRelativePosition(-258); motorSpeed(4,0); goFor(6); // If short, correct to gate on the way back while (getVehiclePostion() > 538) { motorSpeed(4, 45); goFor(0.5); } motorSpeed(4,0); goFor(9); // After gate opening, glide to end motorSpeed(4,45); goToRelativePosition(-288); motorSpeed(4,0); goFor(8); // If short, correct to end. while (getVehiclePostion() > 7) { motorSpeed(4, 35); goFor(0.5); } brake(4); THE CODE IMPLEMENTATION BELOW WAS THE CODE USED FOR THE FINAL TESTS CONDUCTED IN PERFORMANCE TEST 04. // HITCHCOCK 308 CODE WITH LOOPS (V2) // TRIP TO END //----------------------- reverse(4); // Start to gate motorSpeed(4,34); goToRelativePosition(138); motorSpeed(4,0); goFor(8); // Correct if short at first gate while (getVehiclePostion() < 469) { motorSpeed(4, 20); goFor(0.5); } // Wait for gate to open motorSpeed(4,0); goFor(7); // Gate glide to end motorSpeed(4,35); goToRelativePosition(156); motorSpeed(4,0); goFor(8); // If short, correct to end while (getVehiclePostion() < 950) { motorSpeed(4, 20); goFor(0.5); } motorSpeed(4,0); goFor(5); // TRIP BACK TO START //------------------------------------------- // Prepare for trip back by reversing motors reverse(4); // Glide back from end to gate motorSpeed(4,45); goToRelativePosition(-264); motorSpeed(4,0); goFor(6); // If short, correct to gate on the way back while (getVehiclePostion() > 535) { motorSpeed(4, 35); goFor(0.5); } motorSpeed(4,0); goFor(9); // After gate opening, glide to end motorSpeed(4,45); goToRelativePosition(-300); motorSpeed(4,0); goFor(8); // If short, correct to end. while (getVehiclePostion() > 8) { motorSpeed(4, 33); goFor(0.5); } brake(4);