ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Gazebo camera timestamp issue

asked 2011-10-25 22:19:34 -0500

nitschej gravatar image

If I use a gazebo camera like this:

<sensor:camera name="camera1_sensor">
  <imageSize>160 160</imageSize>
  <controller:gazebo_ros_camera name="controller-cam1" plugin="">

The timestamps for full second N is actually output as N-1 + 1000000000ns. This leads to weird behavior, for example when using


in a C++ application, as it produces the string "{N-1}.10" instead of the expected "{N}.00".
I assume that it is probably wrong to blindly use the lexical_cast on every datatype that comes along. And actually this is not a big issue, if you finally realize that it works that way.
But I wonder if this is the correct behavior/usage of ROS::Time? Can I expect other components that output ROS::Time tho behave in the same way and should I do it the same if I ever was to create a ROS::Time object?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2011-10-26 03:38:30 -0500

joq gravatar image

I believe ros::Time() has an operator<<(), which should do the correct normalization.

Have you tried that?

edit flag offensive delete link more


I didn't know about that operator until now. But I checked it and it does not normalize the output stream.
nitschej gravatar image nitschej  ( 2011-10-26 19:14:05 -0500 )edit
It probably should. Either that, or the ros::Time() implementation intended to maintain normalized data as an invariant. We should open a defect ticket.
joq gravatar image joq  ( 2011-10-27 01:34:56 -0500 )edit
Ok, I'll try that. Btw. I wonder, doesn't lexical_cast actually use the ostream operator?
nitschej gravatar image nitschej  ( 2011-10-30 23:50:33 -0500 )edit

Question Tools


Asked: 2011-10-25 22:19:34 -0500

Seen: 406 times

Last updated: Oct 26 '11