arbitrator doesn't seem to be cycling

This is where you talk about the RCX software itself, installation issues, and programming talk.

Moderator: roger

arbitrator doesn't seem to be cycling

Postby whacko » Fri Dec 12, 2008 9:33 pm

here is the class file:

Code: Select all
import josx.robotics.*;
import josx.platform.rcx.*;
public class nRobot {
   boolean f=true,c=true,s;
   public class goForward implements Behavior {
         public boolean takeControl() {
           return true;
         }
         public void suppress() {
            Motor.A.stop();
            Motor.C.stop();
         }
         public void action() {
           Motor.A.setPower(3);
           Motor.C.setPower(3);
            Motor.A.forward();
            Motor.C.forward();
            Arbitrator a = new Arbitrator(new Behavior[]{
               new nRobot.goCrazy()
            });
            a.start();
         }
      }
   public class goCrazy implements Behavior {
         public boolean takeControl() {
            return true;
         }
         public void suppress() {
            Motor.A.stop();
            Motor.C.stop();
         }
         public void action() {
            // Back up:
           Motor.A.setPower(4);
           Motor.C.setPower(4);
            Motor.A.backward();
            Motor.C.backward();
            try{Thread.sleep(1000);}catch(Exception e) {}
            // Rotate by causing only one wheel to stop:
            Motor.A.stop();
            try{Thread.sleep(500);}catch(Exception e) {}
            Motor.C.stop();
         }
      }
   public class doSound implements Behavior {
         public boolean takeControl() {
            return true;
         }
         public void suppress() {
            // Nothing to suppress
         }
         public void action() {
            play();
            try{Thread.sleep(3000);}catch(Exception e) {}
            System.exit(0);
         }

         public  void play() {
            for(int i=0;i<10000; i+=5) {
               Sound.playTone((i*100), i);
               try {
                  Thread.sleep(200);
               } catch (InterruptedException e) {}
            }
         }
      }
   public static void main(String [] args) {
        nRobot x = new nRobot();
         Behavior b1 = x.new goForward();//kewl,huh?
         Behavior b2 = x.new goCrazy();
         Behavior b3 = x.new doSound();
         Behavior [] bArray = {b1, b3, b2};
      Arbitrator arb = new Arbitrator(bArray);
      arb.start();
      }


i'm forced to use emu-lejosrun since school is shutdown. now when i run the code only the goCrazy() class is run. what little i've read lead me to think that the default behavior<sic> is for cycling through each at least once? i also tried some inner classes applying separate Arbitrator()'s as well with the same result, only one Behavior() like so:

Code: Select all
public static void main(String [] args) {
      nRobot x = new nRobot();// instance of current class
      Arbitrator a = new Arbitrator(new Behavior[]{
                           x.new goForward(),x.new goCrazy()
                        });
            a.start();
      Arbitrator b = new Arbitrator(new Behavior[]{
                     x.new goCrazy()
                  });
            b.start();
      }


could someone please help? thanks in advanced.

w
whacko
New User
 
Posts: 1
Joined: Fri Dec 12, 2008 9:17 pm

Postby mpthompson » Wed Mar 04, 2009 7:37 am

I think I've run into the same problem which I've described in the following posting in the NXT forum:

viewtopic.php?t=1377

The Arbitrator class seems to be broken.

Unfortunately, I don't have a solution. Hopefully someone will have some more insight to help us both.

Mike
mpthompson
New User
 
Posts: 3
Joined: Wed Mar 04, 2009 1:33 am


Return to RCX Software

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff