Gazebo仿真环境加载模型错误,卡在启动页面:Spawn service failed. Exiting 解决办法

发布于 2021-03-28  1146 次阅读


在实现激光传感器的PX4自动导航避障时,执行roslaunch启动launch文件后,rviz启动正常,但Gazebo启动后卡住,没有找到模型,报错信息如下:

[ INFO] [1616931993.460944734]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[INFO] [1616931993.473886, 0.000000]: Calling service /gazebo/spawn_sdf_model
[INFO] [1616931993.498768, 0.000000]: Spawn status: SpawnModel: Entity pushed to spawn queue, but spawn service timed out waiting for entity to appear in simulation under the name iris_0
[ERROR] [1616931993.504807, 0.000000]: Spawn service failed. Exiting.
[ INFO] [1616931993.512757068, 354.215000000]: Physics dynamic reconfigure ready.
[vehicle_spawn_ganahe_Nitro_AN515_51_17591_2900921694285571977-6] process has died [pid 17662, exit code 1, cmd /opt/ros/melodic/lib/gazebo_ros/spawn_model -sdf -file /home/ganahe/catkin_ws/src/px4_command/models/iris_2Dlidar/iris_2Dlidar.sdf -model iris_0 -x 0 -y 0 -z 0 -R 0 -P 0 -Y 0 __name:=vehicle_spawn_ganahe_Nitro_AN515_51_17591_2900921694285571977 __log:=/home/ganahe/.ros/log/3b6c2d02-8fbb-11eb-b89b-f82819b4f653/vehicle_spawn_ganahe_Nitro_AN515_51_17591_2900921694285571977-6.log].
log file: /home/ganahe/.ros/log/3b6c2d02-8fbb-11eb-b89b-f82819b4f653/vehicle_spawn_ganahe_Nitro_AN515_51_17591_2900921694285571977-6*.log

分析

编写的功能包加载的世界模型文件路径如下:

ganahe@ganahe-Nitro-AN515-51:~/catkin_ws/src/autoNav_uav_ganahe/models$ pwd
/home/ganahe/catkin_ws/src/autoNav_uav_ganahe/models

而默认配置的Gazebo则正常,经过多方搜寻答案,看到一位大佬的回答:

file

链接:https://ask.csdn.net/questions/2667698

分析得知模型路径未加入配置文件.bashrc中,检查后配置

echo export GAZEBO_MODEL_PATH=${GAZEBO_MODEL_PATH}:/home/ganahe/catkin_ws/src/px4_command/models >> ~/.bashrc

source ~/.bashrc

再次执行:

roslaunch autoNav_uav_ganahe ros_2DNav_ladar_ganahe.launch

执行成功,困扰了一晚上的问题解决!!

file