运行gazebo_sim.launch.py文件打不开gazebo
-
ubuntu版本22.04. 用的是<<ROS2机器人开发>>配套的源码
终端信息
lqh@lqh-virtual-machine:~/ros2bookcode-master/chapt6/chapt6_ws$ ros2 launch fishbot_description gazebo_sim.launch.py [INFO] [launch]: All log files can be found below /home/lqh/.ros/log/2024-12-27-16-50-13-067270-lqh-virtual-machine-23566 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [robot_state_publisher-1]: process started with pid [23580] [INFO] [gzserver-2]: process started with pid [23582] [INFO] [gzclient-3]: process started with pid [23584] [INFO] [spawn_entity.py-4]: process started with pid [23586] [robot_state_publisher-1] [INFO] [1735289416.609378691] [robot_state_publisher]: got segment back_caster_link [robot_state_publisher-1] [INFO] [1735289416.609762074] [robot_state_publisher]: got segment base_footprint [robot_state_publisher-1] [INFO] [1735289416.609789459] [robot_state_publisher]: got segment base_link [robot_state_publisher-1] [INFO] [1735289416.609807065] [robot_state_publisher]: got segment camera_link [robot_state_publisher-1] [INFO] [1735289416.609821652] [robot_state_publisher]: got segment camera_optical_link [robot_state_publisher-1] [INFO] [1735289416.609836778] [robot_state_publisher]: got segment front_caster_link [robot_state_publisher-1] [INFO] [1735289416.609851925] [robot_state_publisher]: got segment imu_link [robot_state_publisher-1] [INFO] [1735289416.610069414] [robot_state_publisher]: got segment laser_cylinder_link [robot_state_publisher-1] [INFO] [1735289416.610103868] [robot_state_publisher]: got segment laser_link [robot_state_publisher-1] [INFO] [1735289416.610119831] [robot_state_publisher]: got segment left_wheel_link [robot_state_publisher-1] [INFO] [1735289416.610135977] [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] [spawn_entity.py-4] [INFO] [1735289418.868044069] [spawn_entity]: Spawn Entity started [spawn_entity.py-4] [INFO] [1735289418.880349399] [spawn_entity]: Loading entity published on topic /robot_description [spawn_entity.py-4] /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/qos.py:307: UserWarning: DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL is deprecated. Use DurabilityPolicy.TRANSIENT_LOCAL instead. [spawn_entity.py-4] warnings.warn( [spawn_entity.py-4] [INFO] [1735289418.931277538] [spawn_entity]: Waiting for entity xml on /robot_description [spawn_entity.py-4] [INFO] [1735289418.951562022] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30 [spawn_entity.py-4] [INFO] [1735289418.965709454] [spawn_entity]: Waiting for service /spawn_entity [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.204.128 [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.204.128 [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 "" [spawn_entity.py-4] [INFO] [1735289423.308325407] [spawn_entity]: Calling service /spawn_entity [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/lqh/ros2bookcode-master/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world] [gzserver-2] [Err] [RenderEngine.cc:197] Failed to initialize scene [gzserver-2] gzserver: /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::Scene; typename boost::detail::sp_member_access<T>::type = gazebo::rendering::Scene*]: Assertion `px != 0' failed. [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] [gzserver-2]: process has died [pid 23582, exit code -6, cmd 'gzserver /home/lqh/ros2bookcode-master/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world --verbose -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so']. [gzserver-2] [ERROR] [gzclient-3]: process has died [pid 23584, exit code -6, cmd 'gzclient --verbose']. [gzclient-3]
-
从您提供的终端信息来看,您遇到的问题主要涉及以下几个方面:
-
Shader 库找不到:
[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?
这个错误提示表明 Gazebo 无法找到其所需的 shader 库,这通常是因为
GAZEBO_RESOURCE_PATH
环境变量没有正确设置。您需要确保已经正确运行了 Gazebo 的环境设置脚本。 -
Qt 平台插件找不到:
[Wrn] [GuiIface.cc:120] Could not find the Qt platform plugin "wayland" in ""
这个警告表明 Gazebo 无法找到 Qt 的 Wayland 平台插件。如果您使用的是非 Wayland 环境(例如标准的 X11),这可能不是主要问题,但如果是 Wayland 环境,您可能需要确保 Qt 的插件路径正确。
-
场景初始化失败:
[Err] [RenderEngine.cc:197] Failed to initialize scene
这通常与图形驱动或 OpenGL 相关的问题有关。确保您的系统具有支持 OpenGL 的图形驱动,并且这些驱动是最新的。
-
Gazebo 服务器和客户端崩溃:
[gzserver-2] gzserver: /usr/include/boost/smart_ptr/shared_ptr.hpp:728: Assertion `px != 0' failed. [gzclient-3] gzclient: /usr/include/boost/smart_ptr/shared_ptr.hpp:728: 断言 "px != 0" 失败。
这些错误表明 Gazebo 的内部组件(可能是场景或相机对象)在尝试访问一个未初始化的对象时发生了断言失败。
解决步骤:
-
确保 Gazebo 环境变量设置正确:
打开一个新的终端,运行以下命令来设置 Gazebo 的环境变量:source /opt/ros/humble/setup.bash source /opt/ros/humble/local/setup.bash source /path/to/gazebo/setup.bash # 替换为实际的 Gazebo 安装路径
-
检查图形驱动:
确保您的系统安装了正确的图形驱动,并且支持 OpenGL。如果您使用的是虚拟机,可能需要确保虚拟机配置允许使用硬件加速。 -
重新运行 Gazebo:
在设置了正确的环境变量后,尝试再次运行您的 launch 文件:ros2 launch fishbot_description gazebo_sim.launch.py
-
检查依赖和插件:
如果您使用的是 Wayland,确保 Qt 的 Wayland 插件可用。如果是 X11,确保没有其他与图形相关的冲突。 -
查看日志文件:
如果问题仍然存在,查看 Gazebo 的日志文件,这可能会提供更多关于问题的详细信息。日志文件通常位于~/.ros/log/
目录下。
通过上述步骤,您应该能够诊断并解决启动 Gazebo 时遇到的问题。如果问题仍然存在,可能需要更详细地检查您的系统配置或寻求社区的帮助。
以上为生成回答,仅供参考~
-
-
@lqh3256948861 在 运行gazebo_sim.launch.py文件打不开gazebo 中说:
[gzserver-2] gzserver: /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::Scene; typename boost::detail::sp_member_access<T>::type = gazebo::rendering::Scene*]: Assertion `px != 0' failed.
[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] [gzserver-2]: process has died [pid 23582, exit code -6, cmd 'gzserver /home/lqh/ros2bookcode-master/chapt6/chapt6_ws/install/fishbot_description/share/fishbot_description/world/custom_room.world --verbose -slibgazebo_ros_init.so -slibgazebo_ros_factory.so -slibgazebo_ros_force_system.so'].
[gzserver-2]
[ERROR] [gzclient-3]: process has died [pid 23584, exit code -6, cmd 'gzclient --verbose'].
[gzclient-3]换一个空的环境试试,另外就是你有按照前面的步骤安装依赖吗
-
@小鱼 之前是更着foxy版本的文档学的,然后更新了Ubuntu换成humble版本学了,所以我直接从仿真导航开始了