6.4.2在gazebo中加载机器人模型
-
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 PythonLaunchDescriptionSourcedef 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>' -
@唔希迪希 我已解决!
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.
-
@2352947187 提供下上下文操作
-
此回复已被删除! -
此回复已被删除! -
@唔希迪希 我已解决!
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.
-
@唔希迪希 感谢老哥,我也根据你得方法解决了
-
@869561879 在 6.4.2在gazebo中加载机器人模型 中说:
@唔希迪希 感谢老哥,我也根据你得方法解决了
@唔希迪希 在 6.4.2在gazebo中加载机器人模型 中说:
@唔希迪希 我已解决!
@唔希迪希 按照你的方法解决了。
-