ros-navigation / docs.nav2.org

https://docs.nav2.org/
https://docs.nav2.org/
Apache License 2.0
90 stars 183 forks source link

Changing the Behavior Tree in my nav2 project #589

Closed AshBastian closed 1 month ago

AshBastian commented 1 month ago

Hello Everyone, I tried to change my behavior tree in my project, but the system just ignores my inputs and uses the default behavior tree. I hope somebody can help me with this problem.

I'm using ROS2 Humble on an Ubuntu 22.04.

Inside my yaml file:

bt_navigator:
  ros__parameters:
    use_sim_time: True
    global_frame: map
    robot_base_frame: base_link
    odom_topic: /odom
    enable_groot_monitoring: True
    groot_zmq_publisher_port: 1666
    groot_zmq_server_port: 1667
    default_bt_xml_filename: "navigate_w_replanning_speed.xml"
    bt_loop_duration: 10
    default_server_timeout: 20
    plugin_lib_names:
    - nav2_compute_path_to_pose_action_bt_node
    - nav2_compute_path_through_poses_action_bt_node
    - nav2_follow_path_action_bt_node
    - nav2_back_up_action_bt_node
    - nav2_spin_action_bt_node
    - nav2_wait_action_bt_node
    - nav2_clear_costmap_service_bt_node
    - nav2_is_stuck_condition_bt_node
    - nav2_goal_reached_condition_bt_node
    - nav2_goal_updated_condition_bt_node
    - nav2_initial_pose_received_condition_bt_node
    - nav2_reinitialize_global_localization_service_bt_node
    - nav2_rate_controller_bt_node
    - nav2_distance_controller_bt_node
    - nav2_speed_controller_bt_node
    - nav2_truncate_path_action_bt_node
    - nav2_goal_updater_node_bt_node
    - nav2_recovery_node_bt_node
    - nav2_pipeline_sequence_bt_node
    - nav2_round_robin_node_bt_node
    - nav2_transform_available_condition_bt_node
    - nav2_time_expired_condition_bt_node
    - nav2_distance_traveled_condition_bt_node
    - nav2_single_trigger_bt_node
    - nav2_is_battery_low_condition_bt_node
    - nav2_navigate_through_poses_action_bt_node
    - nav2_navigate_to_pose_action_bt_node
    - nav2_remove_passed_goals_action_bt_node
    - nav2_planner_selector_bt_node
    - nav2_controller_selector_bt_node
    - nav2_goal_checker_selector_bt_node

My Node that loads the bt_navigator plugin with the configured_params beeing the yaml file

Node(
                package='nav2_bt_navigator',
                executable='bt_navigator',
                name='bt_navigator',
                output='screen',
                respawn=use_respawn,
                respawn_delay=2.0,
                parameters=[configured_params],
                arguments=['--ros-args', '--log-level', log_level],
                remappings=remappings),

One last remark, I can also not see my behavior tree in Groot live monitoring, even with the ports defined

SteveMacenski commented 1 month ago
default_bt_xml_filename: "navigate_w_replanning_speed.xml"

This needs to be the full path to your BT. I'm guessing your see logging errors that the BT XML is invalid.

I think you're also using the wrong parameter name: https://github.com/ros-navigation/navigation2/blob/humble/nav2_bt_navigator/src/navigators/navigate_to_pose.cpp#L64

AshBastian commented 1 month ago

Yes, when using the parameter name from the file you shared, I get the Error of could not open file. I dont really get why, because now I'm giving the full path.

bt_navigator:
  ros__parameters:
    use_sim_time: True
    global_frame: map
    robot_base_frame: base_link
    odom_topic: /odom
    enable_groot_monitoring: True
    groot_zmq_publisher_port: 1666
    groot_zmq_server_port: 1667
    default_bt_xml_filename: "navigate_w_replanning_speed.xml"
    default_nav_to_pose_bt_xml: home/bastian/Documents/own_navigation/install/gazebo_simulation/share/gazebo_simulation/xml/own_behavior_tree.xml
    bt_loop_duration: 10
    default_server_timeout: 20
    plugin_lib_names:
    - nav2_compute_path_to_pose_action_bt_node
    - nav2_compute_path_through_poses_action_bt_node
    - nav2_follow_path_action_bt_node
    - nav2_back_up_action_bt_node
    - nav2_spin_action_bt_node
    - nav2_wait_action_bt_node
    - nav2_clear_costmap_service_bt_node
    - nav2_is_stuck_condition_bt_node
    - nav2_goal_reached_condition_bt_node
    - nav2_goal_updated_condition_bt_node
    - nav2_initial_pose_received_condition_bt_node
    - nav2_reinitialize_global_localization_service_bt_node
    - nav2_rate_controller_bt_node
    - nav2_distance_controller_bt_node
    - nav2_speed_controller_bt_node
    - nav2_truncate_path_action_bt_node
    - nav2_goal_updater_node_bt_node
    - nav2_recovery_node_bt_node
    - nav2_pipeline_sequence_bt_node
    - nav2_round_robin_node_bt_node
    - nav2_transform_available_condition_bt_node
    - nav2_time_expired_condition_bt_node
    - nav2_distance_traveled_condition_bt_node
    - nav2_single_trigger_bt_node
    - nav2_is_battery_low_condition_bt_node
    - nav2_navigate_through_poses_action_bt_node
    - nav2_navigate_to_pose_action_bt_node
    - nav2_remove_passed_goals_action_bt_node
    - nav2_planner_selector_bt_node
    - nav2_controller_selector_bt_node
    - nav2_goal_checker_selector_bt_node
[bt_navigator-16] [ERROR] [1725973784.886966723] [omni1.bt_navigator]: Couldn't open input XML file: home/bastian/Documents/own_navigation/install/gazebo_simulation/share/gazebo_simulation/xml/own_behavior_tree.xml
[bt_navigator-16] [ERROR] [1725973784.886993472] [omni1.bt_navigator]: Error loading XML file: home/bastian/Documents/own_navigation/install/gazebo_simulation/share/gazebo_simulation/xml/own_behavior_tree.xml
AshBastian commented 1 month ago

And also I would like to monitor my behavior tree with groot. I have groot working on my system, but I don't know how to set the parameters for the ports, to start the monitoring

SteveMacenski commented 1 month ago

You’re missing the leading ‘/‘ in your filepath.

AshBastian commented 1 month ago

You are totally right, I didn't recognize that. But is there a way to live monitor the behavior tree with groot? I found some discussions, where the change from 1 to 2 behavior trees failed the groot monitoring, but is there a solution by now?

SteveMacenski commented 1 month ago

Live monitoring hasn't really been used by many since it ticks so fast (100hz by default) so its difficult to track. There's a publisher topic on the BT state that can be listend to for programmatic use, but we do not support live groot monitoring since it doesn't allow us to change the BT or have multiple instances of the ZMQ client for the various navigator plugins. Its technically infeasible with the full set of dynamic features that Nav2 provides.