Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't spawn a model with the same name as a previously-deleted one #510

Closed
osrf-migration opened this issue Feb 19, 2013 · 10 comments
Closed
Labels
1.4 bug Something isn't working major

Comments

@osrf-migration
Copy link

Original report (archived issue) by Jonathan Bohren (Bitbucket: jbohren).


I looked for a ticket corresponding to this kforge ticket, but couldn't find one: https://kforge.ros.org/gazebo/trac/ticket/49

@osrf-migration
Copy link
Author

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


Are you spawning the model using the "Insert" tab on the left side of the screen? In the latest development branch of gazebo, I can verify that the model is successfully deleted from the server (I spawned and deleted some models and then did a "Save world as" and the models were not listed in the saved sdf file). I think the model is not being deleted from the client, which increments the model name in ModelMaker::CreateTheEntity:348-355.

@osrf-migration
Copy link
Author

Original comment by Jonathan Bohren (Bitbucket: jbohren).


This was in version 1.3, using the ROS service to spawn the model, and the gazebo gui to delete it. Since the server reports no errors, I wouldn't be surprised if it was just a problem with the gui client.

@osrf-migration
Copy link
Author

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


  • changed state from "new" to "on hold"

Until 2.0

@osrf-migration
Copy link
Author

Original comment by Ian Chen (Bitbucket: Ian Chen, GitHub: iche033).


  • changed state from "on hold" to "open"

@osrf-migration
Copy link
Author

Original comment by Silvio Traversaro (Bitbucket: traversaro).


The issue is still present in the latest version of Gazebo.
If I try to spawn from the GUI a robot (let's say named icub), then the robot has name icub

If I then delete it and I respawn it from the GUI, then the robot name will be icub_0. If I delete it and respawn again, its name will be icub_2.

This happens only for model spawned with the GUI.

The cause is that the for the model created by the GUI, the MainWindow::entities data stucture is used to check name duplicates (https://github.com/osrf/gazebo/blob/318d72e43638591f25ba9af15e10b99194e8ec52/gazebo/gui/ModelMaker.cc#L398):

    // Automatically create a new name if the model exists
    rendering::ScenePtr scene = gui::get_active_camera()->GetScene();
    gui::MainWindow *mainWindow = gui::get_main_window();
    if (scene && mainWindow)
    {
      int i = 0;
      while ((isModel && mainWindow->HasEntityName(modelName)) ||
          (isLight && scene->GetLight(modelName)))
      {
        modelName = modelElem->Get<std::string>("name") + "_" +
            std::to_string(i++);
      }
    }

The problem is that the entities data structure is populated on entity creation (see https://github.com/osrf/gazebo/blob/318d72e43638591f25ba9af15e10b99194e8ec52/gazebo/gui/MainWindow.cc#L2022):

void MainWindow::OnModel(ConstModelPtr &_msg)
{
  this->dataPtr->entities[_msg->name()] = _msg->id();
  for (int i = 0; i < _msg->link_size(); i++)
  {
    this->dataPtr->entities[_msg->link(i).name()] = _msg->link(i).id();

    for (int j = 0; j < _msg->link(i).collision_size(); j++)
    {
      this->dataPtr->entities[_msg->link(i).collision(j).name()] =
        _msg->link(i).collision(j).id();
    }
  }

Unfortunately the entities attribute is not cleaned on model removal. As far as I could check, apparently the MainWindow class is not notified by anything on model removal.

@osrf-migration
Copy link
Author

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


  • set assignee_account_id to "557058:6ff86fcb-b7ab-44a5-b8a6-f6d9cae8b6e8"
  • set assignee to "chapulina (Bitbucket: chapulina, GitHub: chapulina)"

@osrf-migration
Copy link
Author

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


Pull request #2296 -> server generates unique names for models, gazebo7

Pull request for default is coming up. Also working on server generating unique names for lights.

@osrf-migration
Copy link
Author

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


pull request #2301 -> server generates unique names for models, default

@osrf-migration
Copy link
Author

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


I can't reproduce the issue on Gazebo 9, try for example:

  1. Open Gazebo
  2. Insert a sphere from the toolbar, it is called unit_sphere
  3. Insert a second sphere, it's called unit_sphere_0
  4. Delete unit_sphere
  5. Insert a new sphere, it will be called unit_sphere

@osrf-migration
Copy link
Author

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


  • changed state from "open" to "resolved"

@osrf-migration osrf-migration added major bug Something isn't working 1.4 labels Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.4 bug Something isn't working major
Projects
None yet
Development

No branches or pull requests

1 participant