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

can't add time and duration.

asked 2018-09-18 12:22:17 -0500

edamondo gravatar image

updated 2018-09-18 16:49:04 -0500

jayess gravatar image

Hi,

I am basing myself on this to do some time manipulation in ros. But when I write :

ros::Time beginTime = ros::Time::now();                                                                                                                  
ros::Duration delta_t = ros::Duration(t/2);                                                                                                              
ros::Time t1 = delta_t + beginTime;                                                                                                                      
ros::Time t2 = delta_t + t1;

I get the error

error: no match for ‘operator+’ (operand types are ‘ros::Duration’ and ‘ros::Time’)
ros::Time t1 = delta_t + beginTime;

Why is that? Something has changed since the other post?

Thank you for your help!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
3

answered 2018-09-18 18:18:41 -0500

lucasw gravatar image

updated 2022-02-25 08:28:53 -0500

On Melodic the time has to come before the duration:

ros::Time t1 = beginTime + delta_t;
ros::Time t2 = t1 + delta_t;

http://wiki.ros.org/roscpp/Overview/T... shows the proper order (but doesn't say the opposite won't work).

The other post says the code is untested, so the ordering requirement may or may not have changed.

(Update- I fixed the other post to have the correct time + duration ordering)

edit flag offensive delete link more

Comments

worked for me on ROS noetic! Thanks

amjack gravatar image amjack  ( 2022-02-25 07:03:42 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-09-18 12:22:17 -0500

Seen: 1,215 times

Last updated: Feb 25 '22