Behavior Trees in Robotics (Part 1 - Concept)

Hummingbird Robotics
1 Oct 202214:25

Summary

TLDRThis video delves into behavior trees, a critical tool in robotics and game engines, offering a solution to the limitations of finite state machines (FSMs). It explains the concept of behavior trees, their components, and how they address issues like reactivity and modularity. The video contrasts FSMs with behavior trees, highlighting the latter's scalability and adaptability for complex systems. It also previews upcoming content, which includes coding a behavior tree using the open-source library behavior.cpp in C++.

Takeaways

  • ๐ŸŒณ Behavior Trees are a method used in robotics and game engines to manage and structure tasks for autonomous agents.
  • ๐Ÿ”„ Before Behavior Trees, Finite State Machines (FSMs) were predominant, but they had limitations that led to the development of Behavior Trees.
  • ๐Ÿค– FSMs have a finite number of sequential states, which can become complex and hard to manage as the number of states and transitions increase.
  • ๐Ÿ”„ The two main issues with FSMs are their lack of reactivity to unexpected events and poor modularity, making them less scalable for complex systems.
  • ๐ŸŒŸ Behavior Trees offer improved reactivity and modularity, allowing for easier handling of complex scenarios and better code reuse.
  • ๐Ÿ“š Behavior Trees consist of control flow nodes (like sequences, fallbacks, and decorators) and execution nodes (actions and conditions), which provide structure and functionality.
  • ๐Ÿ”„ A Behavior Tree is executed from the root node through a process called 'ticking', which propagates down the tree based on node types and outcomes.
  • ๐Ÿ”„ The video provides a detailed example of a robot's Behavior Tree for finding, grasping, and disposing of a ball, illustrating the tree's reactivity in action.
  • ๐Ÿ”„ Behavior Trees are particularly useful in robotics for their ability to handle complex and dynamic environments more effectively than FSMs.
  • ๐Ÿ› ๏ธ The video series will proceed to code a Behavior Tree from scratch using an open-source library called behavior.cpp, demonstrating practical implementation.

Q & A

  • What is the main topic of the video?

    -The main topic of the video is to explain what Behavior Trees are, their origin, and the advantages of using them in robotics and game engines.

  • Why were Behavior Trees introduced?

    -Behavior Trees were introduced to address the limitations of Finite State Machines (FSMs), particularly in terms of reactivity and modularity, which FSMs struggled with as systems became more complex.

  • What is a Finite State Machine (FSM)?

    -A Finite State Machine (FSM) is an abstract machine with a finite number of sequential states. It transitions between these states based on inputs and the current state.

  • What are the two main problems with FSMs?

    -The two main problems with FSMs are reactivity and modularity. FSMs are not reactive enough to handle unexpected situations or corner cases, and they lack modularity, making it difficult to reuse states in different contexts without modifications.

  • How does a Behavior Tree differ from an FSM in terms of reactivity?

    -Behavior Trees are more reactive than FSMs because they can handle unexpected situations by continuously ticking all nodes to the left of the currently executing node, allowing for dynamic responses to changes in the environment.

  • What are the basic building blocks of a Behavior Tree?

    -The basic building blocks of a Behavior Tree are internal nodes called control flow nodes and leaf nodes called execution nodes. Control flow nodes include sequence, fallback, parallel, and decorator nodes, while execution nodes include action and condition nodes.

  • What is a 'tick' in the context of Behavior Trees?

    -A 'tick' in Behavior Trees is a signal or nudge that starts the execution from the root node and is propagated through the tree, allowing nodes to execute if they are in the active state.

  • How does modularity in Behavior Trees solve the problem faced by FSMs?

    -Modularity in Behavior Trees allows for the reuse of subtrees independently of the rest of the tree, as each subtree is decoupled from others. This makes it easier to reuse and modify behavior without affecting other parts of the system.

  • What is the role of a sequence node in a Behavior Tree?

    -A sequence node in a Behavior Tree ticks its children from left to right and requires all children to return success for the sequence node to be successful. If any child returns running or failure, the sequence node will return the same status.

  • What is the role of a fallback node in a Behavior Tree?

    -A fallback node in a Behavior Tree ticks its children from left to right and will return success or running as soon as one child returns either of these statuses. If all children return failure, the fallback node will also return failure.

  • What is the difference between an action node and a condition node in a Behavior Tree?

    -An action node in a Behavior Tree is responsible for executing an action and returns success, failure, or running based on the action's outcome. A condition node checks for a condition and returns success or failure based on whether the condition is met or not.

