Closed rhaschke closed 1 year ago
The error related to pluginlib failing to unload the libraries is fixed by 98c58d415041d37267252e15b396cd943bd1f0cd. However, I still get the following exception on shutdown:
terminate called after throwing an instance of 'boost::wrapexcept<boost::lock_error>'
what(): boost: mutex lock failed in pthread_mutex_lock: Invalid argument
I'm not quite sure about its origin and debugging this error is not straight forward. We'll have to dig a little deeper for an actually graceful exit.
Did you already tried to debug this? You need to figure out which mutex is affected. The error typically is related to the mutex being destroyed already (in some other thread).
I checked and cleaned up the usages of sim and render mutexes in 6603225092072d1206e5d6585fb8cacf0ccf93cc. But I already suspected this is somehow related to ROS threads, because of the boost wrapped exception.
With gdb I found that the unique pointer to the simulation step action still needed to be reset and would otherwise cause deallocation problems.
If the simulation uses the sensors plugin and is shutdown before unpausing, the waitForMessage
call in the sensors deferred init function will throw
terminate called after throwing an instance of 'boost::wrapexcept<boost::bad_weak_ptr>'
what(): tr1::bad_weak_ptr
I'm not sure yet how to handle this. We might have to change how the sensor plugin ensures transforms are available.
Other than this last issue, the simulation should exit gracefully.
Could you please call me for this - either by phone or zoom.
Looks good!
I merged the feature branch. For now we fixed all errors on shutdown.
When closing MuJoCo's viewer window, I get the following warnings:
The reason is that the plugin libs are being unloaded although object instances created from those libs are still in use. You first need to finish controllers and unregister/delete those instances.