Gazebo | Ignition | Community
Ask Your Question

Is it possible to send a world pointer in a message?

asked 2017-05-23 10:19:00 -0600

jelavice gravatar image

updated 2017-05-23 10:33:35 -0600

Would it be possible to define a message that transports a pointer to the world class (physics::WorldPtr) in gazebo and send such a message to another node. The upshot would be having something like msgs::WorldPtr.

If it ain't possible, can the same be done with a model pointer?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-05-23 11:43:34 -0600

Carlos Agüero gravatar image

updated 2017-05-23 11:48:42 -0600

(Not a direct reply to your question but might be relevant)

I'm assuming that you want access to the world from your plugin. If it's not a world plugin you can call gazebo::physics::get_world(). If that's enough you'll safe the extra work of sending pointers around.

edit flag offensive delete link more


Hi, thanks for the answer. Ideally, I'd like to access the world from a different node. I don't see any other way than sending a pointer to that node.

jelavice gravatar imagejelavice ( 2017-05-23 14:51:45 -0600 )edit

Could you clarify what do you mean by node? If by node you mean a process, you cannot share the pointer. Each process has its own virtual address space to give the abstraction that all memory belongs to the process. Under the hood, this is mapped into the physical memory. The same memory address for two processes maps into different addresses of physical memory. If by node you mean a thread, you could share the pointer but in that case I'd recommend to use `physics::get_world()`.

Carlos Agüero gravatar imageCarlos Agüero ( 2017-05-23 17:28:05 -0600 )edit

By node I meant another executable. Since I am running it from a different terminal this would mean that my executable is indeed attached to another process (correct me if I'm wrong). Hence, the short answer to my question is "no". Long answer is "maybe, but it's of no use since the pointer would probably point to a wrong address in memory."

jelavice gravatar imagejelavice ( 2017-05-24 00:05:43 -0600 )edit

In that case, you have two separate processes and passing a pointer is not a good idea, you won't be able to access the world. Probably the best approach is to subscribe to an existing topic that publishes the data you're interested or alternatively create a custom message and publish the information by yourself.

Carlos Agüero gravatar imageCarlos Agüero ( 2017-05-24 11:35:25 -0600 )edit

Question Tools

1 follower


Asked: 2017-05-23 10:19:00 -0600

Seen: 289 times

Last updated: May 23 '17