Outlines

00:00

๐ŸŒณ Introduction to Behavior Trees and FSMs

This paragraph introduces the concept of behavior trees and their significance in robotics and game engines. It contrasts behavior trees with finite state machines (FSMs), which were prevalent before behavior trees. The video aims to explain the evolution from FSMs to behavior trees due to limitations in reactivity and modularity. FSMs are described as having a finite number of sequential states, and their simplicity is demonstrated using the example of a computer's on/off state. The paragraph also sets the stage for a deeper exploration of behavior trees in subsequent videos, including coding examples in C++.

05:02

๐Ÿค– Challenges with Finite State Machines

The second paragraph delves into the problems associated with finite state machines (FSMs), particularly their lack of reactivity and modularity. It uses a robot example to illustrate how FSMs struggle with unexpected scenarios, such as an external agent disrupting the robot's task. The paragraph explains how increasing complexity in FSMs leads to a proliferation of states and corner cases, making them difficult to manage and debug. It also discusses the issue of modularity, where states in FSMs are not decoupled, leading to code that is hard to reuse without modifications. These challenges highlight the need for an alternative approach, which behavior trees address.

10:03

๐Ÿ”„ Understanding Behavior Trees and Their Components

The final paragraph provides an in-depth look at behavior trees, their components, and how they overcome the limitations of finite state machines. It describes behavior trees as directed rooted trees with control flow nodes and execution nodes. The paragraph explains the different types of control flow nodes: sequence, fallback, parallel, and decorator nodes, each with specific behaviors. It also differentiates between action and condition nodes. The paragraph uses the robot example to demonstrate how a behavior tree operates, emphasizing its reactivity and modularity. It shows how behavior trees can dynamically adapt to changes and how subtrees can be reused across different scenarios. The paragraph concludes by acknowledging the scalability of behavior trees for complex systems and้ข„ๅ‘Šๅณๅฐ†ๅœจไธ‹ไธ€ไธช่ง†้ข‘ไธญไฝฟ็”จๅผ€ๆบๅบ“behavior.cppๆฅๆž„ๅปบ่กŒไธบๆ ‘็š„ๅฎž่ทตๆ“ไฝœใ€‚

Mindmap

Keywords

๐Ÿ’กBehavior Trees

Behavior Trees are a data structure used in programming, particularly in robotics and game development, to manage and structure tasks or behaviors in an autonomous agent. They are designed to be more flexible and reactive than Finite State Machines (FSMs). In the video, Behavior Trees are introduced as a solution to the limitations of FSMs, providing a way to handle complex scenarios with greater modularity and reactivity. The video explains that Behavior Trees are composed of nodes that can be executed based on certain conditions, allowing for dynamic responses to changes in the environment.

๐Ÿ’กFinite State Machines (FSMs)

Finite State Machines are a computational model that can be in one of a finite number of states at any given time. They are used to design systems where the next state is a function of the current state and the input. In the video, FSMs are discussed as the predecessor to Behavior Trees. They were widely used in robotics and game engines but faced challenges with reactivity and modularity, leading to the development of Behavior Trees. The script uses the example of a robot finding and picking up a ball to illustrate how FSMs work and their limitations.

๐Ÿ’กReactivity

Reactivity in the context of the video refers to the ability of a system to respond to changes in its environment or inputs. Behavior Trees are highlighted as being more reactive than FSMs, allowing for more dynamic and flexible responses to external events. The video contrasts this with FSMs, which may not be able to handle unexpected changes as effectively, requiring the system to be made more complex to account for these scenarios.

๐Ÿ’กModularity

Modularity in software design refers to the concept of creating independent, interchangeable modules that can be easily reused in different parts of a program. The video emphasizes that Behavior Trees offer better modularity than FSMs, allowing developers to reuse subtrees or nodes without being dependent on their context within the tree. This makes Behavior Trees more scalable and easier to manage in complex systems.

