调试环境
Ubuntu20.04-Galactic
gazebo11
报错内容
在ROS2中运行
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
打开gazebo时图标直接卡住,world一直出不来,终端报错如下:
[spawn_entity.py-4] [ERROR] [1666579919.180097092] [spawn_entity]: Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory?
[spawn_entity.py-4] [ERROR] [1666579919.182394989] [spawn_entity]: Spawn service failed. Exiting.
[ERROR] [spawn_entity.py-4]: process has died [pid 3040, exit code 1, cmd ‘/opt/ros/galactic/lib/gazebo_ros/spawn_entity.py -entity waffle -file /opt/ros/galactic/share/turtlebot3_gazebo/models/turtlebot3_waffle/model.sdf -x -2.0 -y -0.5 -z 0.01 --ros-args’].
[spawn_entity.py-4] [ERROR] [1666579919.180097092] [spawn_entity]: Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory?
[spawn_entity.py-4] [ERROR] [1666579919.182394989] [spawn_entity]: Spawn service failed. Exiting.
[ERROR] [spawn_entity.py-4]: process has died [pid 3040, exit code 1, cmd '/opt/ros/galactic/lib/gazebo_ros/spawn_entity.py -entity waffle -file /opt/ros/galactic/share/turtlebot3_gazebo/models/turtlebot3_waffle/model.sdf -x -2.0 -y -0.5 -z 0.01 --ros-args'].
解决方法
添加models路径,终端输入以下指令
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/galactic/share/turtlebot3_gazebo/models
如果要避免每次都输入这句指令,可以将指令添加到~/.bashrc最后一行。
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/opt/ros/galactic/share/turtlebot3_gazebo/models