ColorSensor, Behavior action problem

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

Moderators: roger, 99jonathan, imaqine

ColorSensor, Behavior action problem

Postby matejc » Sun Aug 05, 2012 10:03 pm

Hi!
I have problem with Behavior/Arbitrator pattern with leJOS 0.9.1.3 version.
My robot is similar to the BumperCar sample (in source code sample list).
It was upgraded with ColorSensor that is used as floodlight. I would like that floodlight is turned on in dark room otherwise is off.
For that reason, I have used ColorSensor (NXT) and implemented additional Behavior (UseLight). Behavior was tested separately and it works just fine, but combined with DriveForward and HitWallShoot behaviors, it stops working as I would expected. It looks like behavior UseLight is taking control (I am counting calls in method-see code) but behaviors action method is not called (maybe in 20% of the time otherwise is skipped). Behavior UseLight has highes priority.
Any Idea where I am doing wrong?

Thanks in advance :)

My code:
Code: Select all
public class Labirint {
   public  DifferentialPilot pilot;

   public static void main(String[] args) {
      DifferentialPilot pilot = new DifferentialPilot(40f, 180f, Motor.A, Motor.C);
      Behavior drive = new DriveForward(pilot);
       Behavior wall = new HitWallShoot(SensorPort.S4, pilot);
       Behavior [] bArray = {drive, wall, new UseLight(SensorPort.S3)};
       //Behavior [] bArray = {new UseLight(SensorPort.S3)};
       Arbitrator arby = new Arbitrator(bArray);
      LCD.drawString("PRESS TO START", 0, 0);
      Button.waitForAnyPress();
      LCD.clear();
       arby.start();
      
   }
}


Code: Select all
public class UseLight implements Behavior {
   private boolean suppressed = false;
   private ColorSensor light;
   private static final int MIN_LIGHT_PROCENTAGE = 22;
   private static final long DELAY_CONTROL = 3000; // in ms
   private long lastLightReadingTime; // to manage delay
   private long time;
   private int lastLightValue = 0;
   public static boolean debug = false;
    private int debug_action_indicator=0; //counts actions
    private int debug_take_indicator=0; //counts take on
   
   private void readLight(long time) {
      lastLightValue = light.getLightValue();
      lastLightReadingTime = time;
      if (debug) {
         LCD.clear(1);
         LCD.drawString(
               lastLightValue + " l " + light.isFloodlightOn()+"   ", 0, 1);
      }
   }

   private void setLight() {
      if (lastLightValue < MIN_LIGHT_PROCENTAGE) {
         light.setFloodlight(true);
         if (debug)
            LCD.drawString("SET ON! " + debug_take_indicator+","+debug_action_indicator, 0, 4);
      } else {
         light.setFloodlight(false);
         if (debug)
            LCD.drawString("SET OFF! " + debug_take_indicator+","+debug_action_indicator, 0, 4);
      }
   }

   public UseLight(SensorPort port) {
      light = new ColorSensor(port, Color.NONE); // start floodlight off
      lastLightReadingTime = System.currentTimeMillis(); // start takeControl
                                             // with DELAY
   }

   public boolean takeControl() {
      time = System.currentTimeMillis();
      if ((time - lastLightReadingTime) < DELAY_CONTROL)
         return false;
      if (debug) {
         LCD.clear(0);
         LCD.drawString("1",1,0);
      }
      if (debug) {
         if (light.isFloodlightOn())
            LCD.drawString("is ON? ", 0, 5);
         else
            LCD.drawString("is OFF?", 0, 5);
      }
      if (debug) LCD.drawString("2",2,0);
      readLight(time);
      if (debug) LCD.drawString("3",3,0);
      if ((lastLightValue < MIN_LIGHT_PROCENTAGE) && (light.isFloodlightOn())) {
         if (debug) LCD.drawString("4",4,0);
         return false;
         
      }
      if ((lastLightValue >= MIN_LIGHT_PROCENTAGE) && (!light.isFloodlightOn())) {
         if (debug) LCD.drawString("5",5,0);
         return false;
      }
      if (debug) {
         LCD.drawString("6",6,0);
         LCD.drawString("take " + debug_take_indicator+","+debug_action_indicator, 0, 2);
         debug_take_indicator++;
      }
      return true; // change light action
   }

