BehaviorTree.CPP

Behavior Trees Library in C++. Batteries included.

MIT License

Stars
2.9K

Bot releases are visible (Hide)

BehaviorTree.CPP - 4.6.2 Latest Release

Published by facontidavide 4 months ago

Noteworthy

  1. Re-added support for custom JSOn convertion functions.
  2. Fix in minitrace logger
  3. Removed singleton protection from various Loggers
  4. nonstd::expectedupdated
  5. More checks in VerifyXML to check that Subtree don't use names already recistered and regular Nodes
  6. New callback TickMonitorCallback called at each tick
  7. Fix ament_export_targets
BehaviorTree.CPP - 4.6.1: Small bug fix and flatbuffers deprecation

Published by facontidavide 5 months ago

The main change is a bug fix related to https://github.com/BehaviorTree/BehaviorTree.CPP/issues/823

Additionally, the old FileLogger and the flatbuffers files have been deprectaed and removed from the public API

BehaviorTree.CPP - 4.6: Lot of new features and tutorials

Published by facontidavide 6 months ago

This release includes a lot of important changes. This is a non comprehensive list.

With my great surprise, this release seems to be ABI compatible with 4.5.2

Default behavior of ReactiveSequence and ReactiveFallback

ReactiveSequence and ReactiveFallback are unfortunately hard to use correctly.
There was a long discussion about what should happen when one of these nodes has multiple asynchronous children and there is no easy answer.

The default behavior is not more similar to version 3.8, but this also means that users must be very careful.
Read this issue for details: https://github.com/BehaviorTree/BehaviorTree.CPP/issues/755

The "global blackboard" idiom

We introduce here a new idiom and syntax: the global blackboard.
Usually each Subtree (including the main tree) has its own blackboard, isolated from the others, unless we do remapping.

We additionally provide a top-level blackboard that can be accessed from everywhere, without any manual remapping, using the prefix "@"

See example: https://github.com/BehaviorTree/BehaviorTree.CPP/blob/master/examples/t19_global_blackboard.cpp

Entries of the blackboard are now timestamped!

We added a timestamp and a sequence number to each entry in the blackboard (both updated when we set the value).

This allow use to determine if the value we are reading in the blackboard is "new" (since the last time we accessed it) or "obsolate".

We added the methods Blackboard::getStamped and TreeNode::getInputStamped.

Additionally, we added 3 new builtin nodes that use this functionality:

  • SkipUnlessUpdated: decorator that skip the execution of the children unless an entry was updated, since the last time.
  • WaitValueUpdate: decorator that remains in RUNNING state, unless an entry was updated. Executes the child if it did.
  • WasEntryUpdated: action that returns SUCCESS if an entry was updated, FAILURE otherwise.

String + number concatenation in the scripting language

Details: https://github.com/BehaviorTree/BehaviorTree.CPP/pull/802

We use the operator ".." to concatenate strings and numbers (inspired by Lua).
Give this:

prefix := 'value_';
val := 42;
str:= prefix .. val

The variable "str" should contain the string "value_42"

Enhanced SQlite logger

We added a method to send comands directly to the database and to append extra information to a state transition in the Transitions table.

See example https://github.com/BehaviorTree/BehaviorTree.CPP/blob/master/examples/t16_sqlite_log.cpp

Refactored API to register JSON convertions.

We simplified the way a custom type can be converted from/to JSON. See the example here:
https://github.com/BehaviorTree/BehaviorTree.CPP/blob/master/examples/t11_groot_howto.cpp#L13-L27

Blackup / restore a blackboard state.

Related somehow to the JSON convertion mentioned earlier.
We add some methods to save/load the state of a blackboard. usefull if you want to reset it correctly, withour destrying it and rebuilding it from scratch.

See this tutorial: https://github.com/BehaviorTree/BehaviorTree.CPP/blob/master/examples/t17_blackboard_backup.cpp

convertToString

Added more convertToString specializations

BehaviorTree.CPP - 4.5.2: Bug fixes

Published by facontidavide 8 months ago

Bug fix

This release fix some important bugs in the scripting language, most notably in the equal operators, that now support enums and boolean more correctly.

New features

The way default port values is specified is also being changed, to include default pointers to the blackboard too.

Example of how ports with complex types can be initialized.
Note that the case represented in pointC requires the implementation of convertFromString<Point2D>()

  static PortsList providedPorts()
  {
    return {BT::InputPort<Point2D>("input", "no default value"),
            BT::InputPort<Point2D>("pointA", Point2D{1, 2}, "default value is [1,2]"),
            BT::InputPort<Point2D>("pointB", "{point}", "default value inside blackboard {point}"),
            BT::InputPort<Point2D>("pointC", "5,6", "default value is [5,6]"),
            BT::InputPort<Point2D>("pointD", "{=}", "default value inside blackboard {pointD}")};
  }

But this new syntax is still experimental and will become stable in release 4.6.0

