../_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 Goal Navigation Behavior Tree with custom logic, by creating a new 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/pal_navigation_cfg_params/params/nav2_bt_navigator

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

touch ~/.pal/pal_navigation_cfg_params/params/nav2_bt_navigator/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 :

  • Use the /navigate_to_pose by providing the full path to your custom XML file as shown in the previous section ROS 2 Action.

  • Create your custom configuration for the bt_navigator and update the default bt_xml_filename 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/pal_navigation_cfg_params/params/nav2_bt_navigator

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

touch ~/.pal/pal_navigation_cfg_params/params/nav2_bt_navigator/my_bt_navigator_config.yaml

Within the newly created my_bt_navigator_config.yaml file, you can insert your custom BT Navigator parameters. For the list of available parameters, you can refer to the Nav2 BT Navigator configuration guide. When creating a new Navigation configuration file, apart from the node parameters, you also need to specify the robot to which they refer.

pal_navigation_cfg:
   ros__parameters:
      supported_robots:
      - some_pal_robot # e.g. tiago, omni_base, tiago_pro, etc.

bt_navigator:
   # Your BT Navigator Parameters
   default_nav_to_pose_bt_xml: /home/pal/.pal/pal_navigation_cfg_params/params/nav2_bt_navigator/my_custom_bt.xml # Full path to your custom BT XML file

Once created, to start using your custom BT Navigator configuration, you need to set it in the navigation pipeline by modifying the <robot>_nav.yaml file in the <robot>_2dnav package.

sudo vi /opt/pal/$PAL_DISTRO/share/<robot>_2dnav/params/<robot>_nav.yaml

And then, change the params field of the bt_navigator to the name of your custom BT Navigator configuration file.

Attention

Make sure to replace the <robot> placeholder with the name of your robot (e.g. tiago, omni_base, tiago_pro, etc.).

nodes:
   # Other nodes
   bt_navigator:
      app: bt_navigator
      params: [my_bt_navigator_config]

Attention

Make sure that the name of the custom BT Navigator configuration file you use in the params field (my_bt_navigator_config) is the same as the name of the file you created in the .pal folder (my_bt_navigator_config.yaml).

Finally, to apply the changes and start using the new BT Navigator configuration, you need to restart the navigation pipeline with the command:

pal module restart navigation

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