Ask Your Question
0

ROS2 Dashing: No seconds() in Time_ struct

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

ananya.muddu gravatar image

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

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

gvdhoorn gravatar image

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

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

Stats

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

Seen: 15 times

Last updated: Nov 15