Download Final Year Dissertation 2006
Transcript
Faculty of
Information
Technology
this.arbi=arbi;
}
/**
* Returns a boolean to indicate if this behavior should take
control of the robot.
*/
public boolean takeControl() {
if (!rob.collision &&
rob.targetHead==rob.sim.signalDirection(rob)) {
//oldSpeed=rob.speed;
ticks=time2Last;
System.out.println("Value of drive...true");
return true;
}
else {
System.out.println("Value of drive...false");
return false;
}
}
/**
* The code in action() represents the action the robot should
take when the
* this behavior becomes active.
*/
public void action(){
System.out.println("driving...");//+ ticks);
if (!(ticks<0) && !rob.collision) {
//rob.speed=oldSpeed;
rob.speed=0.2;
System.out.println("Ticks so far driving.... "+ticks);
// rob.speed=oldSpeed;
ticks=ticks-1;
}
else {
arbi.busy=false;//
}
//rob.speed=oldspeed;
//rob.forward();
}
public int getTime2Last(){
return time2Last;
}
public void setTime2Last(int ticks){
time2Last=ticks;
}
public String toString(){return "Drive Behaviour";}
}
64