๐Ÿ’กControl Flow Nodes

Control Flow Nodes are internal nodes in a Behavior Tree that dictate the order in which execution nodes are processed. The video explains that there are four types of control flow nodes: Sequence, Fallback, Parallel, and Decorators. These nodes manage the flow of execution within the tree, determining how the system responds to different conditions and inputs.

๐Ÿ’กExecution Nodes

Execution Nodes are the leaf nodes in a Behavior Tree that represent actions to be performed or conditions to be checked. They are the terminal points in the tree where actual tasks are executed or evaluated. The video distinguishes between two types of execution nodes: Action nodes, which perform tasks, and Condition nodes, which check for specific states or conditions.

๐Ÿ’กSequence Node

A Sequence Node is a type of control flow node in a Behavior Tree that processes its children from left to right until one of them returns a failure or running status. If all children return success, then the sequence node also returns success. The video uses this concept to explain how a sequence node ensures that a series of actions must all be completed successfully for the overall task to be considered successful.

๐Ÿ’กFallback Node

A Fallback Node is another type of control flow node that tries its children from left to right and will return success or running as soon as one of the children does so. If all children return failure, then the fallback node also returns failure. The video script uses the example of a robot's behavior to illustrate how a fallback node can handle different scenarios, such as finding and then picking up a ball, by trying different actions until one succeeds.

๐Ÿ’กParallel Node

A Parallel Node is a control flow node that executes all its children simultaneously and evaluates their success or failure to determine its own status. The video mentions that a parallel node returns success if a specified number of its children succeed, failure if a certain number fail, and running otherwise. This node type is useful for managing concurrent tasks in a system.

๐Ÿ’กDecorator Node

A Decorator Node is a control flow node that adds additional functionality to a child node without changing its core behavior. The video script explains that decorators can be used to modify the behavior of a node, such as allowing it to fail a certain number of times before the failure is propagated. This enhances the flexibility of the Behavior Tree by allowing for more complex conditional behaviors.

Highlights

Behavior trees are introduced as a solution to the limitations of finite state machines (FSMs) in robotics and game engines.

FSMs have a finite number of sequential states, which can become complex and hard to manage in dynamic environments.

Behavior trees offer improved reactivity and modularity over FSMs, making them more suitable for complex systems.

The video explains the concept of behavior trees through a simple example of a robot finding and interacting with a ball.

A behavior tree is a directed rooted tree with internal nodes called control flow nodes and leaf nodes called execution nodes.

Control flow nodes include sequence, fallback, parallel, and decorator nodes, each with a specific function within the tree.

Execution nodes are of two types: action nodes that perform tasks and condition nodes that check for specific conditions.

The video demonstrates how a behavior tree can handle unexpected situations, such as an external agent interfering with the robot's actions.

Behavior trees are shown to be more scalable for complicated scenarios due to their inherent reactivity and modularity.

The video discusses the practical problems with FSMs, such as lack of reactivity and modularity, which led to the development of behavior trees.

The concept of a 'tick' in behavior trees is introduced as a method to initiate and propagate execution through the tree.

The video provides a detailed breakdown of the behavior tree structure, explaining the roles of sequence and fallback nodes.

Decorator nodes are highlighted as a way to add functionality to child nodes, such as allowing multiple failures before a task is considered failed.

The video concludes with a้ข„ๅ‘Š of the next video, where the audience will learn to code a behavior tree from scratch using the behavior.cpp library.

The video recommends a book for further reading on behavior trees, indicating that there is more depth to the subject than covered in the video.

The video emphasizes the practical applications of behavior trees in robotics and game engines, highlighting their widespread use.

Transcripts

play00:00

behaviors this video is about us

play00:02

understanding what Behavior trees are

play00:04

how they came into being and what are

play00:06

the advantages of using Behavior trees

play00:08

in robotics this series will start with

play00:11

the conceptual idea of behavior trees in

play00:13

this video and in the next videos of

play00:15

this series we will actually start

play00:16

coding in C plus to build a behavior

play00:19

tree okay enough about the series let's

play00:21

come back to the idea of behaviors to

play00:24