   public void suppress() {
      suppressed = true;
   }

   public  void action() {
      suppressed = false;
      if (debug) {
         LCD.drawString("7",7,0);
         LCD.drawString("action " + debug_action_indicator, 0, 3);
      }
      setLight(); // time calculated in take control
      //Delay.msDelay(2000); // do I need delay (it is not helping) ??
      if (debug) {
         debug_action_indicator++;
         LCD.drawString("8",8,0);
      }
   }
}

In DriveForward class I am using DifferentialPilot class instead of RegulatedMotor class.

Code: Select all
public class DriveForward  implements Behavior {
   private boolean suppressed = false;
   private  DifferentialPilot pilot;
   
   public DriveForward(DifferentialPilot pilot) {
      this.pilot = pilot;
   }
   public boolean takeControl() {
      return true;
   }

   public void suppress() {
      suppressed = true;
   }

   public void action() {
     suppressed = false;
     pilot.forward();
     while( !suppressed ) {
        Thread.yield();
        if(Button.ESCAPE.isDown()) {
            System.exit(1);
        }
     }
     pilot.stop();
   }
}

Code: Select all
public class HitWallShoot implements Behavior {
    private UltrasonicSensor sonar;
    private boolean suppressed = false;
    private DifferentialPilot pilot;
    public HitWallShoot(SensorPort sonarPort,DifferentialPilot pilot)
    {
       this.pilot = pilot;
       sonar = new UltrasonicSensor( sonarPort );
    }

    public boolean takeControl() {
       sonar.ping();
       return sonar.getDistance() < 80;
    }

    public void suppress() {
       suppressed = true;
    }

    public void action() {
       suppressed = false;
       Motor.B.rotate(720);
       while( Motor.B.isMoving() && !suppressed ) {
           Thread.yield();
        }
       Delay.msDelay(200);
       Motor.B.stop();
       pilot.rotate(-90);
       while( pilot.isMoving() && !suppressed ) {
         Thread.yield();
         if(Button.ESCAPE.isDown()) {
             System.exit(1);
         }
       }
       pilot.stop();
    }
}
matejc
New User
 
Posts: 8
Joined: Sat Aug 04, 2012 7:55 pm

Re: ColorSensor, Behavior action problem

Postby gloomyandy » Mon Aug 06, 2012 10:03 am

Hi,
Sorry but this is probably just too complex for anyone to be able to easily help. I suggest that what you do is to make use of the remote console feature via Bluetooth and log all of the various actions to see what exactly is happening. You should then be able to post the trace of what is going on along with the code with the trace statements in it and we may be able to help then...

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: ColorSensor, Behavior action problem

Postby matejc » Mon Aug 06, 2012 11:51 am

Thanks Andy!
Even answer like this is helpful, because I can eliminate obvious mistakes. I will try to dig dipper.
I will report my findings.
matejc
New User
 
Posts: 8
Joined: Sat Aug 04, 2012 7:55 pm

Re: ColorSensor, Behavior action problem

Postby roger » Mon Aug 06, 2012 5:47 pm

Hi matejc,
I have looked at you code, and it seems that the HitWallShoot.action() does not follow the rules for a behavior. It should stop the pilot and MotorB and then exit immediately when suppress() is called. But as it is coded, it will not exit until both MotorB.rotate(720) and pilot.rotate(90) run to completion. Both these calls should use the immediate return option. I do not know if this is the cause

Roger

BTW, why use ColorSensor? What methods does it implement that LightSensor does not?
roger
Moderator
 
Posts: 307
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Re: ColorSensor, Behavior action problem

Postby matejc » Mon Aug 06, 2012 6:02 pm

Thanks Roger, but problem is still here.
ColorSensor is used because my Lego set has just ColorSensor, I have tried LightSensor class but readings were wrong (If I remember like 255).
HitWallShoot behavior is not in this example anymore, but I used Motor.B for shooting and nothing should stop it :), specially not Floodlight. I think that correct would be to have additional behavior just for shooting but both HitWall and Shoot use same takeover criteria. I would probably need some additional states to solve this problem, but this is for another post.

Problem stays:

