gazebo中显示多个机器人模型
-
请问我在gazebo.launch文件中修改了一个机器人模型,但是命名空间是不起作用还是咋了
一直停留在[robot3.spawn_entity]:Waiting for entity xml on robot1/robot_description不显示机器人模型
具体launch修改代码如下:
import launch
import launch_ros
from ament_index_python.packages import get_package_share_directory
import os
import launch_ros.parameter_descriptions
import launch.launch_description_sources
def generate_launch_description():
# 获取功能包的share路径
urdf_package_path = get_package_share_directory('fishbot_description')
default_xacro_path = os.path.join(urdf_package_path, 'urdf', 'fishbot', 'fishbot.urdf.xacro')
default_gazebo_world_path = os.path.join(urdf_package_path, 'world', 'custom_room.world')# 声明一个urdf目录参数,方便修改 action_declare_arg_mode_path = launch.actions.DeclareLaunchArgument( name='model', default_value=str(default_xacro_path), description='加载的模型文件路径' ) # 处理三个机器人的URDF robot1_desc = launch.substitutions.Command(['xacro ', default_xacro_path, ' prefix:=robot1/']) robot2_desc = launch.substitutions.Command(['xacro ', default_xacro_path, ' prefix:=robot2/']) robot3_desc = launch.substitutions.Command(['xacro ', default_xacro_path, ' prefix:=robot3/']) # 第一个机器人状态发布器 robot1_state_publisher = launch_ros.actions.Node( package='robot_state_publisher', executable='robot_state_publisher', namespace='robot1', parameters=[{ 'robot_description': launch_ros.parameter_descriptions.ParameterValue(robot1_desc, value_type=str), 'frame_prefix': 'robot1/' }], ) # 第二个机器人状态发布器 robot2_state_publisher = launch_ros.actions.Node( package='robot_state_publisher', executable='robot_state_publisher', namespace='robot2', parameters=[{ 'robot_description': launch_ros.parameter_descriptions.ParameterValue(robot2_desc, value_type=str), 'frame_prefix': 'robot2/' }], ) # 第三个机器人状态发布器 robot3_state_publisher = launch_ros.actions.Node( package='robot_state_publisher', executable='robot_state_publisher', namespace='robot3', parameters=[{ 'robot_description': launch_ros.parameter_descriptions.ParameterValue(robot3_desc, value_type=str), 'frame_prefix': 'robot3/' }], ) # 启动 Gazebo 仿真环境 action_launch_gazebo = launch.actions.IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource( os.path.join(get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py') ), launch_arguments=[('world', default_gazebo_world_path), ('verbose', 'true')] ) # 将机器人1加载到 Gazebo action_spawn_robot1 = launch_ros.actions.Node( package='gazebo_ros', executable='spawn_entity.py', namespace='robot1', arguments=[ '-topic', 'robot1/robot_description', '-entity', 'robot1', '-x', '0.4', '-y', '0', '-z', '0' ], output='screen' ) # 将机器人2加载到 Gazebo action_spawn_robot2 = launch_ros.actions.Node( package='gazebo_ros', executable='spawn_entity.py', namespace='robot2', arguments=[ '-topic', 'robot2/robot_description', '-entity', 'robot2', '-x', '-0.4', '-y', '0', '-z', '0' ], output='screen' ) # 将机器人3加载到 Gazebo action_spawn_robot3 = launch_ros.actions.Node( package='gazebo_ros', executable='spawn_entity.py', namespace='robot3', arguments=[ '-topic', 'robot3/robot_description', '-entity', 'robot3', '-x', '0', '-y', '0', '-z', '0' ], output='screen' ) return launch.LaunchDescription([ action_declare_arg_mode_path, robot1_state_publisher, robot2_state_publisher, robot3_state_publisher, action_launch_gazebo, action_spawn_robot1, action_spawn_robot2, action_spawn_robot3 ])
-
我是想在gazebo中显示三个机器人模型,fishbot可以显示,但是三个就显示不了
-
@小鱼我这样做机器人模型xacro还需要更改嘛?