How to convert a std::chrono::high_resolution_clock to ros::Time
I like to convert a chrono::high_resolution_clock to ros:Time?
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;
}
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2019-10-24 02:34:08 -0600
Seen: 755 times
Last updated: Oct 24 '19
Position controller in Gazebo for Panda Arm
LGSVL GPS localization / Tf problem ?
rosserial_server wifi connection Raspberry pi ESP8266
Error loading library in executing soss command
Is the pr2_gazebo package released for melodic?
Error "Does your IK Solver support approximate IK ?" Moveit!