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

ROS2 Dashing: No seconds() in Time_ struct

asked 2019-11-15 10:25:49 -0500

ananya.muddu gravatar image

updated 2019-11-15 10:28:24 -0500

Hi,

While trying to compile the image message callback function in a ROS2 node below,

void imageCallback(const sensor_msgs::msg::Image::ConstSharedPtr& img_msg) {
      double cur_time = img_msg->header.stamp.seconds();
      ...
}

I get the following compilation error:

const struct builtin_interfaces::msg::Time_<std::allocator<void>> has no member named ‘seconds’

How do I solve this issue?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-11-15 12:42:19 -0500

gvdhoorn gravatar image

updated 2019-11-15 12:44:41 -0500

How do I solve this issue?

Use the correct name ;)

builtin_interfaces/msg/Time.msg only has a sec field, not seconds:

int32 sec
uint32 nanosec

And unless I'm mistaken:

double cur_time = img_msg->header.stamp.seconds();

It's also not a method/function, but a plain public member variable. You can't invoke it, so the () are also incorrect/not needed.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2019-11-15 10:25:49 -0500

Seen: 1,668 times

Last updated: Nov 15 '19