Behavior trees (BEHAVIOR TREES) and its industrial applications

        As the name suggests, a behavior tree is a tree structure that describes the behavior of things (humans, animals, robots, virtual characters, etc.). The gaming industry uses behavior trees to model character behavior. Now behavior tree modeling technology is penetrating into other fields, such as industrial production line arrangement and robot control.

    On the other hand, from the technical development trends of some automation manufacturers, it can be seen that open automation is gradually moving up from the underlying programming and modeling technology, adopting more advanced domain languages ​​and high-level modeling technologies, and gradually moving towards natural language-based Programming and modeling goals.

    Behavior trees and finite automata are two main ways of modeling behavior.

     The behavior tree is a tree constructed by three types of predefined nodes (nodes), which are the root (root), workflow (workflow) and execution nodes. Use them to describe "some" behavior. The return of the node is success (Success), failure (Failure) and operation (Running)

       Imagine you're feeling hungry and ready to cook a piece of meat, or order a takeaway. We can use the following behavior tree to describe:

      Maybe you don't know SELECTOR and SEQUENCE的含义,但是你大致了解行为树描述的行为模型的意义。只有一个节点会成功,做成一份肉,或者点了一份外卖。

node type

(Action/Task/Leaf) Action/Task/Leaf nodes

There are two types of leaf nodes:

  • Action: to perform a certain action, for example: to open a door 
  • condition: check for certain conditions

Composite nodes

A composite node is a node with multiple child nodes (Child), mainly including the following three types:

Sequence

A sequence node contains multiple child nodes, once executed, the child nodes will be executed sequentially. If one of the child nodes executes incorrectly, it returns failure.

for child in children:
    status = child.run()
    if status == RUNNING or status == FAILURE:
        return status

return SUCCESS

Selector

      A selector node has multiple child nodes, once executed, it executes all nodes until one succeeds, otherwise it fails. As you can probably tell, it's the exact opposite of a sequential node.

for child in children:
    status = child.run()
    if status == RUNNING or status == SUCCESS:
        return status

return FAILURE

 

 Decorator node (Decorator)

A decorator has only one child node, which is mostly used for utility nodes, such as

  • Repeater : Unlimited execution, or execution of child nodes for a period of time.
  • Inverter : Invert the result of the child node
  • AlwaysSucceed : Failure becomes success.
  • UntilFail : run until an error occurs

 Other compound nodes include

  • parallel execution
  • random execution

Blackboard

        In almost most cases, a node needs to talk to other nodes. Behavior trees have the ability to store data. They are called blackboards or data contexts (blackboard, data context). For example, one node finds the nearest enemy, while another A node hits it. They need to exchange information about the enemy's position

 Applications of Behavior Trees

  • game
  • Conversational AI
  • robot

Application of Behavior Tree in Industrial Software 

   In manufacturing, people use behavior trees to model workflows. For example, convert the standard work order (SOP-Standard Operation Procedure) in the manufacturing industry into a behavior tree model. After building the behavior tree model, the industrial software can convert the behavior tree into an execution program, and each node corresponds to a function block. This enables workflow automation and low-code.

     Searching Github can find many behavior tree libraries for Python and C++. There are also robot behavior tree libraries that specifically support ROS.

Behavior trees combined with function blocks

        The function block in the open automation field is a modular technology, which encapsulates the program segment that completes a single function into a function block, and provides a standardized function block interface. Function blocks are suitable for graphical programming. Apparently implementing behavior trees using function blocks is the way to go. The behavior tree diagram model can be easily converted into a function block diagram network.

      

 Layered Architecture of Model and Code

 

conclusion

      Behavior tree, as a behavior modeling method, has a broad market application in the standard work order-based job flow control, robot, AGV and other occasions in the manufacturing industry.

          However, it should also be pointed out that the behavior tree, like the finite state machine, is a modeling method, not a technical standard. There are flexible application methods in specific applications. The combination of behavior tree model and other modeling methods can become a high-level modeling method, such as OPCUA and IEC61499 based on event function block information model. Further, with the popularization of industrial applications of chatGPT large language model, it can be combined with domain language DSL based on natural language. Promote the application of modeling technology to a higher level and in an efficient manner.

        As the saying goes, "If the foundation is not solid, the earth will shake." When we research and learn new technologies and innovative ideas, basic technologies need to be mastered. At the same time, it is also necessary to learn from the successful experience of other industries, so as to be able to reach the realm of "a stone from another mountain can be used to attack jade".

Guess you like

Origin blog.csdn.net/yaojiawan/article/details/131799946