Ask Your Question

Converting ros::Time to C++ string

asked 2019-11-07 20:33:26 -0600

zlg9 gravatar image

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 ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-11-07 21:31:38 -0600

Thomas D gravatar image

You probably want to use the ros::Time::now().toSec() result, which is a double.

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.

edit flag offensive delete link more


Yes, that's what I needed. Thanks

zlg9 gravatar imagezlg9 ( 2019-11-08 13:00:02 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-11-07 20:33:26 -0600

Seen: 13 times

Last updated: Nov 07