BehaviorTree.js icon indicating copy to clipboard operation
BehaviorTree.js copied to clipboard

Add AlwaysRunningDecorator

Open giannicic opened this issue 5 years ago • 2 comments

Does it make sense to add an "AlwaysRunningDecorator"? In order to keep running a ceratin node at each step until it fails.

giannicic avatar May 18 '19 13:05 giannicic

I don't see a scenario where this can be used. Do you have an example?

Usualy the running indicates that a task is not jet finished processing/running. The other decorators like Invert, AlwaysFail or AlwaisSucceed do logical processing.

Calamari avatar Jan 21 '21 22:01 Calamari

@Calamari actually i have used some time ago so i don't remember perfectly well . I've used the proposed decorator in a time stepped enviroment in order to account for a sequence that should run continously until a success is returned. For example:

{
  "type": "start",
  "name": ""
},
{
  "type": "reachObject",
  "name": ""
},
{
  "type": "catchObject",
  "name": ""
},
{
  "type": "running",
  "name": "putObjectInsideBucket",
  "node": {
	"type": "sequence",
	"name": "putObjectInsideBucketSequence",
	"nodes": [
		{
		  "type": "checkBucketPosition",
		  "name": "each time we check if the position of the bucket has changed"
		},
		{
		  "type": "reachBucket",
		  "name": "path finding throught the bucket, if bucket reached return SUCCESS"
		}
	]
  }
},
{
  "type": "releaseObjectIntoBucket",
  "name": ""
},
{
  "type": "finish",
  "name": ""
}

Here putObjectInsideBucket is in an AlwaysRunningDecorator so at each enviroment cycle the step function will stay on the putObjectInsideBucketSequence until the bucket is reached. If using AlwaysSuccessDecorator or AlwaysFailingDecorator the putObjectInsideBucket will be exected just once. With AlwaysRunningDecorator it got executed multiple times until a success returned.

Not sure if is a proper way to use that package.

giannicic avatar Feb 05 '21 18:02 giannicic