../_images/tiagopro-icon.png ../_images/kangaroo-icon.png ../_images/tiago-icon.png ../_images/ari-icon.png ../_images/talos-icon.png ../_images/mobile-bases-icon.png

🌳 Goal Navigation BT#

As mentioned earlier, the Goal Navigation uses of Behavior Trees to define the logic used in the navigation tasks. In this section, you will learn about the available Behavior Trees, their characteristics, and how to create new ones with new custom logic.

Behavior Tree Navigator#

The bt_navigator is a Behavior Tree-based implementation for navigation, designed to provide flexibility in navigation tasks and to allow for the easy specification of complex robot behaviors, including recovery actions.

It implements different task interfaces, one of this is the Nav2 NavigateToPose .

How to create your Goal Navigation Behavior Tree#

In addition to the PAL Behavior Trees and the Nav2 Behavior Trees, you can create a new Behavior Tree with custom logic, by creating a new XML file.

You can create it in the directory you prefer, though it is recommended to create it in the .pal folder of your robot.

mkdir -p ~/.pal/behavior_trees

And then, within this folder, you can create a new XML file for your custom Behavior Tree.

touch ~/.pal/behavior_trees/my_custom_bt.xml

To do so, you can refer to the BT Official Documentation and configure it by adding your nodes to the XML file as indicated in the Official Configuration Guide.

Configuration#

In order to start using your custom Behavior Tree, you can :

ros2 action send_goal /navigate_to_pose nav2_msgs/action/NavigateToPose "pose:
  header:
    stamp:
      sec: 0
      nanosec: 0
    frame_id: 'map' # The frame in which the pose is expressed
  pose:
    position:
      x: 0.0
      y: 0.0
      z: 0.0
    orientation:
      x: 0.0
      y: 0.0
      z: 0.0
      w: 1.0
behavior_tree: '/home/pal/.pal/behavior_trees/my_custom_bt.xml'"
  • Create your custom configuration for the bt_navigator and update the default default_nav_to_pose_bt_xml parameter to the full path of your custom XML file.

If you want to go with the second option, you first need to create a new directory in the .pal folder of your robot.

mkdir -p ~/.pal/config

And then, within this folder, you can create a new bt_navigator configuration file.

touch ~/.pal/config/99_my_bt_navigator_config.yaml

Attention

The name of the file should start with a number to ensure that it is loaded last and overrides the default PAL configurations.

Within the newly created 99_my_bt_navigator_config.yaml file, you can insert your bt_navigator parameters. For the list of available parameters, their meaning and how they affect the SLAM algorithm, you can refer to the bt_navigator configuration guide. When creating a new Navigation configuration file, you need to specify the node name it refers to, in this case, bt_navigator.

/bt_navigator:
   ros__parameters:
      # Your bt_navigator parameters

      default_nav_to_pose_bt_xml: "/home/pal/.pal/behavior_trees/my_custom_bt.xml"

Once created, to start using your custom bt_navigator configuration, you need to restart the navigation module with the command:

pal module restart navigation

Note

This change is is persistent and will be loaded every time you start the navigation module. If you want to revert to the default PAL configuration, you can simply delete the custom configuration file you created in the ~/.pal/config folder.

See also#

To continue learning about the Behavior Trees used in Nav2, and specific nodes used in the BTs you can check Nav2 Behavior Trees