22 Jul 2002 (updated 23 Jul 2002 at 03:47 UTC)
»
Kanati-1 LIVES!
As I expected, I used a CD jewel case for
the chassie, mounted the three transducers about 45 degrees
apart. May need to move them even farther apart but it never
seems to bump in to anything with the avoidance range set to
4 inches.
I'm using a simple avoidance algorithm;
public static void main() {
int rc;
k = new Kanati(); //create the robot object
System.out.println("K1...online");
k.sleep(5);
k.moving=false;
k.initializeSONAR();
k.minRange=4;
while(true){
//robot code here
CPU.delay(100);
rc=k.checkSONAR();
k.moving=true;
while (rc == 3){
k.move();
CPU.delay(1000);
rc=k.checkSONAR();
}
if (scanForTarget()!=0){
fire();
} else {
k.avoid(rc); // not an enemy, avoid it
}
k.moving=false;
} // while loop
} // main
k is the instantiated kanati class (robot
object)
where
all the real code is at.
The avoid routines determine which sensor
detected
the
obstacle and acts accordingly. If object
detected Forward, backup
and turn in a random direction. If right or left,
turn in the opposite direction.
That's pretty much it so far. I will post
some
pictures
on my website tonight.