My Gazebo version is Garden. I want to use ROS2 command to delete the model in Gazebo simulation.

What command should I enter?


2 Answers 2


I believe the previous answer is correct for gazebo classic. However it is different for gazebo garden.

As of right now there is no ROS interface that directly exposes the delete entity service. There is a draft pull request to add those features.

You could also develop a system plugin and call the RequestRemoveEntity() method for the entity component manager. It is possible to embed a ros2 node inside of a gz system plugin. So you could create a ros service that could be called to remove an entity inside of the system plugin.

Here is an example showing how to embed a ros2 node inside of a gazebo system plugin.

  • $\begingroup$ +1 - You are most likely correct... I must admit that I didn't look for Garden specific examples. I should have made that clear in my answer. This should probably be the accepted answer. $\endgroup$ Commented Apr 8 at 22:32

There are a number of ways, depending on how you want to do it.

Command line

You could use the command line

rosservice call gazebo/delete_model '{model_name: <model_name>}'

In Python

Or something like this in Python:

from gazebo_msgs.srv import DeleteModel # For deleting models from the environment

def del_model( modelName ): # FIXME: Freezes Python, DO NOT USE!
    """ Remove the model with 'modelName' from the Gazebo scene """
    # delete_model : gazebo_msgs/DeleteModel
    del_model_prox = rospy.ServiceProxy('gazebo/delete_model', DeleteModel) # Handle to model spawner
    # rospy.wait_for_service('gazebo/delete_model') # Wait for the model loader to be ready 
    del_model_prox(str(modelName)) # Remove from Gazebo

Note: You need to pass del_model_prox a string, else it will crash. So it is safer to use


rather than just



In C++

From this answer to Problem with Deleting Models

 #include "gazebo/DeleteModel.h"
    remove(std::string model_name)
           ros::NodeHandle nh("");
           ros::ServiceClient deleteModelClient = nh.serviceClient<gazebo::DeleteModel>("gazebo/delete_model");
           gazebo::DeleteModel deleteModel;
           deleteModel.request.model_name = model_name;

and call it (from main() or where ever), with


See also gazebo_msgs/DeleteModel Service

File: gazebo_msgs/DeleteModel.srv

Raw Message Definition

string model_name                 # name of the Gazebo Model to be deleted
bool success                      # return true if deletion is successful
string status_message             # comments if available

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.