从ros1平台迁移到ros2平台,然后将机器人模型导入gazebo时失败,gazebo无响应
-
launch文件gazebo_world.launch.py
import os from launch import LaunchDescription from launch.launch_description_sources import PythonLaunchDescriptionSource from launch.actions import DeclareLaunchArgument, IncludeLaunchDescription from launch_ros.actions import Node from launch.substitutions import Command , LaunchConfiguration from launch_ros.parameter_descriptions import ParameterValue from ament_index_python.packages import get_package_share_directory def generate_launch_description(): urdf_package_path = get_package_share_directory('robot_description') default_urdf_path=os.path.join(urdf_package_path,'urdf','robot_description.urdf') action_declare_arg_model_robot = DeclareLaunchArgument('model', default_value = default_urdf_path, description = 'Model of the robot') substitutions_command_result = Command(['xacro ',LaunchConfiguration('model')]) robot_description_value = ParameterValue(substitutions_command_result, value_type=str) action_declare_x_pos = DeclareLaunchArgument('x_pos', default_value='0.0', description='X position') action_declare_y_pos = DeclareLaunchArgument('y_pos', default_value='0.0', description='Y position') action_declare_z_pos = DeclareLaunchArgument('z_pos', default_value='0.0', description='Z position') action_launch_gazebo = IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join( get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py' ) ), launch_arguments={ 'world': os.path.join(get_package_share_directory('robot_description'), 'world', 'room.world'), 'paused': 'false', 'use_sim_time': 'true', 'gui': 'true', 'headless': 'false', 'debug': 'true' }.items() ) action_robot_state_publisher = Node( package='robot_state_publisher', executable='robot_state_publisher', output='screen', parameters=[{ 'robot_description': robot_description_value }] ) action_spawn_entity = Node( package='gazebo_ros', executable='spawn_entity.py', arguments=[ '-topic','/robot_description', '-entity','Fu_robot' ] ) return LaunchDescription([ action_declare_x_pos, action_declare_y_pos, action_declare_z_pos, action_declare_arg_model_robot, action_robot_state_publisher, action_launch_gazebo, action_spawn_entity ])
终端输入:
ros2 launch robot_description gazebo_world.launch.py model:=/home/leolanqin/catkin_ws_ros2/src/robot_description/urdf/robot_description.urdf.xacro
终端显示:
[INFO] [launch]: All log files can be found below /home/leolanqin/.ros/log/2024-12-24-19-48-39-601713-leolanqin-virtual-machine-137116 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [robot_state_publisher-1]: process started with pid [137128] [INFO] [gzserver-2]: process started with pid [137130] [INFO] [gzclient-3]: process started with pid [137132] [INFO] [spawn_entity.py-4]: process started with pid [137134] [robot_state_publisher-1] [INFO] [1735040920.589923166] [robot_state_publisher]: got segment /ball_wheel_link [robot_state_publisher-1] [INFO] [1735040920.591342777] [robot_state_publisher]: got segment /base_camera_link [robot_state_publisher-1] [INFO] [1735040920.591364087] [robot_state_publisher]: got segment /base_footprint [robot_state_publisher-1] [INFO] [1735040920.591374176] [robot_state_publisher]: got segment /base_laser_link [robot_state_publisher-1] [INFO] [1735040920.591382682] [robot_state_publisher]: got segment /base_link [robot_state_publisher-1] [INFO] [1735040920.591391448] [robot_state_publisher]: got segment /imu [robot_state_publisher-1] [INFO] [1735040920.591401007] [robot_state_publisher]: got segment /left_wheel_link [robot_state_publisher-1] [INFO] [1735040920.591411176] [robot_state_publisher]: got segment /right_wheel_link [spawn_entity.py-4] [INFO] [1735040921.331660406] [spawn_entity]: Spawn Entity started [spawn_entity.py-4] [INFO] [1735040921.333053717] [spawn_entity]: Loading entity published on topic /robot_description [spawn_entity.py-4] /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead. [spawn_entity.py-4] warnings.warn( [spawn_entity.py-4] [INFO] [1735040921.338627613] [spawn_entity]: Waiting for entity xml on /robot_description [spawn_entity.py-4] [INFO] [1735040921.355291473] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30 [spawn_entity.py-4] [INFO] [1735040921.355721465] [spawn_entity]: Waiting for service /spawn_entity [gzserver-2] Error: Non-unique names detected in <link name='link'> [gzserver-2] <collision name='surface'> [gzserver-2] <pose>0 0 1 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <box> [gzserver-2] <size>1.5 0.8 0.03</size> [gzserver-2] </box> [gzserver-2] </geometry> [gzserver-2] <surface> [gzserver-2] <friction> [gzserver-2] <ode> [gzserver-2] <mu>0.6</mu> [gzserver-2] <mu2>0.6</mu2> [gzserver-2] </ode> [gzserver-2] <torsional> [gzserver-2] <ode/> [gzserver-2] </torsional> [gzserver-2] </friction> [gzserver-2] <contact> [gzserver-2] <ode/> [gzserver-2] </contact> [gzserver-2] <bounce/> [gzserver-2] </surface> [gzserver-2] <max_contacts>10</max_contacts> [gzserver-2] </collision> [gzserver-2] <visual name='visual1'> [gzserver-2] <pose>0 0 1 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <box> [gzserver-2] <size>1.5 0.8 0.03</size> [gzserver-2] </box> [gzserver-2] </geometry> [gzserver-2] <material> [gzserver-2] <script> [gzserver-2] <uri>file://media/materials/scripts/gazebo.material</uri> [gzserver-2] <name>Gazebo/Wood</name> [gzserver-2] </script> [gzserver-2] </material> [gzserver-2] </visual> [gzserver-2] <collision name='front_left_leg'> [gzserver-2] <pose>0.68 0.38 0.5 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <cylinder> [gzserver-2] <radius>0.02</radius> [gzserver-2] <length>1</length> [gzserver-2] </cylinder> [gzserver-2] </geometry> [gzserver-2] <max_contacts>10</max_contacts> [gzserver-2] <surface> [gzserver-2] <contact> [gzserver-2] <ode/> [gzserver-2] </contact> [gzserver-2] <bounce/> [gzserver-2] <friction> [gzserver-2] <torsional> [gzserver-2] <ode/> [gzserver-2] </torsional> [gzserver-2] <ode/> [gzserver-2] </friction> [gzserver-2] </surface> [gzserver-2] </collision> [gzserver-2] <visual name='front_left_leg'> [gzserver-2] <pose>0.68 0.38 0.5 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <cylinder> [gzserver-2] <radius>0.02</radius> [gzserver-2] <length>1</length> [gzserver-2] </cylinder> [gzserver-2] </geometry> [gzserver-2] <material> [gzserver-2] <script> [gzserver-2] <uri>file://media/materials/scripts/gazebo.material</uri> [gzserver-2] <name>Gazebo/Grey</name> [gzserver-2] </script> [gzserver-2] </material> [gzserver-2] </visual> [gzserver-2] <collision name='front_right_leg'> [gzserver-2] <pose>0.68 -0.38 0.5 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <cylinder> [gzserver-2] <radius>0.02</radius> [gzserver-2] <length>1</length> [gzserver-2] </cylinder> [gzserver-2] </geometry> [gzserver-2] <max_contacts>10</max_contacts> [gzserver-2] <surface> [gzserver-2] <contact> [gzserver-2] <ode/> [gzserver-2] </contact> [gzserver-2] <bounce/> [gzserver-2] <friction> [gzserver-2] <torsional> [gzserver-2] <ode/> [gzserver-2] </torsional> [gzserver-2] <ode/> [gzserver-2] </friction> [gzserver-2] </surface> [gzserver-2] </collision> [gzserver-2] <visual name='front_right_leg'> [gzserver-2] <pose>0.68 -0.38 0.5 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <cylinder> [gzserver-2] <radius>0.02</radius> [gzserver-2] <length>1</length> [gzserver-2] </cylinder> [gzserver-2] </geometry> [gzserver-2] <material> [gzserver-2] <script> [gzserver-2] <uri>file://media/materials/scripts/gazebo.material</uri> [gzserver-2] <name>Gazebo/Grey</name> [gzserver-2] </script> [gzserver-2] </material> [gzserver-2] </visual> [gzserver-2] <collision name='back_right_leg'> [gzserver-2] <pose>-0.68 -0.38 0.5 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <cylinder> [gzserver-2] <radius>0.02</radius> [gzserver-2] <length>1</length> [gzserver-2] </cylinder> [gzserver-2] </geometry> [gzserver-2] <max_contacts>10</max_contacts> [gzserver-2] <surface> [gzserver-2] <contact> [gzserver-2] <ode/> [gzserver-2] </contact> [gzserver-2] <bounce/> [gzserver-2] <friction> [gzserver-2] <torsional> [gzserver-2] <ode/> [gzserver-2] </torsional> [gzserver-2] <ode/> [gzserver-2] </friction> [gzserver-2] </surface> [gzserver-2] </collision> [gzserver-2] <visual name='back_right_leg'> [gzserver-2] <pose>-0.68 -0.38 0.5 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <cylinder> [gzserver-2] <radius>0.02</radius> [gzserver-2] <length>1</length> [gzserver-2] </cylinder> [gzserver-2] </geometry> [gzserver-2] <material> [gzserver-2] <script> [gzserver-2] <uri>file://media/materials/scripts/gazebo.material</uri> [gzserver-2] <name>Gazebo/Grey</name> [gzserver-2] </script> [gzserver-2] </material> [gzserver-2] </visual> [gzserver-2] <collision name='back_left_leg'> [gzserver-2] <pose>-0.68 0.38 0.5 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <cylinder> [gzserver-2] <radius>0.02</radius> [gzserver-2] <length>1</length> [gzserver-2] </cylinder> [gzserver-2] </geometry> [gzserver-2] <max_contacts>10</max_contacts> [gzserver-2] <surface> [gzserver-2] <contact> [gzserver-2] <ode/> [gzserver-2] </contact> [gzserver-2] <bounce/> [gzserver-2] <friction> [gzserver-2] <torsional> [gzserver-2] <ode/> [gzserver-2] </torsional> [gzserver-2] <ode/> [gzserver-2] </friction> [gzserver-2] </surface> [gzserver-2] </collision> [gzserver-2] <visual name='back_left_leg'> [gzserver-2] <pose>-0.68 0.38 0.5 0 -0 0</pose> [gzserver-2] <geometry> [gzserver-2] <cylinder> [gzserver-2] <radius>0.02</radius> [gzserver-2] <length>1</length> [gzserver-2] </cylinder> [gzserver-2] </geometry> [gzserver-2] <material> [gzserver-2] <script> [gzserver-2] <uri>file://media/materials/scripts/gazebo.material</uri> [gzserver-2] <name>Gazebo/Grey</name> [gzserver-2] </script> [gzserver-2] </material> [gzserver-2] </visual> [gzserver-2] <self_collide>0</self_collide> [gzserver-2] <enable_wind>0</enable_wind> [gzserver-2] <kinematic>0</kinematic> [gzserver-2] </link> [gzserver-2] [spawn_entity.py-4] [INFO] [1735040922.136157557] [spawn_entity]: Calling service /spawn_entity [gzserver-2] Topic [default/Fu_robot//base_footprint/csi_Camera/image] is not valid. [gzserver-2] [INFO] [1735040922.819461672] [camera_controller]: Publishing camera info to [/csi_Camera/camera_info] [spawn_entity.py-4] [INFO] [1735040923.350189398] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [Fu_robot] [INFO] [spawn_entity.py-4]: process has finished cleanly [pid 137134]
-
@2745914991 在 从ros1平台迁移到ros2平台,然后将机器人模型导入gazebo时失败,gazebo无响应 中说:
Error: Non-unique names detected in <link name='link'>
出现了重复名字的link,建议仔细检查下urdf
-
@小鱼 感谢鱼哥回复,我已经仔细检查了我的urdf文件,并没有出现重复名字的link
这是我的urdf文件robot_description.urdf<robot name="robot_description"> <link name="base_footprint"/> <joint name="base_joint" type="fixed"> <parent link="base_footprint"/> <child link="base_link"/> <origin xyz="0.0 0.0 0.012" rpy="0 0 0"/> </joint> <link name="base_link"> <inertial> <origin xyz="-0.021363490239433 0.000185677952833835 0.0417013760059846" rpy="0 0 0" /> <mass value="0.4442754144754" /> <inertia ixx="0.00169347433894092" ixy="-2.48653191534453E-07" ixz="3.6777445179091E-05" iyy="0.00104562302644335" iyz="-4.01932028426777E-06" izz="0.00148226749250531" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/base_link.STL" /> </geometry> <material name=""> <color rgba="1 1 1 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/base_link.STL" /> </geometry> </collision> </link> <link name="imu"> <inertial> <origin xyz="3.46944695195361E-18 0 -0.00353385896202057" rpy="0 0 0" /> <mass value="0.000834" /> <inertia ixx="1.72751258992806E-08" ixy="2.49134059713724E-24" ixz="-2.52435489670724E-26" iyy="1.01251258992806E-08" iyz="1.8466691376894E-25" izz="2.3801E-08" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/imu.STL" /> </geometry> <material name=""> <color rgba="1 1 1 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/imu.STL" /> </geometry> </collision> </link> <joint name="imu_joint" type="fixed"> <origin xyz="-0.056956 -0.0059543 0.072756" rpy="0 5.2369E-16 0" /> <parent link="base_link" /> <child link="imu" /> <axis xyz="0 0 0" /> </joint> <link name="base_camera_link"> <inertial> <origin xyz="-0.0045346942299942 1.38777878078145E-17 -0.00179125965737512" rpy="0 0 0" /> <mass value="0.00100487943921971" /> <inertia ixx="7.55677391275611E-08" ixy="-2.39038796583022E-24" ixz="-1.37755038601046E-09" iyy="3.94938932151791E-08" iyz="2.43323642233816E-23" izz="4.01523294449251E-08" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/base_camera_link.STL" /> </geometry> <material name=""> <color rgba="1 1 1 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/base_camera_link.STL" /> </geometry> </collision> </link> <joint name="camera_joint" type="fixed"> <origin xyz="0.0277 0 0.0623" rpy="-2.2337E-16 5.2369E-16 0" /> <parent link="base_link" /> <child link="base_camera_link" /> <axis xyz="0 0 0" /> </joint> <link name="base_laser_link"> <inertial> <origin xyz="-0.00911214120076251 0.000185677952834168 -0.0842986239940154" rpy="0 0 0" /> <mass value="0.4442754144754" /> <inertia ixx="0.00169347433894092" ixy="-2.4865319153732E-07" ixz="3.67774451790908E-05" iyy="0.00104562302644335" iyz="-4.01932028426874E-06" izz="0.00148226749250531" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/base_laser_link.STL" /> </geometry> <material name=""> <color rgba="1 1 1 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/base_laser_link.STL" /> </geometry> </collision> </link> <joint name="laser_joint" type="fixed"> <origin xyz="-0.012251 0 0.126" rpy="-1.6843E-15 -1.0776E-15 4.3793E-15" /> <parent link="base_link" /> <child link="base_laser_link" /> <axis xyz="0 0 0" /> </joint> <link name="left_wheel_link"> <inertial> <origin xyz="-6.93889390390723E-18 3.46944695195361E-18 0.017494370940819" rpy="0 0 0" /> <mass value="0.0561341413751443" /> <inertia ixx="2.45284373382495E-05" ixy="1.79487710154599E-21" ixz="7.36303183829231E-18" iyy="2.45284373382495E-05" iyz="1.73397416098309E-17" izz="4.23355136524843E-05" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/left_wheel_link.STL" /> </geometry> <material name=""> <color rgba="0.109803921568627 0.109803921568627 0.109803921568627 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/left_wheel_link.STL" /> </geometry> </collision> </link> <joint name="left_wheel_joint" type="continuous"> <origin xyz="0 0.0658 0.02275" rpy="-1.5708 5.2369E-16 8.6736E-17" /> <parent link="base_link" /> <child link="left_wheel_link" /> <axis xyz="0 0 1" /> <limit effort="100" velocity="100" /> </joint> <link name="right_wheel_link"> <inertial> <origin xyz="3.46944695195361E-18 -1.73472347597681E-18 -0.017494370940819" rpy="0 0 0" /> <mass value="0.0561341413751443" /> <inertia ixx="2.45284373382495E-05" ixy="-1.10855737450343E-21" ixz="-7.37237567686968E-18" iyy="2.45284373382495E-05" iyz="1.734064769358E-17" izz="4.23355136524843E-05" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/right_wheel_link.STL" /> </geometry> <material name=""> <color rgba="0.109803921568627 0.109803921568627 0.109803921568627 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/right_wheel_link.STL" /> </geometry> </collision> </link> <joint name="right_wheel_joint" type="continuous"> <origin xyz="0 -0.0658 0.02275" rpy="1.5708 -5.2369E-16 3.1416" /> <parent link="base_link" /> <child link="right_wheel_link" /> <axis xyz="0 0 1" /> <limit effort="100" velocity="100" /> </joint> <link name="ball_wheel_link"> <inertial> <origin xyz="-0.00805 0 0" rpy="0 0 0" /> <mass value="0.00218512482182764" /> <inertia ixx="5.66406205065944E-08" ixy="0" ixz="0" iyy="5.66406205065944E-08" iyz="0" izz="5.66406205065944E-08" /> </inertial> <visual> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/ball_wheel_link.STL" /> </geometry> <material name=""> <color rgba="1 1 1 1" /> </material> </visual> <collision> <origin xyz="0 0 0" rpy="0 0 0" /> <geometry> <mesh filename="package://robot_description/meshes/ball_wheel_link.STL" /> </geometry> </collision> </link> <joint name="ball_wheel_joint" type="fixed"> <origin xyz="-0.06445 0 -0.0028" rpy="0 5.2369E-16 0" /> <parent link="base_link" /> <child link="ball_wheel_link" /> <axis xyz="0 0 0" /> </joint> </robot>
此外我输入指令
check_urdf /home/leolanqin/catkin_ws_ros2/src/robot_description/urdf/robot_description.urdf
终端显示
robot name is: robot_description ---------- Successfully Parsed XML --------------- root Link: base_footprint has 1 child(ren) child(1): base_link child(1): ball_wheel_link child(2): base_camera_link child(3): imu child(4): base_laser_link child(5): left_wheel_link child(6): right_wheel_link
也没有问题,实在不知道问题出在哪里
-
@leolanqin 在 从ros1平台迁移到ros2平台,然后将机器人模型导入gazebo时失败,gazebo无响应 中说:
[gzserver-2] Error: Non-unique names detected in <link name='link'>
[gzserver-2] <collision name='surface'>
[gzserver-2] <pose>0 0 1 0 -0 0</pose>
[gzserver-2] <geometry>
[gzserver-2] <box>
[gzserver-2] <size>1.5 0.8 0.03</size>
[gzserver-2] </box>
[gzserver-2] </geometry>
[gzserver-2] <surface>
[gzserver-2] <friction>
[gzserver-2] <ode>world 里面有没有呢,试着加载一个空的环境