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 -0600
Seen: 2,139 times
Last updated: Oct 24 '19
navsat_transform_node without IMU
Use simulated time with some nodes while running other nodes with wall time
How to subscribe to an OccupancyGrid map and publish a converted array from it? [closed]
How to code user inputs and print messages?
Setting output file name for the ROS video recorder