鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    6.4.2在gazebo中加载机器人模型

    已定时 已固定 已锁定 已移动 已解决
    ROS2机器人开发:从入门到实践
    加载gazebo显示异常 launch
    5
    7
    988
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 2
      2352947187
      最后由 编辑

      gazebo_sim.launch.py文件内容:
      import launch
      import launch_ros
      from ament_index_python.packages import get_package_share_directory
      from launch.launch_description_sources import PythonLaunchDescriptionSource

      def generate_launch_description():
      # 获取默认路径
      # robot_name_in_model = "fishbot"
      urdf_tutorial_path = get_package_share_directory('fishbot_description')
      default_model_path = urdf_tutorial_path + '/urdf/fishbot/fishbot.urdf.xacro'
      default_world_path = urdf_tutorial_path + '/world/custom_room.world'
      # 为 Launch 声明参数
      action_declare_arg_mode_path = launch.actions.DeclareLaunchArgument(
      name='model', default_value=str(default_model_path),
      description='URDF 的绝对路径')
      # 获取文件内容生成新的参数
      robot_description = launch_ros.parameter_descriptions.ParameterValue(
      launch.substitutions.Command(
      ['xacro ', launch.substitutions.LaunchConfiguration('model')]),
      value_type=str)

      robot_state_publisher_node = launch_ros.actions.Node(
          package='robot_state_publisher',
          executable='robot_state_publisher',
          parameters=[{'robot_description': robot_description}]
      )
      
      # 通过 IncludeLaunchDescription 包含另外一个 launch 文件
      launch_gazebo = launch.actions.IncludeLaunchDescription(
          PythonLaunchDescriptionSource([get_package_share_directory(
              'gazebo_ros'), '/launch', '/gazebo.launch.py']),
        	# 传递参数
          launch_arguments=[('world', default_world_path),('verbose','true')]
      )
      return launch.LaunchDescription([
          action_declare_arg_mode_path,
          robot_state_publisher_node,
          launch_gazebo,
      ])
      

      终端输入:ros2 launch fishbot_description gazebo_sim.launch.py
      显示:[INFO] [launch]: All log files can be found below /home/wang/.ros/log/2024-10-23-17-35-42-233913-wang-virtual-machine-9402
      [INFO] [launch]: Default logging verbosity is set to INFO
      [INFO] [robot_state_publisher-1]: process started with pid [9438]
      [INFO] [gzserver-2]: process started with pid [9440]
      [INFO] [gzclient-3]: process started with pid [9443]
      [robot_state_publisher-1] [INFO] [1729676145.696358758] [robot_state_publisher]: got segment back_caster_link
      [robot_state_publisher-1] [INFO] [1729676145.696697463] [robot_state_publisher]: got segment base_footprint
      [robot_state_publisher-1] [INFO] [1729676145.696729168] [robot_state_publisher]: got segment base_link
      [robot_state_publisher-1] [INFO] [1729676145.696745268] [robot_state_publisher]: got segment camera_link
      [robot_state_publisher-1] [INFO] [1729676145.696760659] [robot_state_publisher]: got segment camera_optical_link
      [robot_state_publisher-1] [INFO] [1729676145.696775769] [robot_state_publisher]: got segment front_caster_link
      [robot_state_publisher-1] [INFO] [1729676145.696790216] [robot_state_publisher]: got segment imu_link
      [robot_state_publisher-1] [INFO] [1729676145.696804432] [robot_state_publisher]: got segment laser_cylinder_link
      [robot_state_publisher-1] [INFO] [1729676145.696819304] [robot_state_publisher]: got segment laser_link
      [robot_state_publisher-1] [INFO] [1729676145.696833385] [robot_state_publisher]: got segment left_wheel_link
      [robot_state_publisher-1] [INFO] [1729676145.696848606] [robot_state_publisher]: got segment right_wheel_link
      [gzclient-3] Gazebo multi-robot simulator, version 11.10.2
      [gzclient-3] Copyright (C) 2012 Open Source Robotics Foundation.
      [gzclient-3] Released under the Apache 2 License.
      [gzclient-3] http://gazebosim.org
      [gzclient-3]
      [gzserver-2] Gazebo multi-robot simulator, version 11.10.2
      [gzserver-2] Copyright (C) 2012 Open Source Robotics Foundation.
      [gzserver-2] Released under the Apache 2 License.
      [gzserver-2] http://gazebosim.org
      [gzserver-2]
      [gzserver-2] [Msg] Waiting for master.
      [gzserver-2] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
      [gzserver-2] [Msg] Publicized address: 192.168.28.131
      [gzserver-2] [Err] [RTShaderSystem.cc:480] Unable to find shader lib. Shader generating will fail. Your GAZEBO_RESOURCE_PATH is probably improperly set. Have you sourced <prefix>/share/gazebo/setup.bash?
      [gzclient-3] [Msg] Waiting for master.
      [gzclient-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
      [gzclient-3] [Msg] Publicized address: 192.168.28.131
      [gzclient-3] [Err] [RTShaderSystem.cc:480] Unable to find shader lib. Shader generating will fail. Your GAZEBO_RESOURCE_PATH is probably improperly set. Have you sourced <prefix>/share/gazebo/setup.bash?
      [gzclient-3] [Wrn] [GuiIface.cc:120] Could not find the Qt platform plugin "wayland" in ""
      [gzclient-3] [Err] [RenderEngine.cc:197] Failed to initialize scene
      [gzclient-3] [Err] [GLWidget.cc:177] GLWidget could not create a scene. This will likely result in a blank screen.
      [gzclient-3] gzclient: /usr/include/boost/smart_ptr/shared_ptr.hpp:728: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::rendering::Camera; typename boost::detail::sp_member_access<T>::type = gazebo::rendering::Camera*]: 断言 "px != 0" 失败。
      [ERROR] [gzclient-3]: process has died [pid 9443, exit code -6, cmd 'gzclient --verbose'].
      [gzclient-3]
      ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT)
      [robot_state_publisher-1] [INFO] [1729676286.561609333] [rclcpp]: signal_handler(signum=2)
      [INFO] [robot_state_publisher-1]: process has finished cleanly [pid 9438]
      [gzserver-2] [Msg] Loading world file [/home/wang/desktop/ros2bookcode/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world]
      终端输入: ros2 launch fishbot_description gazebo_sim.launch.py --debug
      显示:
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.IncludeLaunchDescription'
      [INFO] [launch]: All log files can be found below /home/wang/.ros/log/2024-10-23-17-38-13-922416-wang-virtual-machine-9696
      [INFO] [launch]: Default logging verbosity is set to DEBUG
      [DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription object at 0x757dcefa0d00>'
      [DEBUG] [launch]: processing event: '<launch.events.include_launch_description.IncludeLaunchDescription object at 0x757dcefa0d00>' ✓ '<launch.event_handlers.on_include_launch_description.OnIncludeLaunchDescription object at 0x757dcf144100>'
      [DEBUG] [launch.launch_description_source]: Traceback (most recent call last):
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/launch_description_source.py", line 68, in try_get_launch_description_without_context
      perform_substitutions(context, self.__location)
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
      return ''.join([context.perform_substitution(sub) for sub in subs])
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
      return ''.join([context.perform_substitution(sub) for sub in subs])
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/launch_context.py", line 240, in perform_substitution
      return substitution.perform(self)
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/substitutions/this_launch_file_dir.py", line 56, in perform
      raise SubstitutionFailure(
      launch.substitutions.substitution_failure.SubstitutionFailure: ThisLaunchFileDir used outside of a launch file (in a script)

      [DEBUG] [launch.launch_description_source]: Failed to load the launch file without a context: ThisLaunchFileDir used outside of a launch file (in a script)
      [DEBUG] [launch.launch_description_source]: Traceback (most recent call last):
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/launch_description_source.py", line 68, in try_get_launch_description_without_context
      perform_substitutions(context, self.__location)
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
      return ''.join([context.perform_substitution(sub) for sub in subs])
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
      return ''.join([context.perform_substitution(sub) for sub in subs])
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/launch_context.py", line 240, in perform_substitution
      return substitution.perform(self)
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/substitutions/this_launch_file_dir.py", line 56, in perform
      raise SubstitutionFailure(
      launch.substitutions.substitution_failure.SubstitutionFailure: ThisLaunchFileDir used outside of a launch file (in a script)

      [DEBUG] [launch.launch_description_source]: Failed to load the launch file without a context: ThisLaunchFileDir used outside of a launch file (in a script)
      [DEBUG] [launch.launch_description_source]: Traceback (most recent call last):
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/launch_description_source.py", line 68, in try_get_launch_description_without_context
      perform_substitutions(context, self.__location)
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
      return ''.join([context.perform_substitution(sub) for sub in subs])
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
      return ''.join([context.perform_substitution(sub) for sub in subs])
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/launch_context.py", line 240, in perform_substitution
      return substitution.perform(self)
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/substitutions/this_launch_file_dir.py", line 56, in perform
      raise SubstitutionFailure(
      launch.substitutions.substitution_failure.SubstitutionFailure: ThisLaunchFileDir used outside of a launch file (in a script)

      [DEBUG] [launch.launch_description_source]: Failed to load the launch file without a context: ThisLaunchFileDir used outside of a launch file (in a script)
      [DEBUG] [launch.launch_description_source]: Traceback (most recent call last):
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/launch_description_source.py", line 68, in try_get_launch_description_without_context
      perform_substitutions(context, self.__location)
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
      return ''.join([context.perform_substitution(sub) for sub in subs])
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
      return ''.join([context.perform_substitution(sub) for sub in subs])
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/launch_context.py", line 240, in perform_substitution
      return substitution.perform(self)
      File "/opt/ros/humble/lib/python3.10/site-packages/launch/substitutions/this_launch_file_dir.py", line 56, in perform
      raise SubstitutionFailure(
      launch.substitutions.substitution_failure.SubstitutionFailure: ThisLaunchFileDir used outside of a launch file (in a script)

      [DEBUG] [launch.launch_description_source]: Failed to load the launch file without a context: ThisLaunchFileDir used outside of a launch file (in a script)
      Executing <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/humble/lib/python3.10/site-packages/launch/launch_service.py:228> result=None created at /opt/ros/humble/lib/python3.10/site-packages/launch/launch_service.py:318> took 2.764 seconds
      [INFO] [robot_state_publisher-1]: process started with pid [9715]
      [DEBUG] [launch.launch_context]: emitting event: 'launch.events.process.ProcessStarted'
      [INFO] [gzserver-2]: process started with pid [9717]
      [DEBUG] [launch.launch_context]: emitting event: 'launch.events.process.ProcessStarted'
      [INFO] [gzclient-3]: process started with pid [9719]
      [DEBUG] [launch.launch_context]: emitting event: 'launch.events.process.ProcessStarted'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_started.ProcessStarted object at 0x757dcd9da920>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_started.ProcessStarted object at 0x757dcd4e1c90>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_started.ProcessStarted object at 0x757dcd4e3160>'
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStderr'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd9d9900>'
      [robot_state_publisher-1] [INFO] [1729676296.921460176] [robot_state_publisher]: got segment back_caster_link
      [robot_state_publisher-1] [INFO] [1729676296.921841094] [robot_state_publisher]: got segment base_footprint
      [robot_state_publisher-1] [INFO] [1729676296.921878362] [robot_state_publisher]: got segment base_link
      [robot_state_publisher-1] [INFO] [1729676296.921897078] [robot_state_publisher]: got segment camera_link
      [robot_state_publisher-1] [INFO] [1729676296.921913011] [robot_state_publisher]: got segment camera_optical_link
      [robot_state_publisher-1] [INFO] [1729676296.921929261] [robot_state_publisher]: got segment front_caster_link
      [robot_state_publisher-1] [INFO] [1729676296.921944901] [robot_state_publisher]: got segment imu_link
      [robot_state_publisher-1] [INFO] [1729676296.921959646] [robot_state_publisher]: got segment laser_cylinder_link
      [robot_state_publisher-1] [INFO] [1729676296.921974807] [robot_state_publisher]: got segment laser_link
      [robot_state_publisher-1] [INFO] [1729676296.921990079] [robot_state_publisher]: got segment left_wheel_link
      [robot_state_publisher-1] [INFO] [1729676296.922004943] [robot_state_publisher]: got segment right_wheel_link
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStderr'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4e2a40>'
      [gzclient-3] Gazebo multi-robot simulator, version 11.10.2
      [gzclient-3] Copyright (C) 2012 Open Source Robotics Foundation.
      [gzclient-3] Released under the Apache 2 License.
      [gzclient-3] http://gazebosim.org
      [gzclient-3]
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStderr'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4fb7f0>'
      [gzserver-2] Gazebo multi-robot simulator, version 11.10.2
      [gzserver-2] Copyright (C) 2012 Open Source Robotics Foundation.
      [gzserver-2] Released under the Apache 2 License.
      [gzserver-2] http://gazebosim.org
      [gzserver-2]
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStdout'
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStderr'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stdout.ProcessStdout object at 0x757dcd9da920>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stdout.ProcessStdout object at 0x757dcd9da920>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4fb7f0>'
      [gzserver-2] [Msg] Waiting for master.
      [gzserver-2] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
      [gzserver-2] [Msg] Publicized address: 192.168.28.131
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd4e18a0>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd4e18a0>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4fb7f0>'
      [gzserver-2] [Err] [RTShaderSystem.cc:480] Unable to find shader lib. Shader generating will fail. Your GAZEBO_RESOURCE_PATH is probably improperly set. Have you sourced <prefix>/share/gazebo/setup.bash?
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStdout'
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStderr'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stdout.ProcessStdout object at 0x757dcdabfa30>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stdout.ProcessStdout object at 0x757dcdabfa30>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4e2a40>'
      [gzclient-3] [Msg] Waiting for master.
      [gzclient-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
      [gzclient-3] [Msg] Publicized address: 192.168.28.131
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd4e18a0>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd4e18a0>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4e2a40>'
      [gzclient-3] [Err] [RTShaderSystem.cc:480] Unable to find shader lib. Shader generating will fail. Your GAZEBO_RESOURCE_PATH is probably improperly set. Have you sourced <prefix>/share/gazebo/setup.bash?
      [gzclient-3] [Wrn] [GuiIface.cc:120] Could not find the Qt platform plugin "wayland" in ""
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStderr'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4e2a40>'
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStderr'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcd9da920>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4e2a40>'
      [gzclient-3] [Err] [RenderEngine.cc:197] Failed to initialize scene
      [gzclient-3] [Err] [GLWidget.cc:177] GLWidget could not create a scene. This will likely result in a blank screen.
      [DEBUG] [launch.launch_context]: emitting event synchronously: 'launch.events.process.ProcessStderr'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcdabf6d0>'
      [DEBUG] [launch]: processing event: '<launch.events.process.process_stderr.ProcessStderr object at 0x757dcdabf6d0>' ✓ '<launch.event_handlers.on_process_io.OnProcessIO object at 0x757dcd4e2a40>'

      小鱼小 唔 2 条回复 最后回复 回复 引用 0
      • 唔
        唔希迪希 @唔希迪希
        最后由 编辑

        @唔希迪希 我已解决!
        solution:
        查看自己的gazebo是哪个版本的

        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ ls /usr/share | grep gazebo
        gazebo
        gazebo-11
        

        然后修改环境变量

        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ export GAZEBO_RESOURCE_PATH=$GAZEBO_RESOURCE_PATH:/usr/share/gazebo-11
        

        查看一下有没有修改成功

        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ printenv | grep  GAZEBO_RESOURCE_PATH
        GAZEBO_RESOURCE_PATH=:/usr/share/gazebo-11
        

        再运行

        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ ros2 launch fishbot_description gazebo_sim.launch.py 
        

        成功在gazebo中打开模型并且无报错!

        完整过程:

        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ ls /usr/share | grep gazebo
        gazebo
        gazebo-11
        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ printenv | grep  GAZEBO_RESOURCE_PATH
        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ export GAZEBO_RESOURCE_PATH=$GAZEBO_RESOURCE_PATH:/usr/share/gazebo-11
        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ printenv | grep  GAZEBO_RESOURCE_PATH
        GAZEBO_RESOURCE_PATH=:/usr/share/gazebo-11
        daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ ros2 launch fishbot_description gazebo_sim.launch.py 
        [INFO] [launch]: All log files can be found below /home/daisy/.ros/log/2024-11-13-17-05-21-173897-daisy-VirtualBox-5684
        [INFO] [launch]: Default logging verbosity is set to INFO
        [INFO] [robot_state_publisher-1]: process started with pid [5686]
        [INFO] [gzserver-2]: process started with pid [5688]
        [INFO] [gzclient-3]: process started with pid [5690]
        [robot_state_publisher-1] [INFO] [1731488721.944877604] [robot_state_publisher]: got segment back_caster_link
        [robot_state_publisher-1] [INFO] [1731488721.947460442] [robot_state_publisher]: got segment base_footprint
        [robot_state_publisher-1] [INFO] [1731488721.947480484] [robot_state_publisher]: got segment base_link
        [robot_state_publisher-1] [INFO] [1731488721.947484598] [robot_state_publisher]: got segment camera_link
        [robot_state_publisher-1] [INFO] [1731488721.947488090] [robot_state_publisher]: got segment front_caster_link
        [robot_state_publisher-1] [INFO] [1731488721.947491439] [robot_state_publisher]: got segment imu_link
        [robot_state_publisher-1] [INFO] [1731488721.947494741] [robot_state_publisher]: got segment laser_cylinder_link
        [robot_state_publisher-1] [INFO] [1731488721.947498114] [robot_state_publisher]: got segment laser_link
        [robot_state_publisher-1] [INFO] [1731488721.947501197] [robot_state_publisher]: got segment left_wheel_link
        [robot_state_publisher-1] [INFO] [1731488721.947504493] [robot_state_publisher]: got segment right_wheel_link
        [gzserver-2] Gazebo multi-robot simulator, version 11.10.2
        [gzserver-2] Copyright (C) 2012 Open Source Robotics Foundation.
        [gzserver-2] Released under the Apache 2 License.
        [gzserver-2] http://gazebosim.org
        [gzserver-2] 
        [gzclient-3] Gazebo multi-robot simulator, version 11.10.2
        [gzclient-3] Copyright (C) 2012 Open Source Robotics Foundation.
        [gzclient-3] Released under the Apache 2 License.
        [gzclient-3] http://gazebosim.org
        [gzclient-3] 
        [gzserver-2] [Msg] Waiting for master.
        [gzserver-2] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
        [gzserver-2] [Msg] Publicized address: 172.20.10.12
        [gzserver-2] [Msg] Loading world file [/home/daisy/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world]
        [gzserver-2] [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/physics/contacts, deleting message. This warning is printed only once.
        [gzclient-3] [Msg] Waiting for master.
        [gzclient-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
        [gzclient-3] [Msg] Publicized address: 172.20.10.12
        [gzclient-3] [Wrn] [GuiIface.cc:120] Could not find the Qt platform plugin "wayland" in ""
        [gzclient-3] [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call
        [gzclient-3] context mismatch in svga_surface_destroy
        [gzclient-3] context mismatch in svga_surface_destroy
        [gzclient-3] [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/user_camera/pose, deleting message. This warning is printed only once.
        
        
        8 1 条回复 最后回复 回复 引用 0
        • 小鱼小
          小鱼 技术大佬 @2352947187
          最后由 编辑

          @2352947187 提供下上下文操作

          新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

          唔 1 条回复 最后回复 回复 引用 0
          • 唔
            唔希迪希 @2352947187
            最后由 编辑

            此回复已被删除!
            唔 1 条回复 最后回复 回复 引用 0
            • 唔
              唔希迪希 @小鱼
              最后由 编辑

              此回复已被删除!
              1 条回复 最后回复 回复 引用 0
              • 唔
                唔希迪希 @唔希迪希
                最后由 编辑

                @唔希迪希 我已解决!
                solution:
                查看自己的gazebo是哪个版本的

                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ ls /usr/share | grep gazebo
                gazebo
                gazebo-11
                

                然后修改环境变量

                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ export GAZEBO_RESOURCE_PATH=$GAZEBO_RESOURCE_PATH:/usr/share/gazebo-11
                

                查看一下有没有修改成功

                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ printenv | grep  GAZEBO_RESOURCE_PATH
                GAZEBO_RESOURCE_PATH=:/usr/share/gazebo-11
                

                再运行

                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ ros2 launch fishbot_description gazebo_sim.launch.py 
                

                成功在gazebo中打开模型并且无报错!

                完整过程:

                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ ls /usr/share | grep gazebo
                gazebo
                gazebo-11
                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ printenv | grep  GAZEBO_RESOURCE_PATH
                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ export GAZEBO_RESOURCE_PATH=$GAZEBO_RESOURCE_PATH:/usr/share/gazebo-11
                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ printenv | grep  GAZEBO_RESOURCE_PATH
                GAZEBO_RESOURCE_PATH=:/usr/share/gazebo-11
                daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ ros2 launch fishbot_description gazebo_sim.launch.py 
                [INFO] [launch]: All log files can be found below /home/daisy/.ros/log/2024-11-13-17-05-21-173897-daisy-VirtualBox-5684
                [INFO] [launch]: Default logging verbosity is set to INFO
                [INFO] [robot_state_publisher-1]: process started with pid [5686]
                [INFO] [gzserver-2]: process started with pid [5688]
                [INFO] [gzclient-3]: process started with pid [5690]
                [robot_state_publisher-1] [INFO] [1731488721.944877604] [robot_state_publisher]: got segment back_caster_link
                [robot_state_publisher-1] [INFO] [1731488721.947460442] [robot_state_publisher]: got segment base_footprint
                [robot_state_publisher-1] [INFO] [1731488721.947480484] [robot_state_publisher]: got segment base_link
                [robot_state_publisher-1] [INFO] [1731488721.947484598] [robot_state_publisher]: got segment camera_link
                [robot_state_publisher-1] [INFO] [1731488721.947488090] [robot_state_publisher]: got segment front_caster_link
                [robot_state_publisher-1] [INFO] [1731488721.947491439] [robot_state_publisher]: got segment imu_link
                [robot_state_publisher-1] [INFO] [1731488721.947494741] [robot_state_publisher]: got segment laser_cylinder_link
                [robot_state_publisher-1] [INFO] [1731488721.947498114] [robot_state_publisher]: got segment laser_link
                [robot_state_publisher-1] [INFO] [1731488721.947501197] [robot_state_publisher]: got segment left_wheel_link
                [robot_state_publisher-1] [INFO] [1731488721.947504493] [robot_state_publisher]: got segment right_wheel_link
                [gzserver-2] Gazebo multi-robot simulator, version 11.10.2
                [gzserver-2] Copyright (C) 2012 Open Source Robotics Foundation.
                [gzserver-2] Released under the Apache 2 License.
                [gzserver-2] http://gazebosim.org
                [gzserver-2] 
                [gzclient-3] Gazebo multi-robot simulator, version 11.10.2
                [gzclient-3] Copyright (C) 2012 Open Source Robotics Foundation.
                [gzclient-3] Released under the Apache 2 License.
                [gzclient-3] http://gazebosim.org
                [gzclient-3] 
                [gzserver-2] [Msg] Waiting for master.
                [gzserver-2] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
                [gzserver-2] [Msg] Publicized address: 172.20.10.12
                [gzserver-2] [Msg] Loading world file [/home/daisy/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world]
                [gzserver-2] [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/physics/contacts, deleting message. This warning is printed only once.
                [gzclient-3] [Msg] Waiting for master.
                [gzclient-3] [Msg] Connected to gazebo master @ http://127.0.0.1:11345
                [gzclient-3] [Msg] Publicized address: 172.20.10.12
                [gzclient-3] [Wrn] [GuiIface.cc:120] Could not find the Qt platform plugin "wayland" in ""
                [gzclient-3] [Wrn] [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call
                [gzclient-3] context mismatch in svga_surface_destroy
                [gzclient-3] context mismatch in svga_surface_destroy
                [gzclient-3] [Wrn] [Publisher.cc:135] Queue limit reached for topic /gazebo/default/user_camera/pose, deleting message. This warning is printed only once.
                
                
                8 1 条回复 最后回复 回复 引用 0
                • 8
                  869561879 @唔希迪希
                  最后由 编辑

                  @唔希迪希 感谢老哥,我也根据你得方法解决了

                  D 1 条回复 最后回复 回复 引用 0
                  • D
                    devin @869561879
                    最后由 编辑

                    @869561879 在 6.4.2在gazebo中加载机器人模型 中说:

                    @唔希迪希 感谢老哥,我也根据你得方法解决了

                    @唔希迪希 在 6.4.2在gazebo中加载机器人模型 中说:

                    @唔希迪希 我已解决!

                    @唔希迪希 按照你的方法解决了。

                    1 条回复 最后回复 回复 引用 0
                    • 小鱼小 小鱼 将这个主题标记为已解决,在
                    • 第一个帖子
                      最后一个帖子
                    皖ICP备16016415号-7
                    Powered by NodeBB | 鱼香ROS