In the past few weeks, the team put the focus on code development for AEV performance. The task is to operate AEV, perform a certain routine automatically, safly and consistently, in both time and energy conserved fashion. Before the team put the concern on energy efficiency, the AEV need to be assured for its consistency in terms of reach certain position and be able to stop to avoid potential crashes. Hence the team developed three version of code to gradually improve the adaptability, adjustability and consistency.

Code Version 1

const int mark1st = 260;

const int mark2nd = 580;

const int mark3rd = 380;

const int mark4th = 0;

// GO TO THE GATE

motorSpeed(4,20);

goToAbsolutePosition(mark1st);

brakeStop();

goFor(7);

//GO TO THE LOADING ZONE

motorSpeed(4,20);

goToAbsolutePosition(mark2nd);

brakeStop();

goFor(5);

//BACK TO GATE

reverse(4);

motorSpeed(4,20);

goToAbsolutePosition(mark3rd);

brakeStop();

goFor(7);

//GET OUT

/* motorSpeed(4,20);

goToAbsolutePosition(mark4th);

brakeStop();

*/

}

// BRAKE FUNCTION

void brakeStop() {

const Int breakingPower =15;

int iniDir = getVehicleDirection();

int finDir =iniDir;

reverse(4);

do {

int currentPosition = getVehiclePostion();

motorSpeed(4,breakingPower);

goFor(minTimeLapse/1000.0);

finDir = getVehicleDirection();

} while (finDir == iniDir);

reverse(4);

brake(4);

}

The focus of this code is to put all the important marks in the beginning of the code for easy adjustment, followed by the good coding practice. And an approach to reach for consistency is the breakStop() function which can reverse the motor to stop the AEV until it change its direction.

Code Version 2

// BRAKE FUNCTION

void brakeStopAt(int brakingPower,int stopMark) {

int iniDir = getVehicleDirection();

int finDir =iniDir;

reverse(4);

do {

//adjust brake power according to the distance between target mark and current mark

//using 10 as range for adjust at two stop of braking power

if (currentPosition<stopMark+10&&currentPosition>stopMark-10) {

motorSpeed(4,brakingPower);

goFor(minTimeLapse/1000.0);

} else {

motorSpeed(4,brakingPower-5);

goFor(minTimeLapse/1000.0);

}

finDir = getVehicleDirection();

} while (finDir == iniDir);

reverse(4);

brake(4);

}

This version of code only change the brakeStop() function to brakeWithPowerStopAt(int brakePower, int stopMark). Introducing a parameter “brakePower” to adjust the reverse power for each stage allow the AEV to adapt the weight change after picking up the caboose. After the total weight increase, the AEV need to increase braking power to stop properly. Another change to the code is adding “stopMark” to the braking function, allow it adjust the braking power itself according to AEV’s current location.

Other than the braking function, the team also added underlined code to change running power in 2nd and 3rd stage to adapt to the hump on the track.

//GO TO THE LOADING ZONE

motorSpeed(4,20);

goFor(2);

motorSpeed(4,15);

goToAbsolutePosition(mark2nd);

brakeStop();

goFor(5);

//BACK TO GATE

reverse(4);

motorSpeed(4,20);

goFor(1);

motorSpeed(4,25);

goToAbsolutePosition(mark3rd);

brakeStop();

goFor(7);

Figure.2 V2 code results summery

Code Version 3

// BRAKE FUNCTION

//@breakingPower = power of break @stopMark is the targeted stopping pos

void brakeStopAt(int breakingPower,int stopMark) {

const int STOP_TIME = 4;

int iniPos = getVehiclePostion();

int posCountTime = 0;

int iniDir = getVehicleDirection();

int finDir =iniDir;

reverse(4);

do {

//check position of the AEV

int currentPosition = getVehiclePostion();

//compare current pos and past pos, if same, count time +1

if (currentPosition == iniPos) {

posCountTime++;

}

//update the pos

iniPos = currentPosition;

//adjust break power according to the distance between target mark and current mark

//using 10 as range for adjust at two stop of breaking power

if (currentPosition<stopMark+10&&currentPosition>stopMark-10) {

motorSpeed(4,breakingPower+5);

goFor(minTimeLapse/1000.0);

} else {

motorSpeed(4,breakingPower);

goFor(minTimeLapse/1000.0);

}

finDir = getVehicleDirection();

} while ((finDir == iniDir)&&(posCountTime<STOP_TIME));

reverse(4);

brake(4);

}

This version of code only fine tuned the braking function by adding one more condition check to determine when to stop the brake, that is to check whether the AEV is stopped(position no longer change). And this code lead to our successful final run.

Figure.2 Final performance test run

If you have trouble accessing this page and need to request an alternate format, contact u@osu.edu

The content of this site is published by the site owner(s) and is not a statement of advice, opinion, or information pertaining to The Ohio State University. Neither text, nor links to other websites, is reviewed or endorsed by The Ohio State University.