As suggested I have try to simplify source code (just DriveForward and UseLight behaviors are used) and made some RConsole debug info output!
Problem is same. Behaviors UseLight method takecontrol is called but action is not.
Code: Select all
public class Labirint {
   public  DifferentialPilot pilot;
   public static void main(String[] args) {
      DifferentialPilot pilot = new DifferentialPilot(40f, 180f, Motor.A, Motor.C);
      Behavior drive = new DriveForward(pilot);
           Behavior [] bArray = {drive,new UseLight(SensorPort.S3)};
           Arbitrator arby = new Arbitrator(bArray);
      LCD.drawString("PRESS TO START", 0, 0);
      Button.waitForAnyPress();
      LCD.clear();
       arby.start();
      
   }
}

Code: Select all
public class UseLight implements Behavior {
   private boolean suppressed = false;
   private ColorSensor light;
   private static final int MIN_LIGHT_PROCENTAGE = 22;
   private static final long DELAY_TIME = 2000; // in ms
   private long lastLightReadingTime; // to manage delay
   private long time;
   private int lastLightValue = 0;
   public static boolean debug = true;
    private int debug_action_indicator=0; //counts actions
    private int debug_take_indicator=0; //counts take on
   
   private void readLight(long time) {
      lastLightValue = light.getLightValue();
      lastLightReadingTime = time;
      if (debug) {   
         RConsole.println("UseLight.readLight"+lastLightValue + " l " + light.isFloodlightOn());
      }
   }

   private void setLight() {
      if (lastLightValue < MIN_LIGHT_PROCENTAGE) {
         light.setFloodlight(true);
      } else {
         light.setFloodlight(false);
      }
   }

   public UseLight(SensorPort port) {
      light = new ColorSensor(port, Color.NONE); // start floodlight off
      lastLightReadingTime = System.currentTimeMillis(); // start takeControl
                                             // with DELAY
   }

   public boolean takeControl() {
      time = System.currentTimeMillis();
      if ((time - lastLightReadingTime) < DELAY_TIME)
         return false; //do not change Floodlight at least for DELAY_TIME
      readLight(time);
      if ((lastLightValue < MIN_LIGHT_PROCENTAGE) && (light.isFloodlightOn())) {
         RConsole.println("UseLight.takeControl FALSE");
         return false;
         
      }
      if ((lastLightValue >= MIN_LIGHT_PROCENTAGE) && (!light.isFloodlightOn())) {
         RConsole.println("UseLight.takeControl FALSE");
         return false;
      }
      if (debug) {
         RConsole.println("UseLight.takeControl TRUE takeCount:" + debug_take_indicator+" actionCount:"+debug_action_indicator);
         debug_take_indicator++;
      }
      return true; // change light action
   }

   public void suppress() {
      suppressed = true;
   }

   public  void action() {
      suppressed = false;
      setLight(); // time calculated in take control
      //Delay.msDelay(2000); // do I need delay (it is not helping) ??
      if (debug) {
         RConsole.println("UseLight.action takeCount:" + debug_take_indicator+" actionCount:"+debug_action_indicator);
         debug_action_indicator++;
      }
   }
}

Code: Select all
public class DriveForward  implements Behavior {
   private boolean suppressed = false;
   private  DifferentialPilot pilot;
   
   public DriveForward(DifferentialPilot pilot) {
      this.pilot = pilot;
   }
   public boolean takeControl() {
     RConsole.println("DriveForward.takeControl");
      return true;
   }

   public void suppress() {
      suppressed = true;
   }

   public void action() {
    RConsole.println("DriveForward.action");
     suppressed = false;
     pilot.forward();
     while( !suppressed ) {
        Thread.yield();
        if(Button.ESCAPE.isDown()) {
            System.exit(1);
        }
     }
     pilot.stop();
   }
}

