0
$\begingroup$

Rosanswers logo

Hello everyone,

i have some troubles and hope that you can help me. I want to use the time that i got from ROS in Matalb. First i used the command ros::Time::now(); and i got for each frame a timestamp. And now in matlab, i want to use the difference between the timestamp (eg. timestamp[3] - timestamp [2] or timestamp[4] - timestamp [3]) for further calculations. But the problem is that i always got the value 0 when i calcute the difference. And now i have used the function toSec in ROS. And when i calculate the difference in matlab, i have results # 0, meanings "better results". I have read the wiki http://wiki.ros.org/roscpp/Overview/Time , but it doesnt tell or explain exactly what is the difference between using or working with the ros::Time or toSec ? I hope please that you can better lighten it

Thanks!


Originally posted by Sami on ROS Answers with karma: 3 on 2017-01-13

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

ros::Time::now() gives you an actual time stamp as an object. toSec() just converts this into a double represenation in seconds. Subtracting time stamps and calling toSec() on this should work and give you correct results.


Originally posted by dornhege with karma: 31395 on 2017-01-13

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Sami on 2017-01-13:
Thanks for the reply. Thanks. That means, for the evaluation of results in matlab, it is better to use the function toSec() and not to use directly the value of ros::Time::now() (meanings the timestamp value) ?

Comment by Sami on 2017-01-13:
In Matlab,if want to work with timestamp, its better to tranform it using toSec? Is there a difference, if i first,for each time stamp that i receive, use the function toSec and then calculate the difference between values that follow each other, then i publish them or if I do it like you said?

Comment by dornhege on 2017-01-15:
besides double inaccuracies that should give you the same result, i.e., a time difference in seconds. If Matlab can't handle the ros::Time class, then you can use the time stamp in seconds.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.