understand Behavior trees let's go back

play00:26

to a time where we did not have Behavior

play00:28

trees but fsms were the main thing in

play00:31

robotics and game engines let's also

play00:33

understand what behaviories and fsms are

play00:35

in general for they are ways to

play00:37

structure and manage the switching

play00:39

between different tasks in an autonomous

play00:41

agent which could be inside a game like

play00:44

a virtual entity or a robot but let's

play00:46

talk about fsm's first and that will

play00:48

lead to certain problems and then that

play00:50

will lead to our discussion about

play00:51

Behavior trees and how this started what

play00:53

exactly is a finite State machine or as

play00:55

we said FSM and FSM or finite State

play00:58

machine is an abstract machine with

play01:00

finite number of sequential States

play01:03

this sounds very boring and full of

play01:05

jargons so let's just simplify this

play01:07

using an example okay now imagine a

play01:09

machine for example your computer in a

play01:12

very simple scenario your computer can

play01:13

be in two states on or off so this will

play01:17

be a state machine for that and this has

play01:19

two states so this is a finite State

play01:22

machine here one state depends on the

play01:24

input which is a button press and in

play01:26

this case we'll simplify it to a toggle

play01:27

and then also it depends on the previous

play01:30

date so that's why it's sequential so it

play01:33

depends on the previous state and the

play01:35

input given now this was a very simple

play01:37

example of a finite State machine you

play01:39

can of course go into the details of

play01:40

finite State machines because what I've

play01:42

explained is not actually exhaustive

play01:44

it's a very simple watered down idea of

play01:47

a finite State machine now I hope you've

play01:49

either understood the idea of a finite

play01:50

State machine in simple terms or you've

play01:52

researched about finite State machines

play01:54

already in the past so let's look at a

play01:55

more evolved but still very simple

play01:57

finite State machine of a robot this

play02:00

robot is supposed to find a ball go to

play02:02

the ball pick it up then go to a bin and

play02:05

drop it in the bin and the process

play02:07

repeats this is the state machine of

play02:09

that robot spend a couple of seconds

play02:11

understanding what the state machine is

play02:13

as I said the state machine has finite

play02:15

States and it is sequential that means

play02:18

that the current state depends on the

play02:20

previous state and the input the input

play02:22

is given through sensors and the

play02:24

previous state is of course the previous

play02:25

state for instance let's say the first

play02:27

date is finding the ball if the ball is

play02:29

found we go to the next state to

play02:30

approach the ball if we approach the

play02:32

ball we go to the next state which is

play02:34

grasping the ball and then we go to the

play02:36

bin and then we drop the ball and then

play02:38

the process repeats again but during

play02:40

this process if there is a fault

play02:42

somewhere then the system should ask for

play02:45

help so this is our state machine for

play02:48

the simple robot now we were talking

play02:49

about finite State machines and you

play02:51

might get impatient and then you'd ask

play02:53

why are we talking about this well

play02:55

before Behavior trees finite State

play02:57

machines were ruling the world of game

play02:59

engines and Robotics but it had a couple

play03:01

of problems which led to the creation

play03:03

and usage of behavior trees looking at

play03:06

this FSM we are happy because it seems

play03:08

to work well but there are two problems

play03:10

with this state machine all this finite

play03:12

State machine one reactivity and second

play03:15

modularity let's start talk about them

play03:17

individually now first up reactivity now

play03:19

the problem with the state machine is

play03:21

that let's say an external agent comes

play03:23

when our robot is supposed to drop the

play03:26

ball to the bin and it pushes the ball

play03:27

out of the robot's hand what will the

play03:29

state machine do in that case it assumes

play03:31

that nothing like that will happen what

play03:33

we need to do here is that we need to

play03:35

make our state machine more complicated

play03:37

for complicated scenarios right so we

play03:39

can do that we can add an additional

play03:40

state or we can upgrade the state which

play03:43

is placeball so that it constantly

play03:45

checks if the ball is still there that's

play03:47

still fine but in a real scenario there

play03:50

are so many complexities as you increase

play03:51

the complexity you would need to have

play03:53

more States that's still okay but you

play03:55

would need to handle each state with a

play03:57

