Behavior Trees (Thu Nov 14, lect 21) | previous | next | slides |

Behavior trees are a better way to create interesting Robot behavior

Reminder: Readings are your responsibility. You will be expected to come to class prepared, having read the material, and ready to participate in the discussion

Logistics

Homework submission details

  • If you submit an assignment, code, a video or whatever
  • We may very well grade it
  • If you want to submit a revision before the cutoff
  • You need to tell us because we don’t get a notification
  • Your assignment will be considered late and so cannot get an “exceeds”

Team Standups

ProjectTeam
Tom and Jerry: The Cheese NappingVedanshi Shah and Parthiv Ganguly
Red Object Picker "Sonny George and Alex Danilkovas
Starship Bot Clone "Artem Lavrov, Zach Hovatter, Ephraim Zimmerman
Precision Agriculture Robot Ming-Shih Wang and Jiahao Li
Dungeons and Robot "Yutian (Tim) Fan
Smart Cleaning Bot with Voice ControlZhenxu Chen Pang Liu
Rights of RobotHaochen Lin and Zixin Jiang
Autonomous Taxi SimChao An
Hide and SeekJungju Lee Daphne Pissios abd Chloe Wahl-Dassule
Micro MouseSam Herman
Bot Follower/MapperEric Hurchey
Counter Strike BotZared Cohen Harry Yu and TsunOn Kwok
Gesture Control BotLeo Gao and Jeffrey Wang
Micro MouseBen Zhang

Introduction to Behavior Trees

  • Some similarity to FSM, however…
  • BTs are specifically trees, with one root and leaves
  • BTs have different kinds of nodes with very different semantics
  • The leaves represent the actual control actions
  • All the other nodes are part of the control logic

py_trees

  • This example uses this library: py_trees
  • As we are using ROS1, you need to use py_trees 0.7 of this library
  • Latest version is not compatible with the current version of ROS

Behavior Tree Execution

  • “Tick” oriented control flow
  • A tree is “ticked”, which “ticks” the top node
  • Each node type has specific semantics about what happens on a tick
  • Nodes can return one of: SUCCESS, FAILURE, RUNNING

Node Types

  • These control flow
    • Sequence - perform each child node in turn as long as they return SUCCESS
    • Selector - perform the first child node that returns SUCCESS
    • … several mode
  • Behavior nodes actually DO somerthing

Behavior Tree Returns

  • SUCCESS: The action is complete and was successfull
  • FAILURE: The action is done but failed
  • RUNNING: The action is incomplete and needs to be ticked again

  • You will discover that the semantics of these are a little subtler than they seem initially

Behavior Nodes - Example

  • Behavior nodes are the leaf nodes.
  • They execute code which actually “do something” to outside of the tree
  • They could cause an action or read a sensor or anything else.
  • Simple example: blink light once would:
    1. On Update: Tell the hardware to turn the light on and off; Return SUCCESS (because it always works.)
  • Simple example: turn light on with a parameter: n seconds, would:
    1. On Init: set initial time <- current time; turn the light on
    2. On Update: if current time > initial time + n: turn off the light; return SUCCESS; else return RUNNING

Behavior Nodes

  • Life Cycle of a behavior node
  • Setup (optional): one time initiatlization of state when first instantiated
  • Initialize (optional): called each time that the node is entered anew (i.e. when its not RUNNING)
  • Update (required): called each time the node is ticked
  • Terminate (optional): called whenever the node goes to not RUNNING

Composites

  • The non-leaf nodes are all known as composites
  • Generally the leftmost leaf is ticked first
  • Depending on Composite type and returned status of that node, different next nodes may be ticked
  • Core (traditional) set of Composites are: Sequence, Selector, Parallel
  • But depending on the library, there may be other variations (which are all extensions of this set.

Sequence

  • Most common
  • Tick from left to right
  • Each SUCCESS result leads to the next node
  • Any non-SUCCESS ends the sequence and returns that same status up the chain

Selector

  • Also very useful, kind of the reverse
  • Tick from left to right as long as the child returns FAILURE
  • The first non-failure makes the whole Composit3e return

Parallel

  • Returns FAILURE if any child returns FAILURE
  • Otherwise keeps ticking all the children
  • Depending on policy it will return when one or all the children have returned SUCCESS

Thank you. Questions?  (random Image from picsum.photos)