Converting ros::Time to C++ string
How can we convert the result of ros::Time::now()
into std::string
, given that std::string to_string (*)
in C++11 doesn't support this conversion ?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
How can we convert the result of ros::Time::now()
into std::string
, given that std::string to_string (*)
in C++11 doesn't support this conversion ?
You probably want to use the ros::Time::now().toSec()
result, which is a double.
http://docs.ros.org/latest/api/rostim...
Then you can convert that double to a string with std::string to_string
.
You could use strftime
to convert the double to many different string formats as well.
Asked: 2019-11-07 20:33:26 -0600
Seen: 4,688 times
Last updated: Nov 07 '19
Answer to convert to a formatted date time string using
boost::posix_time::to_iso_extended_string
#q251966