lot more intelligence and then one state

play03:59

might not lead to another state but it

play04:01

might lead to five or six or n different

play04:03

states depending on how complicated the

play04:05

system is so we can take one of the

play04:07

paths now as we make the system more

play04:09

complex due to requirements making a

play04:12

finite State machine becomes super hard

play04:14

because you will have so many Corner

play04:16

cases you will have so many issues so

play04:18

the problem is a practical finite State

play04:20

machine which is understandable for us

play04:22

and we can debug it properly is not

play04:25

reactive enough and of course the more

play04:27

Corner cases you have the more

play04:28

intelligence you want to put in a finite

play04:30

State machine the more complicated it'll

play04:32

get and we as Engineers might not be

play04:33

able to deal with it so in simple terms

play04:36

you might make a mess of your state

play04:38

machine if you keep using finite State

play04:40

machines for complicated scenario a

play04:42

practical State machine is not reactive

play04:44

enough to react to these Corner cases

play04:45

and complexities in the system second

play04:48

modularity now one state here in this

play04:50

finite State machine is actually not

play04:52

decoupled from the previous state and

play04:54

the next state for instance cross ball

play04:56

is supposed to be connected to approach

play04:59

ball and approach bin in this case

play05:01

what's happening is that if for some

play05:03

reason you want to use this state again

play05:06

because the system is getting more

play05:08

complex and you want to grasp ball not

play05:09

just to approach the bin and put it the

play05:11

bin but for something else as well you

play05:14

cannot use it as it is because it is not

play05:16

modular it will have code which at least

play05:18

indirectly depends on the previous state

play05:20

and the next date so that means if we

play05:22

want to use the state or the code inside

play05:24

the state again we cannot do that we

play05:26

will have to make changes to this code

play05:28

to check if the next state is this or

play05:30

that if the previous state is this or

play05:32

that and as I said before as these

play05:34

things happen the system becomes more

play05:36

complicated it just becomes a mess and

play05:38

thus a state in itself is not modular

play05:41

these are the two main problems with a

play05:43

finite State machine and a finite State

play05:45

machine starts failing practically for

play05:47

development and deployment once the

play05:50

system starts becoming more complicated

play05:51

it's great to use a finite State machine

play05:53

if the system is very simple and then if

play05:56

your environment is constrained and

play05:58

predictable but because of the previous

play05:59

two issues we can say that in general as

play06:02

the system becomes more complex a finite

play06:04

State machine is not scalable so that is

play06:06

the problem which led to the creation of

play06:08

behavior so now after all the story we

play06:11

finally talking about Behavior trees

play06:13

this is the corresponding behavior of

play06:15

your state machine it might look

play06:17

slightly random if you don't know what's

play06:19

actually happening so what we'll do is

play06:20

we will understand different components

play06:22

which together form a behavior tree

play06:24

we'll also check if this behavior is

play06:25

doing what we want but with reactivity

play06:28

and modularity right because these were

play06:31

the two reasons which led to the

play06:33

creation of behaviorly so let's start

play06:34

with understanding the basic building

play06:36

blocks of behavior trees and then we'll

play06:38

come back to this Behavior tree and see

play06:39

what's actually happening a behavior

play06:41

tree is a directed rooted tree which has

play06:44

internal nodes called control flow nodes

play06:46

and leaf nodes called execution nodes a

play06:49

behavior restarts its execution from the

play06:51

root mode using something called a tick

play06:53

a tick is basically like a nudge to a

play06:56

node where it'll start functioning so

play06:58

the root node actually starts the stick

play07:00

or this nudge and it nudges all the

play07:02

nodes just below that so all the

play07:05

children of this root node and this

play07:07

nudge or a tick is gradually propagated

play07:09

a node is only executed if it is State

play07:12

otherwise it's not also taking in

play07:14

Behavior tree happens from left to right

play07:16

so depending on what the parent node is

play07:18

it will either take only the left node

play07:21

or all the nodes but we'll get into that

play07:23

in a bit in general there exists four

play07:25

different categories of control flow

play07:26

nodes sequence fallback parallel and

play07:29

decorators a sequence node is a control

play07:31

node with children where it actually

play07:33

starts ticking from the left node and

