Ask Your Question

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


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

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

lucasw gravatar image

updated 2018-09-18 18:20:07 -0500

On Melodic the time has to come before the duration:

ros::Time t1 = beginTime + delta_t;
ros::Time t2 = t1 + delta_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.

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: 2018-09-18 12:22:17 -0500

Seen: 586 times

Last updated: Sep 18 '18