Console output with my comments
Code: Select all
Console open
UseLight.readLight34 l false //init
UseLight.takeControl FALSE //OK
DriveForward.takeControl //OK
DriveForward.action  //OK
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
...  //this is like 100x DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
UseLight.readLight6 l false
UseLight.takeControl TRUE takeCount:0 actionCount:0 //HERE IS TAKE CONTROL TRUE but no UseLight.action is called
DriveForward.takeControl
DriveForward.takeControl
... //like 20x DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.action
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
... //like 40x DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
UseLight.readLight41 l false
UseLight.takeControl FALSE //OK
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
... //like 40x DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
UseLight.readLight56 l false
UseLight.takeControl FALSE //OK
DriveForward.takeControl
DriveForward.takeControl
... //like 40x DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
UseLight.readLight5 l false
UseLight.takeControl TRUE takeCount:1 actionCount:0 //ERROR NO Action call again
DriveForward.takeControl
DriveForward.takeControl
...
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.action
DriveForward.takeControl
DriveForward.takeControl
...
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
DriveForward.takeControl
UseLight.readLight6 l false
UseLight.takeControl TRUE takeCount:2 actionCount:0 //ERROR no UseLight.action
DriveForward.takeControl
...
User interrupt
Program exit
Console closed


If I use just UseLight behavior output is as expected!
Code: Select all
Console open
UseLight.readLight6 l false
UseLight.takeControl TRUE takeCount:0 actionCount:0
UseLight.action takeCount:1 actionCount:1
UseLight.readLight7 l true
UseLight.takeControl FALSE
UseLight.readLight29 l true
UseLight.takeControl TRUE takeCount:1 actionCount:1
UseLight.action takeCount:2 actionCount:2
UseLight.readLight10 l false
UseLight.takeControl TRUE takeCount:2 actionCount:2
UseLight.action takeCount:3 actionCount:3
UseLight.readLight42 l true
UseLight.takeControl TRUE takeCount:3 actionCount:3
UseLight.action takeCount:4 actionCount:4
UseLight.readLight9 l false
UseLight.takeControl TRUE takeCount:4 actionCount:5
UseLight.action takeCount:5 actionCount:4
...
User interrupt
Program exit
Console closed


Thanks, Matej
matejc
New User
 
Posts: 8
Joined: Sat Aug 04, 2012 7:55 pm

Re: ColorSensor, Behavior action problem

Postby matejc » Mon Aug 06, 2012 7:43 pm

I think I have solved me mystery. Arbitrator has two Threads and if I understand correctly method takeControl (first Thread) can be called many times before one call of method action is made (in second Thread).
In my case I have changed condition ("if (time - lastLightReadingTime)"...) after successful call of takeControl method, second call of same method always returns false. Because of that second call (false) has override my call and action method was not called.

Is this behavior in Arbitrator class is as it needs to be (I am new in robotics)?
I think that if behavior with higher priority takes control, we don't need to make calls of method takeControl on behaviors with lower or same priority until method action is not called or takeControl of behavior with higher priority overrides control.

Thanks for help and please correct me if I am wrong, Matej
matejc
New User
 
Posts: 8
Joined: Sat Aug 04, 2012 7:55 pm

Re: ColorSensor, Behavior action problem

Postby roger » Wed Aug 08, 2012 3:50 am

Hi Matej,
Good idea to simplify your code. You are correct, that the first thread continually searches the behavior array to find the highest priority thread that wants to take control. If this is higher priority than the active thread, it suppresses the active thread.
The other thread waits till the the active thread action method exits, then calls action() on the highest priority thread.
If your useLight method is running and still wants control, it can keep returning true to takeControl(), but its actiion method will not be called again till the current method exits.

A quick look at the debug output suggests that DriveForward.action() does not exit when it should. You might try adding a debug statement rporting when DriveForward suppress() is called, and also when action() exits. you could also remove the debug from the takeControl method since we know that it is continually called ,except possibly when UseLight action is running. but we don't know if that ever happens.
Good luck,
Roger
roger
Moderator
 
Posts: 307
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Re: ColorSensor, Behavior action problem

Postby matejc » Wed Aug 08, 2012 9:01 pm

Thanks Roger!
>"If this is higher priority than the active thread, it suppresses the active thread." I agree!
>"The other thread waits till the the active thread action method exits, then calls action() on the highest priority thread." I agree!
>"If your useLight method is running and still wants control, it can keep returning true to takeControl(), but its actiion method will not be called again till the current method exits." I agree!

