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

std_msgs::Duration multipliation

asked 2016-09-26 03:32:53 -0600

eed gravatar image

Hi I want to calculate a distance. Therfore I have a std_msgs::Duration t and want to calculate:

d*d = t*t * w*w;

with w is the speed of sound (for now as a float). The error I get is:

no match for ‘operator*’ (operand types are ‘const Time {aka const std_msgs::Time_<std::allocator<void> >}’ and ‘const Time {aka const std_msgs::Time_<std::allocator<void> >}’)
 d1_2 = t1*t1*omega*omega;

I think I have to convert the duration into a float. But I don't know how to do.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2016-09-26 08:04:55 -0600

Take a look at the API reference for DurationBase, which Duration inherits from. You probably want toSec which returns a double.

edit flag offensive delete link more

Comments

That looks good but doesn't work:

error: ‘const Duration’ has no member named ‘toSec’

I used std_msgs::Duration. Now I try to ue ros::Duration, than i think your answer work.

eed gravatar image eed  ( 2016-09-27 03:23:18 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2016-09-26 03:32:53 -0600

Seen: 568 times

Last updated: Sep 26 '16