Home | Tutorials | Wiki | Issues
Ask Your Question
0

Get WorldPtr to the simulated world by gzserver

asked 2016-08-14 19:19:40 -0600

wicked88 gravatar image

Hi all,

I'm implementing my own simulator using Gazebo, Ignition and ROS. Using gzserver, a world file and my models, im able to get everything rendered correctly by gzserver and control everything. Now, i implemented the visualization in my simulator, in Qt, although it has low fps, but that's still a problem to be solved. Now, i want to control all the aspects of the world that is being simulated by gzserver.

Looking at Gazebo's API i noticed the classes World and Model under gazebo::physics, that allow me to control and have access to all of the data from the simulation that i need, and, so far so good. I just don't get how to have access do the world (get the matching WorldPtr) that is being simulated by gzserver, to be able to use all the funcionalities provided by World class.

The documentation doesn't helped me either, as it is poorly documented and no examples are given ...

Thanks in advance !

Pedro Silva

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2016-08-15 11:53:16 -0600

updated 2016-08-15 14:21:47 -0600

I don't think there is a (trivial?) way to directly access WorldPtr from another process. Gazebo for example, runs two processes: gzserver, which holds the WorldPtr, and gzclient, which has no direct access to it. Instead, gzclient talks to gzserver via the transport layer.

If the current transport layer is not exposing enough for your use case, you could create a world plugin, or system plugin, which exposes the functionality you need for the GUI.

Let's say for example that you need CoM information for all models in the world. Your world plugin could publish that information on a new topic, and your GUI listens to it and displays the information accordingly.

That sounds like an awesome project, by the way :)

edit flag offensive delete link more

Comments

Hi again ! The World class offers so much, is almost impossible to miss it. I managed to think of a cheat for this, don't know if it is really retarded or not, but ... I thought of "why not publishing the world memory address (content of the WorldPtr) through a topic". I then read the topic, make a WorldPtr or a World * object, cast the address and voilá ! Haven't tried, need an opinion, from 1 to 10, how retarded is this.

wicked88 gravatar imagewicked88 ( 2016-08-16 20:59:46 -0600 )edit

Also, i managed to control the simulation (pause, unpause, reset models, reset all, get times and so on ... ) using the transport layer as you suggested. Now, this cheat that i referred, might allow me to have a "God" like control over the simulation and the models, much easier to work than with the transport layer.

wicked88 gravatar imagewicked88 ( 2016-08-16 21:31:10 -0600 )edit

Gazebo wasn't designed to work like this, so there might be many risks involved. But it sounds like an interesting experiment :)

chapulina gravatar imagechapulina ( 2016-08-18 10:39:35 -0600 )edit
0

answered 2016-08-15 13:36:59 -0600

wicked88 gravatar image

Hi, thanks !!

I'm developing this for my RoboCup MSL Team and for my master thesis, so, controlling and rendering the simulation is the first step :D . I managed to pause, unpause the simulation using a publisher to a gazebo topic, but i would rather have a class to control the simulated world, haven't tried that yet. My GUI in Qt is supposed to have full control of everything, how would i get the pointer to my Qt program using the world plugin ?

Thanks !

edit flag offensive delete link more

Comments

Could you please move this to the question? I'll edit my answer to reply to that ;)

chapulina gravatar imagechapulina ( 2016-08-15 14:13:23 -0600 )edit

I would be also very interested. Have a similar problem. Wanted to create a model-view-ctrl concept with gazebo framework, but having issues implementing gazebo plugins into my software. Is there only a publisher subscriber concept designated to pass information?

TwoBid gravatar imageTwoBid ( 2016-08-17 03:35:26 -0600 )edit

As a safe way to do it, i guess the answer is yes. The gzserver provides information and the plugins allow to control entities (world, models, lights). I'm halfway of implementing something very stupid or very cool, which lies on what i posted on the up comment. I made a world plugin that publishes the memory address of the world, and my Qt program will read that address, cast a pointer to a world, and i hope to gain access to all the world functionalities.Don't know how stupid this is,lets see.

wicked88 gravatar imagewicked88 ( 2016-08-17 06:04:31 -0600 )edit

Very interested in the outcome, pls let us know about your results :)

TwoBid gravatar imageTwoBid ( 2016-08-18 05:52:54 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-08-14 19:19:40 -0600

Seen: 472 times

Last updated: Aug 15 '16