What is missing in documentation is:
That takeControl() starts to suppress() behavior with lower priority. But before calling action() method takeControl() can be called again so if meanwhile takeControl() starts returning false, action() will never be called.
Is this ok or it is bug in leJOS?
In my scenario this was unexpected! I think that call of action() (after successful takeControl()) needs to be called and if next call takeControl() return false than it will quickly exit by calling suppress().


Debug output:
Code: Select all
Console open
UseLight.takeControl FALSE
DriveForward.takeControl
DriveForward.action begin
UseLight.takeControl FALSE
DriveForward.takeControl
...
DriveForward.takeControl
UseLight.takeControl TRUE takeCount:0 actionCount:0
DriveForward.suppress
UseLight.takeControl FALSE  //ERR overrides my first take control
DriveForward.takeControl
UseLight.takeControl FALSE
...
DriveForward.takeControl
UseLight.takeControl FALSE
DriveForward.takeControl
UseLight.takeControl TRUE takeCount:1 actionCount:0
DriveForward.suppress  //WAITS for END
UseLight.takeControl FALSE //ERR overrides my take control
DriveForward.takeControl
...
DriveForward.takeControl
UseLight.takeControl FALSE
DriveForward.takeControl
UseLight.takeControl FALSE
DriveForward.takeControl
DriveForward.action end   //END
UseLight.takeControl FALSE
DriveForward.takeControl
DriveForward.action begin  //BEGIN
UseLight.takeControl FALSE
...
seLight.takeControl FALSE
DriveForward.takeControl
UseLight.takeControl FALSE
DriveForward.takeControl
UseLight.takeControl TRUE takeCount:2 actionCount:0  //ERR still no ACTION
DriveForward.suppress   //SUPPRESS
...
UseLight.takeControl FALSE
DriveForward.takeControl
DriveForward.action end  //END
UseLight.takeControl FALSE
DriveForward.takeControl
DriveForward.action begin


In case of floodLight I don't wont to have light-show (takeControl()/action()) also I don't like that behavior floodLight ON/OFF takes control all the time. In short I would like that this behavior checks and takesControl every two second!

I have made simple solution that works just fine, by adding boolean variable baction that is set true after first takeControl() and forces takeControl() to return true until action() is called.

Code: Select all
public class UseLight implements Behavior {
   private boolean suppressed = false;
   private ColorSensor light;
   private static final int MIN_LIGHT_PROCENTAGE = 22;
   private static final long DELAY_TIME = 2000; // in ms
   private long lastLightReadingTime; // to manage delay
   private long time;
   private int lastLightValue = 0;
   public static boolean debug = true;
    private int debug_action_indicator=0; //counts actions
    private int debug_take_indicator=0; //counts take on
    private boolean baction;
   
   private void readLight(long time) {
      lastLightValue = light.getLightValue();
      lastLightReadingTime = time;
      baction = false;
      if (debug) {   
         RConsole.println("UseLight.readLight"+lastLightValue + " l " + light.isFloodlightOn());
      }
   }

   private void setLight() {
      if (lastLightValue < MIN_LIGHT_PROCENTAGE) {
         light.setFloodlight(true);
      } else {
         light.setFloodlight(false);
      }
   }

   public UseLight(SensorPort port) {
      light = new ColorSensor(port, Color.NONE); // start floodlight off
      lastLightReadingTime = System.currentTimeMillis(); // start takeControl                                             // with DELAY
   }

   public boolean takeControl() {
      if (baction) return true;
      time = System.currentTimeMillis();
      if ((time - lastLightReadingTime) < DELAY_TIME) {
         RConsole.println("UseLight.takeControl FALSE");
         return false; //do not change Floodlight at least for DELAY_TIME
      }
      readLight(time);
      if ((lastLightValue < MIN_LIGHT_PROCENTAGE) && (light.isFloodlightOn())) {
         RConsole.println("UseLight.takeControl FALSE");
         return false;
         
      }
      if ((lastLightValue >= MIN_LIGHT_PROCENTAGE) && (!light.isFloodlightOn())) {
         RConsole.println("UseLight.takeControl FALSE");
         return false;
      }
      if (debug) {
         RConsole.println("UseLight.takeControl TRUE takeCount:" + debug_take_indicator+" actionCount:"+debug_action_indicator);
         debug_take_indicator++;
      }
      baction = true;
      return true; // change light action
   }

