//Step the Bilby advance(1); //step forwards showsense(); if(!frontwhite){ //front sensor black? if (edge == right){ //blocked right? for(i = 1;i<21;i++){ rotate(anticlock); //turn left showsense(); } //a }else{ for(i = 1;i<21;i++){ rotate(clockwise); //turn right showsense(); } //b }; edge = 0; }else{ if(!leftwhite){ //left sensor black? edge = left; //set edge flag rotate(clockwise); rotate(clockwise); //turn right two }else{ if(!rightwhite){ //right sensor black? edge = right; }; rotate (anticlock); //turn left }; }; if(running){setTimeout('steppit();',50);} else{document.panels.doit.value='Run Bilby';};
//Reset Bilby theta = 3.1416 / 40; //angle to rotate dd = .05; //step size sinTheta = Math.sin(theta); cosTheta = Math.cos(theta); sb = -1; //bilby sin cb = 0; //bilby cos xb = .5; //Initial bilby x measured in 'squares' yb = 15.5; edge=0; xs = new Array( 0, -.51, .51); //Sensor positions ys = new Array(.5, .4, .4 ); //front,left,right wrt bilby centre