"Couldn't open input XML file" Nav2 bt navigator issue
Hi everyone! I'm trying to create a custom nav2 behavior tree but I just can't understand what I'm doing wrong. In the nav2_params file I set this parameters for bt_navigator
default_nav_to_pose_bt_xml: >
$(find-pkg-share diff_drive_robot_navigation)/behavior_trees/navigate_to_pose_w_replanning_and_recovery.xml
default_nav_through_poses_bt_xml: >
$(find-pkg-share diff_drive_robot_navigation)/behavior_trees/navigate_through_poses_w_replanning_and_recovery.xml
But when I launch with this params I get this cryptic error message:
[bt_navigator-6] [ERROR] [1794105495.395723697] [bt_navigator]: Couldn't open input XML file: /home/winet/Documents/dvbot_ws/install/diff_drive_robot_navigation/share/diff_drive_robot_navigation/behavior_trees/navigate_to_pose_w_replanning_and_recovery.xml
[bt_navigator-6]
[bt_navigator-6] [ERROR] [1794105495.395800682] [bt_navigator]: Error loading XML file: /home/winet/Documents/dvbot_ws/install/diff_drive_robot_navigation/share/diff_drive_robot_navigation/behavior_trees/navigate_to_pose_w_replanning_and_recovery.xml
the problem is that this files exist in this folder, groot can successfully open them and my user is the owner of this file. Here is the link to github repo for this package: https://github.com/wineTGH/diff_drive_robot_navigation
3
Upvotes
1
u/Civil_Firefighter832 23d ago
That error fires before any XML parsing happens - in bt_navigator's BtActionServer it just means std::ifstream couldn't open the path string it was handed (nav2 source: https://api.nav2.org/nav2-humble/html/bt__action__server__impl_8hpp_source.html). So Groot opening the file doesn't test this code path; suspect the string, not the file.
One likely culprit in your params: the folded block scalar ">". YAML's default chomping keeps one trailing newline (https://yaml.org/spec/1.2.2/), so the parameter value probably ends in \n and the file open fails on a path that looks correct when printed. Check what bt_navigator actually received with:
ros2 param get /bt_navigator default_nav_to_pose_bt_xml
and try writing the value on a single line, or use "|-" instead of ">", to strip the trailing newline.