Gazebo | Ignition | Community
Ask Your Question

'world' is protected, how do I get a pointer?

asked 2019-09-23 23:09:54 -0600

clydemcqueen gravatar image

updated 2019-09-23 23:24:28 -0600

Hi, super dumb question... I'm writing a sensor plugin (subclass SensorPlugin) that wraps an Altimeter sensor and I need access to SimTime(). How do I get a pointer to the world object to call SimTime()? I see it in the sensor API (include/gazebo-9/gazebo/sensors/Sensor.hh) but it's protected. Is there some magic global variable that I'm missing?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-09-23 23:30:27 -0600

chapulina gravatar image

It's not recommended to access the world from a sensor plugin because sensors don't run in the physics thread.

Maybe what you want are Altimeter::LastUpdateTime or Altimeter::LastMeasurementTime?

edit flag offensive delete link more



Thanks for the quick reply! I suspected as much. Altimeter::LastMeasurementTime is always 0 and Altimeter::LastUpdateTime seems 10-20ms later than ros_node->now(), which itself is later than Camera::LastMeasurementTime. Any advice? Perhaps I need to write a camera sensor plugin that will give me consistent time across multiple sensors? Or fix Altimeter::LastMeasurementTime?

clydemcqueen gravatar imageclydemcqueen ( 2019-09-24 09:52:37 -0600 )edit

My workaround (so far): I hacked up a version of gazebo_ros_pkgs that use wall time, rather than SimTime or ROS time. While not ideal, all sensors report the same time. If there are other good options I'd love to hear about them!

clydemcqueen gravatar imageclydemcqueen ( 2019-11-23 10:48:57 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-09-23 23:09:54 -0600

Seen: 115 times

Last updated: Sep 23 '19