gzserver crashed randomly when using delete and spawn model. ROS core dumped
I am doing deep Q learning and trying to delete and spawn models for every episode. And I am getting the following crash:
gzserver: ../nptl/pthread_mutex_lock.c:79: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed.
Aborted (core dumped)
This happens randomly; it can crash on the 50 episode or 400 episodes. Here are the portion of my code that I think is responsible for the crash:
rospy.wait_for_service("gazebo/delete_model")
rospy.wait_for_service("gazebo/spawn_sdf_model" )
delete_model = rospy.ServiceProxy("gazebo/delete_model", DeleteModel)
spawn_model = rospy.ServiceProxy("gazebo/spawn_sdf_model", SpawnModel)
#----------Surrounding Generation-----------#
prev_surr_name = "surr"+str(self.prev_surrounding)
# print("prev i i", self.prev_surrounding)
if self.prev_surrounding is not None:
try:
resp = delete_model(prev_surr_name) #delete
except rospy.ServiceException, e:
print "Service call failed for delete model: %s" % e
surr_i = random.randint(0,2)
curr_surr_name = "surr"+str(surr_i)
self.prev_surrounding = surr_i
# print("current i", self.prev_surrounding)
f = open('/home/user/model_editor_models/surr'+str(surr_i)+'/model.sdf','r')
surr_xml = f.read()
surr_x = 6.08
surr_y = -2.2
surr_quat = Quaternion(*quaternion_from_euler(0.0, 0.0, 0))
surr_pose = Pose(Point(x=surr_x, y=-2.2, z=0), surr_quat)
try:
resp = spawn_model(curr_surr_name, surr_xml, "", surr_pose, "world") #spawn
except rospy.ServiceException, e:
print "Service call failed for spawn_model: %s" % e
I am also getting these errors on my other terminal:
Service call failed for delete model: transport error completing service call: unable to receive data from sender, check sender's logs for details
Service call failed for spawn_model: unable to connect to service: [Errno 104] Connection reset by peer
I am using python and don't remember messing around with pthread, I did use gazebo.pauseSim() here and there but I don't think that cause this issue. Does anyone have an idea of what might cause these?
If you're deleting/spawning parts, are they the same model? Because if so, I tried using move model and that seemed to be more stable (tried your strategy first and it kept crashing). However, when I moved models and tried to complete the same actions I did in the previous episode when they were first spawned, they wouldn't do the same behavior which was confusing. If this isn't an issue for you, it might be worth a shot.