Home | Tutorials | Wiki | Issues
Ask Your Question
0

How to add/delete a object mutliple times from a single model file using a plug-in

asked 2014-01-10 07:56:11 -0500

Markus Bader gravatar image

Hi

I like to add multiple cylinders with an id and i like also to remove them after a ceartain time using a plug-in. I worked through the model factory example. http://gazebosim.org/wiki/Tutorials/1.9/plugins/factory I am able to add, let's say ten cylinders but all cylinders a named the same. So my first question is how to I add a model, from file with a different name? How to I remove a added model by name using a plug-in?

Thanks

edit retag flag offensive close merge delete

Comments

If you add them as in the tutorial, you could usa a variable for the model name in order to use different values. And you should be able to remove them with http://gazebosim.org/api/dev/classgazebo11physics11Model.html#ae8f752eae4b0a138fae49065e24e202c

AndreiHaidu gravatar imageAndreiHaidu ( 2014-01-10 09:58:09 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
2

answered 2014-02-10 03:05:32 -0500

scpeters gravatar image

updated 2014-02-10 03:24:42 -0500

Assuming you're using a WorldPlugin, you can use the World::InsertModelSDF or World::InsertModelString API's (see example code from updated tutorial). You can specify the model name as an attribute in the passed SDF object or SDF string. I'm updating the example to show how to do this (pull request #957).

I don't think it's currently possible to specify a custom model name when spawning via a filename with a factory message, though it can be done when passing custom sdf strings (see numerous spawning functions in the ServerFixture class).

edit flag offensive delete link more

Comments

Thanks for the update, spawning works now

Markus Bader gravatar imageMarkus Bader ( 2014-04-10 04:42:47 -0500 )edit
0

answered 2014-01-13 23:00:38 -0500

dkotfis gravatar image

I've been doing this by keeping track of whether a model type exists within the world, and using the clonemodelname field of the factory message to spawn sequential models. With this method, each new model takes the previous with "_clone" appended to its name. Unfortunately, the functions within physics::World needed modify the model name before spawning are private, so I don't think there's a better way right now.

edit flag offensive delete link more
0

answered 2014-01-13 23:03:04 -0500

dkotfis gravatar image

You can delete models using the "entity_delete" field on the "~/request" topic. Just fill in the model name.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2014-01-10 07:56:11 -0500

Seen: 1,180 times

Last updated: Feb 10 '14