From 2a066ab48e7e5450a1feb5e026966b75ec65fe1d Mon Sep 17 00:00:00 2001 From: clhchan Date: Mon, 1 Jun 2026 10:44:38 +0800 Subject: [PATCH] chore(agv_pro_navigation2): clean nav launch and example script --- .../launch/navigation2_active.launch.py | 24 ++++--------------- .../scripts/example_nav_to_pose.py | 16 +++---------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/agv_pro_navigation2/launch/navigation2_active.launch.py b/agv_pro_navigation2/launch/navigation2_active.launch.py index c5a651a..0b62623 100644 --- a/agv_pro_navigation2/launch/navigation2_active.launch.py +++ b/agv_pro_navigation2/launch/navigation2_active.launch.py @@ -3,11 +3,7 @@ import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription -from launch.actions import ( - DeclareLaunchArgument, - GroupAction, - IncludeLaunchDescription, -) +from launch.actions import DeclareLaunchArgument, GroupAction, IncludeLaunchDescription from launch.conditions import IfCondition from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.substitutions import LaunchConfiguration @@ -19,26 +15,16 @@ def generate_launch_description(): use_rviz = LaunchConfiguration('use_rviz', default='true') map_dir = LaunchConfiguration( 'map', - default=os.path.join( - get_package_share_directory('agv_pro_navigation2'), - 'map', - 'map.yaml')) + default=os.path.join(get_package_share_directory('agv_pro_navigation2'), 'map', 'map.yaml')) param_file_name = 'agvpro.yaml' param_dir = LaunchConfiguration( 'params_file', - default=os.path.join( - get_package_share_directory('agv_pro_navigation2'), - 'param', - param_file_name)) + default=os.path.join(get_package_share_directory('agv_pro_navigation2'), 'param', param_file_name)) - nav2_launch_file_dir = os.path.join( - get_package_share_directory('nav2_bringup'), 'launch') + nav2_launch_file_dir = os.path.join(get_package_share_directory('nav2_bringup'), 'launch') - rviz_config_dir = os.path.join( - get_package_share_directory('agv_pro_navigation2'), - 'rviz', - 'agvpro_navigation2.rviz') + rviz_config_dir = os.path.join(get_package_share_directory('agv_pro_navigation2'), 'rviz', 'agvpro_navigation2.rviz') return LaunchDescription([ DeclareLaunchArgument( diff --git a/agv_pro_navigation2/scripts/example_nav_to_pose.py b/agv_pro_navigation2/scripts/example_nav_to_pose.py index 938bff6..d31a242 100644 --- a/agv_pro_navigation2/scripts/example_nav_to_pose.py +++ b/agv_pro_navigation2/scripts/example_nav_to_pose.py @@ -16,11 +16,6 @@ Basic navigation demo to go to pose. def parse_arguments(): parser = argparse.ArgumentParser(description='Send navigation test goals.') - parser.add_argument( - '--localization', - choices=('amcl', 'slam'), - default='amcl', - help='Localization backend started by navigation2_active.launch.py.') parser.add_argument( 'targets', nargs='*', @@ -99,14 +94,9 @@ if __name__ == '__main__': rclpy.init() navigator = BasicNavigator() - if cli_args.localization == 'slam': - # slam_toolbox on Humble is not a Nav2 lifecycle-managed localizer. - navigator._waitForNodeToActivate('bt_navigator') - navigator.info('Nav2 is ready for use!') - else: - # AMCL obtains its initial origin pose from agvpro.yaml. - navigator.initial_pose_received = True - navigator.waitUntilNav2Active() + # AMCL obtains its initial origin pose from agvpro.yaml. + navigator.initial_pose_received = True + navigator.waitUntilNav2Active() # Try to load waypoints from YAML, fallback to hardcoded defaults waypoints = {}