../_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

๐ŸŒณ Target Navigation BT#

As mentioned in ๐ŸŽฏ Target Navigation chapter, the Target Navigation framework is implemented in the NavigateToTarget Navigator which is a Nav2 Behavior-Tree Navigator. As such, this navigator allows you to define a custom navigation logic using a Behavior Tree to define the robotโ€™s behavior while approaching a target and any recovery logics.

In this section, you will find the available Behavior Trees for the Target Navigation module and learn how to create your own.

PAL robots are equipped with the following behavior tree for the target navigation:

  • navigate_to_target.xml

Note

You can find the available PAL behavior tree in

ls /opt/pal/${PAL_DISTRO}/share/pal_nav2_bt_navigator/behavior_trees/

This behavior tree is used to navigate the robot to a target and has the following nodes:

Plugin Name

BT Node Type

DetectTarget

Action

NavigateToPose

Action

To learn more about the types of BT nodes, you can refer to the official BT basic documentation.

Behavior Tree#

Behavior Tree Nodes#

DetectTarget#

Detects and localizes a target in the environment.

Port Name

Type

Description

Input Ports

target

(int, DEFAULT=N/A)

Navigation target identifier.

detector

(string, DEFAULT=N/A)

Detector used for detecting the target pose.

Output Ports

goal

(geometry_msgs::msg::PoseStamped, DEFAULT=N/A)

Target pose.

error_code_id

(uint16, DEFAULT=N/A)

Error code in case an error has occurred.

How to create your Target Navigation Behavior Tree Node#

In addition to all the PAL Behavior Tree nodes and the Nav2 Behavior Tree, you might want to develop your custom node implementing a desired behavior.

Note

To see the list of all the PAL Behavior Tree nodes, you can use the command:

cat /opt/pal/${PAL_DISTRO}/share/pal_nav2_behavior_tree/pal_nav2_tree_nodes.xml

To see the list of all the Nav2 Behavior Tree nodes, you can use the command:

cat /opt/ros/${ROS_DISTRO}/share/nav2_behavior_tree/nav2_tree_nodes.xml

To create your Behavior Tree node with your custom logic, you can refer to the Nav2 official documentation.

Once created, you can start using your Behavior Tree node for the Target Navigation by creating a new configuration file in the ~/.pal directory 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 custom bt_navigator parameters. For the list of available parameters, their meaning and how they affect the bt_navigator node, 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

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.

How to create your Target Navigation Behavior Tree#

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

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.

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

Once created, you can start using your XML file with your custom BT with the Target Navigation.

To use your BT with the NavigateToTarget Navigator you can directly use the action server /navigate_to_target and provide the full path to your XML file in the behavior_tree field of the goal message.

Otherwise, if you want to set your custom BT as the default one for the NavigateToTarget Navigator, you can refer to the following steps:

Create a new configuration file in the ~/.pal directory of your robot:

mkdir -p ~/.pal/config

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

touch ~/.pal/config/99_my_navigate_to_target_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_navigate_to_target_config.yaml file, you can insert your custom navigate_to_target parameters. For the list of available parameters, their meaning and how they affect the navigate_to_target node, you can refer to the ๐ŸŽฏ Target Navigation. When creating a new Navigation configuration file, you need to specify the node name it refers to, in this case, navigate_to_target.

/navigate_to_target:
   ros__parameters:
      # Your navigate_to_target parameters

      default_nav_through_waypoints_bt_xml: "/home/pal/.pal/config/my_custom_bt.xml"

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

pal module restart advanced_navigation

Note

This change is is persistent and will be loaded every time you start the advanced_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.