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

Gazebo camera timestamp issue

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

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="libgazebo_ros_camera.so">
    <updateRate>20.0</updateRate>
    <imageTopicName>/gazebo/cam1</imageTopicName>
    <cameraInfoTopicName>/gazebo/cam1/info</cameraInfoTopicName>
  </controller:gazebo_ros_camera>
</sensor:camera>

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

boost::lexical_cast<std::string>(image_message1->header.stamp)

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
0

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

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

Comments

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 -0600 )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 -0600 )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 -0600 )edit

Question Tools

Stats

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

Seen: 431 times

Last updated: Oct 26 '11