小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
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>' -
@2352947187 提供下上下文操作
-
@2352947187 我也遇到了同样的问题,请问你解决了吗
-
@小鱼 我也在“6.4.2在gazebo中加载机器人模型”遇到了和贴主一样的问题
gazebo_sim.launch.py代码如下:import launch import launch.launch_description_sources import launch_ros from ament_index_python.packages import get_package_share_directory import os from launch.launch_description_sources import PythonLaunchDescriptionSource import launch_ros.parameter_descriptions def generate_launch_description(): #获取功能包的share路径 package_path = get_package_share_directory('fishbot_description') #获取默认的xacro路径 default_xacro_path = os.path.join(package_path, 'urdf', 'fishbot/fishbot.urdf.xacro') #获取rviz配置文件路径(用于打开rviz软件) #default_rviz_config_path = os.path.join(package_path, 'config', 'display_robot_model.rviz') #获取gazebo世界模型文件路径(用于打开gazebo软件) default_gazebo_world_path = os.path.join(package_path, 'world', 'custom_room.world') #声明xacro目录参数,方便修改 action_declare_arg_mode_path = launch.actions.DeclareLaunchArgument( name = 'model', default_value=str(default_xacro_path), description='加载的模型文件路径' ) #通过文件路径,获取内容,并转换成参数值对象,以供传入 robot_state_publisher,model是路径参数,相当于在终端输入了xacro + 文件路径 substitutions_command_result = launch.substitutions.Command(['xacro ', launch.substitutions.LaunchConfiguration('model')]) #转换成launch参数值对象 robot_descriptioin_value = launch_ros.parameter_descriptions.ParameterValue(substitutions_command_result, value_type=str) action_robot_state_publisher = launch_ros.actions.Node( package='robot_state_publisher', executable='robot_state_publisher', parameters=[{'robot_description':robot_descriptioin_value}] ) action_launch_gazebo = launch.actions.IncludeLaunchDescription( launch.launch_description_sources.PythonLaunchDescriptionSource([get_package_share_directory('gazebo_ros'), '/launch', '/gazebo.launch.py']), launch_arguments=[('world', default_gazebo_world_path),('verbose','true')] ) # action_rviz_node = launch_ros.actions.Node( # package='rviz2', # executable='rviz2', # arguments=['-d' ,default_rviz_config_path] # ) return launch.LaunchDescription([ action_declare_arg_mode_path, action_robot_state_publisher, action_launch_gazebo, # action_rviz_node, ])
终端操作如下:
daisy@daisy-VirtualBox:~/chapt6$ cd chapt6_ws/ daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ source install/setup.bash daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ source install/setup.bash daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ colcon build Starting >>> fishbot_description Finished <<< fishbot_description [1.02s] Summary: 1 package finished [1.74s] 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-16-13-30-042688-daisy-VirtualBox-3880 [INFO] [launch]: Default logging verbosity is set to INFO [ERROR] [launch]: Caught exception in launch (see debug for traceback): Caught multiple exceptions when trying to load file of format [py]: - AttributeError: module 'launch' has no attribute 'actioons' - InvalidFrontendLaunchFileError: The launch file may have a syntax error, or its format is unknown daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ colcon build Starting >>> fishbot_description Finished <<< fishbot_description [0.30s] Summary: 1 package finished [0.62s] 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-16-13-57-292398-daisy-VirtualBox-3993 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [robot_state_publisher-1]: process started with pid [4010] [INFO] [gzserver-2]: process started with pid [4012] [INFO] [gzclient-3]: process started with pid [4014] [robot_state_publisher-1] [INFO] [1731485638.900938666] [robot_state_publisher]: got segment back_caster_link [robot_state_publisher-1] [INFO] [1731485638.901109575] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-1] [INFO] [1731485638.901121696] [robot_state_publisher]: got segment base_link [robot_state_publisher-1] [INFO] [1731485638.901125974] [robot_state_publisher]: got segment camera_link [robot_state_publisher-1] [INFO] [1731485638.901129892] [robot_state_publisher]: got segment front_caster_link [robot_state_publisher-1] [INFO] [1731485638.901133654] [robot_state_publisher]: got segment imu_link [robot_state_publisher-1] [INFO] [1731485638.901137125] [robot_state_publisher]: got segment laser_cylinder_link [robot_state_publisher-1] [INFO] [1731485638.901140746] [robot_state_publisher]: got segment laser_link [robot_state_publisher-1] [INFO] [1731485638.901144368] [robot_state_publisher]: got segment left_wheel_link [robot_state_publisher-1] [INFO] [1731485638.901147913] [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: 172.20.10.12 [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: 172.20.10.12 [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. [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] 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 4014, exit code -6, cmd 'gzclient --verbose']. [gzclient-3] ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT) [robot_state_publisher-1] [INFO] [1731485758.346198941] [rclcpp]: signal_handler(signum=2) [INFO] [robot_state_publisher-1]: process has finished cleanly [pid 4010] [INFO] [gzserver-2]: process has finished cleanly [pid 4012] [gzserver-2] [gzserver-2] daisy@daisy-VirtualBox:~/chapt6/chapt6_ws$ source install/setup.bash 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-16-16-07-344853-daisy-VirtualBox-4390 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [robot_state_publisher-1]: process started with pid [4392] [INFO] [gzserver-2]: process started with pid [4394] [INFO] [gzclient-3]: process started with pid [4396] [robot_state_publisher-1] [INFO] [1731485768.000059857] [robot_state_publisher]: got segment back_caster_link [robot_state_publisher-1] [INFO] [1731485768.000151923] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-1] [INFO] [1731485768.000158276] [robot_state_publisher]: got segment base_link [robot_state_publisher-1] [INFO] [1731485768.000162215] [robot_state_publisher]: got segment camera_link [robot_state_publisher-1] [INFO] [1731485768.000165779] [robot_state_publisher]: got segment front_caster_link [robot_state_publisher-1] [INFO] [1731485768.000169217] [robot_state_publisher]: got segment imu_link [robot_state_publisher-1] [INFO] [1731485768.000172550] [robot_state_publisher]: got segment laser_cylinder_link [robot_state_publisher-1] [INFO] [1731485768.000175961] [robot_state_publisher]: got segment laser_link [robot_state_publisher-1] [INFO] [1731485768.000179341] [robot_state_publisher]: got segment left_wheel_link [robot_state_publisher-1] [INFO] [1731485768.000182855] [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: 172.20.10.12 [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: 172.20.10.12 [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. [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] 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 4396, exit code -6, cmd 'gzclient --verbose']. [gzclient-3] ^C[WARNING] [launch]: user interrupted with ctrl-c (SIGINT) [robot_state_publisher-1] [INFO] [1731486372.159001383] [rclcpp]: signal_handler(signum=2) [INFO] [robot_state_publisher-1]: process has finished cleanly [pid 4392] [INFO] [gzserver-2]: process has finished cleanly [pid 4394] [gzserver-2] [gzserver-2]
-
@唔希迪希 我已解决!
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.