How to convert a std::chrono::high_resolution_clock to ros::Time
I like to convert a chrono::high_resolution_clock to ros:Time?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
I like to convert a chrono::high_resolution_clock to ros:Time?
Hi ros::Time are sec and nsec since epoch
#include <iostream>
#include <chrono>
#include <ctime>
#include <ros/ros.h>
int main()
{
const auto p0 = std::chrono::time_point<std::chrono::high_resolution_clock>{};
const auto p3 = std::chrono::high_resolution_clock::now();
auto tstamp = p3 - p0;
int32_t sec = std::chrono::duration_cast<std::chrono::seconds>(tstamp).count();
int32_t nsec = std::chrono::duration_cast<std::chrono::nanoseconds>(tstamp).count() % 1000000000UL;
std::cout << "sec: " << sec << " nsec: " << nsec << " since epoch: \n";
ros::Time n(sec, nsec);
return 0;
}
Asked: 2019-10-24 02:34:08 -0500
Seen: 2,323 times
Last updated: Oct 24 '19
Converting realsense 2d image pixel into world's XYZ
How to load a map(.png) to ros and make an occupancy grid?
Problem with roslaunch on rc.local startup
error while launching lslidar_c16
How to install my Python modules as part of my ROS package
TF_REPEATED_DATA error with robot_localization ukf package
Movit unable to generate configuration files