BehaviorTree.CPP - 4.5.1: access the blackboard by pointer

Published by facontidavide 9 months ago

  • Example 6 updated and improved API of LockedPtr
  • Fix Switch node when using enums and integers
  • basic static_assert when trying to register a derived TreeNode with abstract methods
BehaviorTree.CPP - 4.5.0: Ports with Any type and Metadata

Published by facontidavide 9 months ago

Noteworthy changes

  • It is now possible to create ports with type BT::Any. These ports can connect to each other or to strongly typed ports
  • Optional metadata can be added to the manifest, implementing the static method KeyValueVector metadata() in your custom TreeNode.
  • Any::castPtr added, to access the content of Any without copying.
  • Any::isType() will now compare to the original type, not the casted one
  • Function writeTreeXSD() added
BehaviorTree.CPP - 4.5.0: Ports with Any type and Metadata

Published by facontidavide 9 months ago

Noteworthy changes

  • It is now possible to create ports with type BT::Any. These ports can connect to each other or to strongly typed ports
  • Optional metadata can be added to the manifest, implementing the static method KeyValueVector metadata() in your custom TreeNode.
  • Any::castPtr added, to access the content of Any without copying.
  • Any::isType() will now compare to the original type, not the casted one
  • Function writeTreeXSD() added
BehaviorTree.CPP - 4.4.2: Prevent empty output ports

Published by facontidavide 11 months ago

The most notable addition in this release is related to this issue: https://github.com/BehaviorTree/BehaviorTree.CPP/issues/702

The only valid ports are those remapped to a port entry.

BehaviorTree.CPP - 4.4.0: SubTree Model added

Published by facontidavide about 1 year ago

This version introduces some refactoring of the Blackboard class and other minor bug fixes.

But the most important change is the introduction of the SubTree Model.

See example ex05_subtree_mode.cpp for details

BehaviorTree.CPP - 4.3.8: Bug fixes and Reactive nodes

Published by facontidavide about 1 year ago

  • fixed a potential busy look caused by WakeUpSignal
  • Added tutorial 13 (how to build your own plugins)
  • The scripting language can now accept (and ignore) newlines.

Important

Both ReactiveSequence and ReactiveFallback were updated to better resemble each other and, partially, the logic they add in version 3.8.

Report any issue you may have.

BehaviorTree.CPP - 4.3.7: Fixing generic port type matching

Published by facontidavide about 1 year ago

This is the most improtant change in this release: https://github.com/BehaviorTree/BehaviorTree.CPP/commit/57a26632fb5c237e88e7da5a93a911c861407891

Related to this issue: https://github.com/BehaviorTree/BehaviorTree.CPP/issues/653

Previously, ports created by SetBlackboard would be recognized as strings instead of being considered "typeless" (as they should).

BehaviorTree.CPP - 4.3.6: Changes in Tutorial 12 and ReactiveFallback

Published by facontidavide about 1 year ago

  • Tutorial 12 was improved to make it easier to register custom type in the "blackboard visualized" of Groot2.

  • ReactiveFallback was fixed

  • Pre conditions script will be invoked less often now (i.e., only when really required)

BehaviorTree.CPP - 4.3.5: Bug fixes, mostly

Published by facontidavide about 1 year ago

BehaviorTree.CPP - 4.3.4: Bug fixes and Node description

Published by facontidavide about 1 year ago

Hi,

this release fix few bugs.

The most noteworthy addition is described here: #603

It is now possible to add a description of your node into the manifest of that node. That description will be exported in the section <TreeNodesModel> of your XML.

BehaviorTree.CPP - 4.3.3: Fix onHalted and added Groot2 recording

Published by facontidavide over 1 year ago

Record logs from Groot2

A new functionality introduced in Groot2 (1.0.0) is the ability to record a log in the Monitor mode.
To allow this functionality, version 4.3.3 of BehaviorTree.CPP must be used.

Important bug fix in post conditions

#601 : onHalted was not invoked correctly by some ControlNodes.

BehaviorTree.CPP - 4.3.2: More nodes and better error messages

Published by facontidavide over 1 year ago

Changes since version 4.3.1

  • Added ParallelAll node
  • Much better error messages when there is an error in the scripting language
  • Fix issues preventing Parallel (and probably other nodes) from using correctly _skipIf
BehaviorTree.CPP - 4.3 Bug fixes and a ton of refactoring

Published by facontidavide over 1 year ago

Important

This release is not ABI compatible with the previous one! Please recompile all your plugins, when updating.

Bug fix: Subtree "_autoremap"

This is related to #563 .
I realized that Subtree::_autoremap in V4.x was not an exact drop-in replacement of Subtree::__shared_blackboard in V3.X.

The main problem was that port remapping may not work properly if there is a subtree of a subtree (see this unit test).

To solve this problem, the implementation of the Blackboard and port remapping had to change considerably.

A nice side effect is that not TreeNode::getInput and TreeNode::setOutput is now actually more efficient.

