Home | Tutorials | Wiki | Issues
Ask Your Question
3

Create model during runtime

asked 2016-01-16 10:18:08 -0500

skm gravatar image

Hello,

is there a way to create a model during runtime? I've created a little GUI overlay plugin with a button and some other elements. If the button is pressed i want to create some cylinders in the scene that are connected by joints at specified positions with specified dimensions. The position and size of the cylinders are not known during startup of Gazebo, so i don't want to use SDF files as used in most tutorials.

I've tried to find tutorials or a way to create models during runtime, but couldn't find anything. Is there a way to solve my problem?

Maybe i could create a string, that looks like a SDF file, as in this tutorial: http://gazebosim.org/tutorials?tut=gu... But i hope there is a better way, because the creation of such a string that simulates a SDF file with a couple of calculated parameters, that need to be used, would be complex and not very convenient. Maybe there are some already existing methods of gazebo, like (pseudocode): "createCylinder(position, radius, length); addJoint(cylinder, jointType); ...."

Thank you very much, skmCry

edit retag flag offensive close merge delete

Comments

I'm actually interested in doing this as well... I think if we start looking at the model editor code we will find the examples we want. the path from the root of gazebo is `gazebo/gui/model/`

Peter Mitrano gravatar imagePeter Mitrano ( 2016-02-15 11:38:43 -0500 )edit

I'm actually interested in doing this as well... I think if we start looking at the model editor code we will find the examples we want. the path from the root of gazebo is ```gazebo/gui/model/```

Peter Mitrano gravatar imagePeter Mitrano ( 2016-02-15 11:38:57 -0500 )edit

The model editor uses SDF as well, see this: https://bitbucket.org/osrf/gazebo/src/411807a3a83074ef00bea1482a62d81775003e28/gazebo/gui/model/ModelCreator.cc?fileviewer=file-view-default#ModelCreator.cc-1435 You don't necessarily have to handle a string. You can have an `sdf::ElementPtr` and manipulate its attributes with the SDF API: http://osrf-distributions.s3.amazonaws.com/sdformat/api/dev/classsdf_1_1Element.html

chapulina gravatar imagechapulina ( 2016-02-15 12:12:30 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-15 19:31:08 -0500

You can see an example of a very very similiar plugin here. It generates/reads mazes in gazebo

example video 1 example video 2

edit flag offensive delete link more

Comments

Nice thanks alot! Will be looking a this!

AlexandreB gravatar imageAlexandreB ( 2016-03-15 21:29:01 -0500 )edit

I'm sorry for the late response, although i've created this topic, but i was very busy and couldn't continue working on my project. Anyway, thanks a lot Peter, your code helped me a lot to get an idea how gazebo works and a real-time creation of models can be accomplished. I've created a gui and world plugin. Both are running at the same time and model creation with sdf::ElementPtr is looking good so far. But communication between the gui and world plugin is a bit complex (qt signal&slots needed

skm gravatar imageskm ( 2016-03-19 16:56:49 -0500 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2016-01-16 10:18:08 -0500

Seen: 931 times

Last updated: Mar 15 '16