小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
用gazebo打开turtletle3下的ros2turtlebot3_house.launch.py文件一直报错
-
版本为ubantu22.04 ros2 humble
$ ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
[INFO] [launch]: All log files can be found below /home/cwh/.ros/log/2024-07-23-00-22-34-099869-cwh-11523
[INFO] [launch]: Default logging verbosity is set to INFO
urdf_file_name : turtlebot3_burger.urdf
urdf_file_name : turtlebot3_burger.urdf
[INFO] [gzserver-1]: process started with pid [11524]
[INFO] [gzclient-2]: process started with pid [11526]
[INFO] [robot_state_publisher-3]: process started with pid [11528]
[INFO] [spawn_entity.py-4]: process started with pid [11530]
[robot_state_publisher-3] [INFO] [1721665355.035643279] [robot_state_publisher]: got segment base_footprint
[robot_state_publisher-3] [INFO] [1721665355.035736197] [robot_state_publisher]: got segment base_link
[robot_state_publisher-3] [INFO] [1721665355.035750725] [robot_state_publisher]: got segment base_scan
[robot_state_publisher-3] [INFO] [1721665355.035761059] [robot_state_publisher]: got segment caster_back_link
[robot_state_publisher-3] [INFO] [1721665355.035770733] [robot_state_publisher]: got segment imu_link
[robot_state_publisher-3] [INFO] [1721665355.035780353] [robot_state_publisher]: got segment wheel_left_link
[robot_state_publisher-3] [INFO] [1721665355.035789826] [robot_state_publisher]: got segment wheel_right_link
[spawn_entity.py-4] [INFO] [1721665355.357259445] [spawn_entity]: Spawn Entity started
[spawn_entity.py-4] [INFO] [1721665355.357592744] [spawn_entity]: Loading entity XML from file /opt/ros/humble/share/turtlebot3_gazebo/models/turtlebot3_burger/model.sdf
[spawn_entity.py-4] [INFO] [1721665355.358289200] [spawn_entity]: Waiting for service /spawn_entity, timeout = 30
[spawn_entity.py-4] [INFO] [1721665355.358583433] [spawn_entity]: Waiting for service /spawn_entity
[spawn_entity.py-4] [INFO] [1721665356.114090195] [spawn_entity]: Calling service /spawn_entity
[gzserver-1] [INFO] [1721665356.332377718] [turtlebot3_imu]: <initial_orientation_as_reference> is unset, using default value of false to comply with REP 145 (world as orientation reference)
[spawn_entity.py-4] [INFO] [1721665356.429145798] [spawn_entity]: Spawn status: SpawnEntity: Successfully spawned entity [burger]
[gzserver-1] [INFO] [1721665356.545491538] [turtlebot3_diff_drive]: Wheel pair 1 separation set to [0.160000m]
[gzserver-1] [INFO] [1721665356.545535655] [turtlebot3_diff_drive]: Wheel pair 1 diameter set to [0.066000m]
[gzserver-1] [INFO] [1721665356.546384957] [turtlebot3_diff_drive]: Subscribed to [/cmd_vel]
[gzserver-1] [INFO] [1721665356.548277307] [turtlebot3_diff_drive]: Advertise odometry on [/odom]
[gzserver-1] [INFO] [1721665356.550355944] [turtlebot3_diff_drive]: Publishing odom transforms between [odom] and [base_footprint]
[gzserver-1] [INFO] [1721665356.558950057] [turtlebot3_joint_state]: Going to publish joint [wheel_left_joint]
[gzserver-1] [INFO] [1721665356.558978083] [turtlebot3_joint_state]: Going to publish joint [wheel_right_joint]
[INFO] [spawn_entity.py-4]: process has finished cleanly [pid 11530]
[gzclient-2] 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-2]: process has died [pid 11526, exit code -6, cmd 'gzclient'].尝试过重新安装gazebo和turtlebot3但是依旧报错,环境配置应该没问题,手动启动gazebo可以打开别的文件
-
从您提供的错误信息来看,问题似乎出在
gzclient
(Gazebo的图形用户界面)上。特别是这个错误:gzclient: /usr/include/boost/smart_ptr/shared_ptr.hpp:728: ... boost::shared_ptr<T>::operator->() const ...: 断言 "px != 0" 失败。
这个断言失败通常表示您尝试对一个空的
shared_ptr
(智能指针)执行了->
操作,这通常是因为指针在尝试使用之前已经被释放或者从未被正确初始化。以下是一些可能的解决步骤:
-
检查Gazebo版本:
确保您安装的Gazebo版本与ROS 2 Humble兼容。ROS 2 Humble通常与Gazebo 11或更新的版本兼容。 -
重新安装Gazebo:
如果您认为Gazebo可能已损坏,可以尝试完全卸载并重新安装Gazebo。使用您的包管理器(如apt
)进行此操作。 -
清理工作空间:
如果您使用了ROS 2的工作空间,请尝试清理并重新构建它。使用colcon build --symlink-install --packages-select ...
(指定您想要构建的包)来重新构建工作空间。 -
检查环境变量:
确保您的环境变量(如GAZEBO_MODEL_PATH
、GAZEBO_RESOURCE_PATH
等)设置正确,以便Gazebo可以找到所需的模型和插件。 -
查看日志文件:
检查Gazebo和ROS 2的日志文件以获取更多有关错误的详细信息。日志文件通常位于~/.ros/log/
目录下。 -
查看Gazebo问题跟踪器:
检查Gazebo的GitHub问题跟踪器,看看是否有人报告了与您类似的错误,并查找可能的解决方案。 -
尝试不同的模型:
为了确定问题是否与特定的模型(如turtlebot3)相关,您可以尝试在Gazebo中加载不同的模型。 -
检查硬件和驱动程序:
如果错误与图形硬件或驱动程序相关,请确保您的图形驱动程序是最新的,并且与您的操作系统兼容。 -
寻求社区帮助:
如果上述步骤都不能解决问题,您可以在ROS和Gazebo的社区论坛、邮件列表或GitHub问题跟踪器中寻求帮助。 -
使用Docker:
如果您仍然无法解决问题,考虑使用Docker来运行ROS 2和Gazebo的预配置环境。这可以确保所有依赖项和配置都是正确的,并且可以轻松地重新创建环境。
以上为生成回答,仅供参考~
-
-
@thh 在 用gazebo打开turtletle3下的ros2turtlebot3_house.launch.py文件一直报错 中说:
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" 失败。
之前遇到多这种bug,好像是关节碰撞导致的,不确定你这个原因,建议先加载一个空环境,再加载机器人和插件之类的,确定是哪个部件导致的