   public void suppress() {
      suppressed = true;
   }

   public  void action() {
      baction = false;
      suppressed = false;
      setLight(); // time calculated in take control
      //Delay.msDelay(2000); // do I need delay (it is not helping) ??
      if (debug) {
         debug_action_indicator++;
         RConsole.println("UseLight.action takeCount:" + debug_take_indicator+" actionCount:"+debug_action_indicator);
      }
   }
}


Thanks, Matej
matejc
New User
 
Posts: 8
Joined: Sat Aug 04, 2012 7:55 pm

Re: ColorSensor, Behavior action problem

Postby roger » Thu Aug 09, 2012 12:35 am

Hi,
I am pleased that you have solved your problem. You commented
What is missing in documentation is:
That takeControl() starts to suppress() behavior with lower priority. But before calling action() method takeControl() can be called again so if meanwhile takeControl() starts returning false, action() will never be called.
Is this ok or it is bug in leJOS?
In my scenario this was unexpected! I think that call of action() (after successful takeControl()) needs to be called and if next call takeControl() return false than it will quickly exit by calling suppress().

I thought the documentation was pretty clear
boolean takeControl()
The boolean return indicates if this behavior should seize control of the robot.

So obviously, if it returns false, the behavior should not seize control.
In your case, since useLight.takeControl() returned false before action() was called, it was no longer the highest priority behavior. ( By the way , takeControl() is not successful until the action() method is called.)
Congratulations on finding the simple solution that was not obvious to me .
Roger
roger
Moderator
 
Posts: 307
Joined: Fri Jun 01, 2007 4:31 am
Location: Berkeley, CA

Re: ColorSensor, Behavior action problem

Postby matejc » Thu Aug 09, 2012 2:02 pm

Thanks Roger.
I still think that concept of Behavior needs more words :) and examples. Usually event based architecture makes respons on every event.
In continues actions like moving there is natural that you override action() call with new takeOver() is false. In my case I had discrite idea, that after every delta time I check sensor and if necessary change floodLite state, and action could be override only after delta time.
matejc
New User
 
Posts: 8
Joined: Sat Aug 04, 2012 7:55 pm

Re: ColorSensor, Behavior action problem

Postby gloomyandy » Thu Aug 09, 2012 2:51 pm

Hi,
The entire point of a behaviour system is that it is supposed to be very simple. So having a takeControl method that returns different results even though the external situation is still the same is a little strange. In general it is not a good assumption to make that retuning true from takeControl will ensure that your action routine is called any time soon, or even at all (for instance another higher priority behaviour may prevent it being called). The general idea is that as much as possible each behaviour should be self contained and should work correctly no matter what priority they run at. This way you can combine the different behaviours to obtain interesting functionality.

In this case you are trying to use the behaviour system in a more sophisticated way, but as you have found, if you want to do this you need may need to add extra code to ensure that things work the way you expect.

Not sure if you are familiar with the concept of behaviour programming but if not the original papers by Rodney Brooks which describe his subsumption architecture make interesting and at times entertaining reading....
http://people.csail.mit.edu/brooks/pape ... tation.pdf
http://people.csail.mit.edu/brooks/pape ... 20Just.pdf

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: ColorSensor, Behavior action problem

Postby matejc » Thu Aug 09, 2012 8:22 pm

Thanks Andy!
I am always surplice how good old papers were (are), for me this is all new. Papers nicely describes development of behaviour systems (how all started and why and little about how to build/program them).

As you pointed out It looks that I am trying to use behaviour system in a more sophisticated way (using for unusual tasks). Having java as programming language nothing seems too complex and it is easy to be too creative :)

Also thanks for pointing possible problem in my solution
for instance another higher priority behaviour may prevent it being called)

Currently my UseLight behaviour has highest priority, and I don't have this problem. But I will fix that by modifying suppress() method.
Code: Select all
   public void suppress() {
      suppressed = true;
      baction = false; //override call of action by higher priority
   }


Matej
matejc
New User
 
Posts: 8
Joined: Sat Aug 04, 2012 7:55 pm


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 0 guests

more stuff