๐ณ 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 |
---|---|
Action |
|
Action |
To learn more about the types of BT nodes, you can refer to the official BT basic documentation.
Behavior Tree#
Navigate To Target#
The main BT for the target navigation is the navigate_to_target.xml
. Using this BT allows for
dynamic adjustment of the navigation strategy based on the specific requirements of the target, the detectorโs output,
and the current environmental context.
The functionality of the BT is to detect a target pose and process it with the NavigateToPose
.
Navigate To Local Target#
An alternative BT for the target navigation is the navigate_to_local_target.xml
. This BT is used to move the robot
using directly the FollowPath
Action server to a target pose detected by the detector.
This means that only the Controller Server is used to move the robot.
Behavior Tree Nodes#
DetectTarget#
Detects and localizes a target in the environment.
Port Name |
Type |
Description |
|
---|---|---|---|
Input Ports |
|
|
Navigation target identifier. |
|
|
Detector used for detecting the target pose. |
|
Output Ports |
|
|
Target pose. |
|
|
Error code in case an error has occurred. |
NavigateToPose#
Navigates the robot to a target identified by an ID, using a specified detector and a Behavior Tree (BT) for the navigation logic. This navigator extends the functionalities provided by the NAV2 official documentation.
Port Name |
Type |
Description |
|
---|---|---|---|
Input Ports |
|
|
Navigation target identifier. |
|
|
Detector used for detecting the target pose. |
|
|
|
BT used for navigating to the target pose. |
|
Output Ports |
|
|
Error code in case an error has occurred. |
Usage#
To configure this BT node you can refer to the ๐ Target Navigation API section.
To use the NavigateToTarget
Navigator you need to send a goal to the action server /navigate_to_target,
specifying the target ID, the detector name and a BT for the navigation logic.
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.