#!/usr/bin/python3 """生成 BCR 机器人(GzWeb 可视化,无 ros_gz_bridge / Nav2)。""" from os.path import join from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import DeclareLaunchArgument from launch.substitutions import Command, LaunchConfiguration from launch_ros.actions import Node def generate_launch_description(): bcr_bot_path = get_package_share_directory('bcr_bot') position_x = LaunchConfiguration('position_x', default='0.0') position_y = LaunchConfiguration('position_y', default='0.0') orientation_yaw = LaunchConfiguration('orientation_yaw', default='0.0') robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', name='robot_state_publisher', parameters=[{ 'robot_description': Command([ 'xacro ', join(bcr_bot_path, 'urdf/bcr_bot.xacro'), ' camera_enabled:=false', ' stereo_camera_enabled:=false', ' two_d_lidar_enabled:=false', ' odometry_source:=world', ' sim_gz:=true', ]), }], remappings=[('/joint_states', 'bcr_bot/joint_states')], ) gz_spawn_entity = Node( package='ros_gz_sim', executable='create', arguments=[ '-topic', '/robot_description', '-name', 'bcr_bot', '-allow_renaming', 'true', '-z', '0.28', '-x', position_x, '-y', position_y, '-Y', orientation_yaw, ], ) return LaunchDescription([ DeclareLaunchArgument('position_x', default_value='0.0'), DeclareLaunchArgument('position_y', default_value='0.0'), DeclareLaunchArgument('orientation_yaw', default_value='0.0'), robot_state_publisher, gz_spawn_entity, ])