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

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
3

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

Comments

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
0

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

Comments

1

So what is exactly your question here?

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

Question Tools

1 follower

Stats

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

Seen: 15,579 times

Last updated: Feb 18 '16