Ask Your Question

Converting ros::time to double value without uint_t

asked 2016-02-18 05:39:07 -0500

user23fj239 gravatar image

I had a look at the ros::durationBase and it has functions toSec toNsec to convert the following into one int64_t which would exceed a double in c++;

int32_t     nsec
int32_t     sec
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-02-18 06:24:41 -0500

mgruhler gravatar image

Both, ros::durationBase (API Doc) as well as ros::timeBase (API Doc) contain the respective toSec() functions which return a double. What you did is not required!

edit flag offensive delete link more


So this is also ok? ( I could not get it to run with the function first)

double h_time = h.stamp.toSec();
user23fj239 gravatar image user23fj239  ( 2016-02-18 08:35:37 -0500 )edit

answered 2016-02-18 05:39:21 -0500

user23fj239 gravatar image

So I did this:

    double h_time = double(h.stamp.sec) + double(h.stamp.nsec)*1e-9;

Basically the same what the function does: 00093 double toSec() const { return (double)sec + 1e-9*(double)nsec; };

edit flag offensive delete link more



So what is exactly your question here?

gvdhoorn gravatar image gvdhoorn  ( 2016-02-18 05:45:46 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-02-18 05:39:07 -0500

Seen: 11,104 times

Last updated: Feb 18 '16