play07:36

then it gradually moves towards the

play07:37

right but the catch here is that a

play07:39

sequence node takes its children

play07:41

starting from left to right until it

play07:43

finds a child node which returns either

play07:45

running or failure so sequence node

play07:48

actually requires all the children to

play07:50

return success for it to say that hey I

play07:53

am successful and when that happens it

play07:55

will return success to its period note

play07:57

that when a child of a sequence node

play07:59

returns running of failure then the next

play08:02

node or the next child node to the one

play08:04

which return this is not ticked so it is

play08:07

only take if the previous one returns

play08:09

success a fallback node on the other

play08:10

hand routes the this text to its

play08:12

children from left to right until it

play08:14

finds a node or a child node which

play08:16

returns either success or running if all

play08:19

the child nodes return failure only then

play08:22

is this note saying hey I failed

play08:24

otherwise it will return a success or

play08:26

running as soon as one of its children

play08:28

returns running all success know that

play08:31

for a fallback node if a child returns

play08:33

running or success the next node is not

play08:35

date so the status is returned back to

play08:38

the parent node which is the fallback

play08:40

node and this fallback node reports back

play08:42

to its parents saying running all

play08:44

success a parallel node routes sticks to

play08:47

all its children and returns success if

play08:49

M of these nodes actually return success

play08:51

it returns failure if n minus M plus 1

play08:53

notes where n is the total number of

play08:55

nodes return failure and otherwise it

play08:57

returns running a decorator node is an

play09:00

added functionality on a child for

play09:01

instance if you want to allow the child

play09:03

node to fail n number of times then you

play09:05

can add a decorator node to basically

play09:07

enhance its functionality and say Hey

play09:09

you can fail n number of times now

play09:11

talking about execution notes there are

play09:13

two simple types of execution notes one

play09:15

is action and one is condition action

play09:17

node is responsible for carrying out an

play09:19

action and then it returns either

play09:20

success failure or running and a

play09:22

condition node checks for a condition

play09:23

and returns success or failure based on

play09:25

that condition passing or failing now

play09:27

let's combine all of this and look back

play09:29

at our example where the robot was

play09:31

supposed to find a ball and then finally

play09:33

drop the ball in a bin and the process

play09:35

repeats looking at this Behavior tree

play09:36

the root note is a fallback node that

play09:38

means it goes to the left side of the

play09:40

tree which is our main tree and the

play09:42

right side is asked for help if the left

play09:44

side returns running or success then the

play09:47

right side is not used at all right so

play09:49

the right child which is asked for help

play09:50

is not used if the left tree returns

play09:53

success that is everything is done the

play09:55

ball was finally dropped in the bin or

play09:57

it returns running which means the root

play09:59

node has to wait anyway now going down

play10:00

the three by one the next node is a

play10:02

sequence node that means it wants to

play10:04

tick all the children one by one and

play10:07

when all of them return success only

play10:08

then it's happy and it returns success

play10:10

back to its paid node which is the root

play10:12

node if not it will either return

play10:14

running based on what the children are

play10:15

doing if one of the child returns

play10:17

running it will return running back

play10:18

otherwise if one of the child returns

play10:20

failure then it will return failure and

play10:22

then we'll go to ask for help now let's

play10:24

go to the next level we see this level

play10:26

filled with fallback notes again that

play10:28

means this fallback node will first take

play10:30

its left child and then if the left

play10:32

child fails only then it will go to the

play10:34

right child let's just take one example

play10:37

because it's just repetitive and it's

play10:38

the same for all of these fallback notes

play10:40

now let's take the extreme left side of

play10:42

this here what you have is a fallback

play10:43

node which has two children one ball

play10:45

found condition node and second fine

play10:47

Ball action node ball found condition

play10:49

node just checks if the ball is actually

play10:51

found or not if it's found then it

play10:53

returns success that means this part of

play10:56

the tree returns success to its parent

play10:58

which is a sequence node so it will

play11:00

basically take the next one but if ball

play11:02

is not found then this fallback node

play11:05

will look at the next child which is

play11:07

fine ball if fine ball returns running

play11:10

then this node will return running back

play11:12

to its parent node that means the system

