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

Converting ros::Time to plain data structure

asked 2019-01-24 09:45:48 -0500

debonair gravatar image

updated 2019-01-24 10:10:18 -0500

ros::time is derived from Time and Time class has 2 members uint32 sec, nsec. If I have ros::time, how do I store it into plain structure where i just have 2 uint32 fields. ros::time has toSec() and toNSec(), but neither of which returns uint32. How do I convert ros::time to

Message time {
  uint32 sec, nsec;
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-01-24 10:10:50 -0500

VictorLamoine gravatar image

sec and nsec are public members of the ros::Time class:

  struct Time {
    uint32_t sec;
    uint32_t nsec;

  Time t2;
  ros::Time t1;
  t2.sec = t1.sec;
  t2.nsec = t1.nsec;
edit flag offensive delete link more

Question Tools


Asked: 2019-01-24 09:45:48 -0500

Seen: 375 times

Last updated: Jan 24 '19