Bug fix: default value for custom types

This solves #580. Note that it also required some radical changes in the Blackboard.

The user facing API did not change, but the internal one did; therefore, those users which use directly the Blackboard (something that is discouraged), might be affected.

Refactoring: Pimpl

To prevent more ABI compatibility issues in the future, we started using the PImpl idiom in multiple classes (TreeNode and BehaviorTreeFactory in particular).

New logger: FileLogger2

This is a replacement of the old FileLogger using Flatbuffers. This version will generate smaller logs and is compatible with the latest version of Groot2 (to be released soon).

BehaviorTree.CPP - 4.2 : Important change in Sequence and Fallback!

Published by facontidavide over 1 year ago

Breaking change

Since version 4.0, the behavior of Sequence and Fallback was changes, compared to 3.x.

The new implementation would return RUNNING after executing a Synchronous child.

This new behavior was reverted in 4.2.
Now the default behavior is the same as 3.8.

If you want to use the new behavior, you should switch to AsyncSequence and AsyncFallback.

Thread-safe access to ports with reference semantic

It is not uncommon to store objects with reference semantic (for instance std::shared_ptr<T>) in the blackboard.

Unfortunately, this makes it impossible for the setter and getter of the Blackboard to make the access to the object T thread-safe.

We propose a solution to this problem that uses:

  • Blackboard::getAnyLocked
  • TreeNode::getLockedPortContent

These new interfaces return an object called AnyPtrLocked.

This contains the pointer to the object Any, but will also keep the a mutex locked as long as the object exist.

To see a practical example, check LoopNode and the example 4 (ex4_waypoints).

Other changes

  • New FileLogger2, replacing the old (and deprecated) one.
  • RunOnce node added.
  • Tree::getNodesByPath added.
BehaviorTree.CPP - 4.1.1: bug fixes and SQLIte logger

Published by facontidavide over 1 year ago

I must admit that 4.1.0 was kind of a misfire.

Some important bugs were fixed since that release, and you should probably NOT use it.

Notable changes

  • ManualNode and dependency to ncurses . I am assuming that nobody uses that node. If you do... I am sorry? NCurses is a dependency I don't want to have.

  • New logger based on SQLite, that will allow users to log multiple runs in the same database. It is meant to be used with Groot2

  • Now substitution rules can be loaded from JSON at runtime (see tutorial 11)

  • Fixed issue #530

  • some header files (3rd party dependencies) moved from folder util to contrib

BehaviorTree.CPP - Release 4.1... getting ready for Groot2

Published by facontidavide over 1 year ago

New features / important changes

Identifying Nodes

  • The unique ID of the Nodes, i.e. TreeNode::UID(), is now deterministic and based on the Depth-first Traversal order (starting at 1).
  • Struct Tree::Subtree has now a unique human-readable identifier called tree_ID.
  • The Tree::Subtree::tree_ID is used to generate the TreeNode::fullPath(), which is also a uniquely identified string, that contains the hierarchy in the tree and the name of the Node.

A great way to get familiar with the new UID and fullPath is to look at Tutorial 10, where a TreeObserver is introduced too.

Tools to make debugging easier.

Version 4.1 introduces a new concept: node replacement. At deployment time, i.e. before the tree is instantiated, we can add "rules" to the BT factory to substitute certain Nodes with another implementations.

This is particularly useful when generating unit tests, i.e. when we want to substitute Nodes with dummy ones.

We provide a specific "dummy node" called TestNode that should cover the vast majority of the use cases.

Also, the TreeObserver is a great tool to create unit tests: it allows the user to check which Nodes have been ticked, and what they returned, in a non-intrusive way.

Dependencies and build

  • We removed the dependency from Boost, which was used only for its coroutine library. We use now minicoro. Boost is a "commodity" in Linux, but quite annoying for Windows users.

  • We now use conan to download dependencies in non-ROS builds.

Groot2 interface

We included the first, preliminary version of the Groot2Publisher, which can be used to communicate in real-time with Groot2 to do amazing things:

  • real-time visualization of the BT status
  • blackboard visualization
  • insert breakpoints in the tree and wait for "Continue" in Groot2
  • mocking of Nodes at run-time (force FAILURE or SUCCESS)
  • fault injection: make a node fail to trigger the execution of recovery branches.

Important bug fixes

  • #525 Pre-Condition : _skipIf NOT working with ReactiveSequence
  • #517 Halting the tree doesn't set the root node to idle
  • #515 "ReactiveSequence is not supposed to reach this point"
  • #514 Changed behavior of tickOnce
  • #507 _skipIf precondition does not work with SubTree
  • #506 Floating point values set by Script cause Floating point truncated
  • #505 'std::bad_alloc' when using Script node on Raspberry Pi
  • #492 Threads::Threads errors when building a project based on BT.CPP
  • #489 Port type mismatch between blackboard and subtree port

And probably others that I can't remember here