ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

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


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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


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

Seen: 1,174 times

Last updated: Nov 15 '19