Gazebo freezes intermittently when using a model plugin
Summary
I have created a custom model plugin and have attached it to a model spawned in gazebo. I want to run simulation experiments with different parameters. The workflow is:
1. Launch an empty gazebo world with a launch file
2. Spawn the model with the plugin attached
3. After a set amount of time, delete the model using the /gazebo/delete_model
service
4. Set different parameters to the ros parameter server and respawn the model
I need to run around 1000 trials to sufficiently explore the parameter space.
Problems
1. Gazebo stops running after a small, random number of respawns (around 10-15). By stop working, I mean that the spawned model remains frozen in place. The gui indicates that the simulation is not paused. Also, none of the /gazebo/..
services return a response. For, example, I cannot delete the spawned model (frozen in place).
2. This problem disappears when I remove the model plugin.
I am new to gazebo, so am not sure what I am doing wrong, or what to check. Any help or advice would be appreciated!