play11:15

has to wait until this running is

play11:17

changed to either success or failure so

play11:19

this node constantly takes ball found

play11:21

and the action node which is fine ball

play11:24

and then once the ball is actually found

play11:25

this will eventually return success

play11:27

right because the condition ball found

play11:28

becomes true so ball found returns

play11:31

success so once this is done the

play11:32

sequence node which was the parent of

play11:34

all these fallback nodes takes the next

play11:36

fallback node which is about approaching

play11:38

the ball the same logic is applied there

play11:40

and hence all the fallback nodes from

play11:42

left to right are ticked one by one now

play11:44

one thing to consider here is that this

play11:46

is a reactive Behavior tree which means

play11:48

that all the nodes to the left of the

play11:51

currently take note are also ticked what

play11:53

does that mean in this case and why did

play11:55

I say that this is a reactive Behavior

play11:56

tree let's say in this case the ball is

play11:59

grasped and then the robot is moving

play12:01

towards the bin somehow an external

play12:04

agent pushes the ball away from the hand

play12:05

of the robot now in this case since all

play12:08

the nodes which are on the left to the

play12:10

node we're talking about which is for

play12:11

approaching the bin since all the left

play12:13

fallback nodes were ticked continuously

play12:15

as soon as the ball slips away all is

play12:17

visible but the ball is not close to the

play12:19

robot so the second fallback node comes

play12:21

into play here now the robot will again

play12:23

approach the ball so in this case the

play12:25

behavior tree is already pretty reactive

play12:27

that was not the case with a finite

play12:28

State machine if something like that

play12:30

happened for a finite State machine it

play12:31

would have failed so we would have to

play12:33

make changes to that finite State

play12:34

machine to consider this example or this

play12:36

corner case but then you have so many

play12:37

Corner cases so this is one example

play12:39

where reactivity is clearly there that's

play12:42

why I was saying a behavior tree is

play12:44

reactive but a finite State machine is

play12:46

not talking about the second Advantage

play12:48

now modularity one module or one subtree

play12:51

of this Behavior tree is actually

play12:53

independent of all the other it doesn't

play12:54

know where the take is coming from it

play12:57

doesn't know which sub tree will stick

play12:58

before so you can actually reuse this

play13:01

again and again and let's say you have

play13:03

to grasp the ball again and again in

play13:04

different scenarios you can use the same

play13:06

subtree from the behavior tree instead

play13:09

of doing something else making some

play13:10

other changes is because subtree is

play13:12

decoupled from all other subfrees or

play13:14

different parts of the Trees of this

play13:16

Behavior tree so that solves our problem

play13:18

of modularity now because of reactivity

play13:20

and modularity the idea of behavior tree

play13:22

is very scalable for complicated

play13:24

scenarios and complicated systems that

play13:27

is exactly why Behavior trees came into

play13:29

being and that is why they are used so

play13:31

much in robotics and game engines now so

play13:34

this was the basic idea of behavior

play13:36

trees I hope you understood what a

play13:38

behavior tree is how they came into

play13:40

being because of problems with finite

play13:42

State machines and what are the

play13:43

advantages there is a lot more to

play13:46

understand when it comes to behavior

play13:47

trees I'm adding a link to the book I

play13:49

read which is all about Behavior trees

play13:51

it is a brilliant book this video just

play13:53

covers the basics and there is a lot

play13:54

more to understand now in the next video

play13:56

we will code a behavior tree from

play13:58

scratch for a simple example using

play14:00

something called behavior.cpp which is

play14:03

an open source library for making

play14:05

Behavior trees this is a brilliant

play14:07

brilliant Library made by Davide and I

play14:09

absolutely love this Library so we're

play14:11

gonna talk about that Library we will

play14:13

start making a simple Behavior tree

play14:15

using that library in C plus plus and

play14:17

then we'll take it from there and then

play14:18

gradually build upon that to make

play14:19

robotic Behavior thank you for watching

play14:21

this video I'd love to know what you

play14:22

think about this and I will see you in

play14:24

the next video bye

Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
Behavior TreesFinite State MachinesRoboticsGame EnginesReactivityModularityC++ CodingAI StructuresAutomationSoftware Engineering