Gazebo | Ignition | Community
Ask Your Question
0

Cannot delete models when using the transport system

asked 2018-12-30 14:13:44 -0600

david_d gravatar image

updated 2019-01-02 12:03:03 -0600

chapulina gravatar image

Hello.

I am attempting to use the transport message system to have one plugin request another plugin to delete several models, using the world.RemoveModel() method, or model.Fini() method. When this simple system deletes any models, gazebo crashes, and I get the following error message:

gzclient: /usr/include/boost/smart_ptr/shared_ptr.hpp:648: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::msgs::Response; typename boost::detail::sp_member_access<T>::type = gazebo::msgs::Response*]: Assertion `px != 0' failed.

I have confirmed that I can use these methods successfully, without issue. The only through-line I can identify with replicating this issue, is that the error appears when a deleting method is called from within a callback for a topic subscription.

I have tested (to the best of my ability) to confirm that the issue is not:

  • That the shared pointer to the world is broken.
  • That accessing the world at all is broken.
  • That I cannot change things using any world methods.
  • That the issue is specific to the world.RemoveModel() method.
  • That deleting something from within a callback is broken, for example an event callback.

Which leads me to conclude it is specifically the transport system callbacks, and specifically deleting models.

Any ideas as to what causes this? For now, I'm just working around the issue.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-01-02 12:06:22 -0600

chapulina gravatar image

It's most likely not thread-safe to call the RemoveModel function on a world object from a thread other than the physics thread. In your case, you're trying to call it in a transport callback thread.

Instead, try connecting to the world update event and calling the function from that callback. See an example on this tutorial.

edit flag offensive delete link more

Comments

Thank you for your answer. That is indeed how I ended up working around my problem. In future, is there any documentation about the thread system I could reference? If not, would it be appropriate for me to contribute some, somewhere? I'm very new to c++ in general, so if this is such an obvious issue that it doesn't need to be written down anywhere, then that makes sense.

david_d gravatar imagedavid_d ( 2019-01-04 15:14:55 -0600 )edit

We don't have a tutorial on all the Gazebo threads yet, you're welcome to contribute one! Here's where the turorials are hosted: https://bitbucket.org/osrf/gazebo_tutorials/

chapulina gravatar imagechapulina ( 2019-01-04 15:51:30 -0600 )edit

Thank you. I may contribute if I feel my understanding of the topic is sufficient.

david_d gravatar imagedavid_d ( 2019-01-04 19:32:27 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2018-12-30 14:13:44 -0600

Seen: 415 times

Last updated: Jan 02 '19