converting ros::time to boost ptime: "Year is out of valid range" error

asked 2018-03-26 04:50:29 -0600

Toothless gravatar image

updated 2018-03-26 06:16:42 -0600

Hi there, I am new to the ROS and its community. I am looking for a function that can convert the ROS time to the boost::posix_time::ptime. Does anybody know about such function? I found an answer here, https://answers.ros.org/question/2519... which is close to what I am looking for. However, when I use this .toBoost() function, an exception is thrown, " Year is out of valid range: 1400..100000". Also, I couldn't find the function .toBoost() in ros:Time class reference.

If anybody knows about such function then please let me know. Any suggestions/remarks are most welcomed! [edit 1] : example: ROS timestamp(1520004209.448167176) to boost time --> results into the error.

Thank you very much,

edit retag flag offensive close merge delete

Comments

" Year is out of valid range: 1400..100000"

that would seem to suggest something is wrong with your timestamps. Can you add some examples of stamps you try to convert to your question text? Use the edit button/link.

gvdhoorn gravatar imagegvdhoorn ( 2018-03-26 05:17:46 -0600 )edit

I've updated your question title, as there is a known conversion (#q251966) but you're encountering errors trying to use it. That would seem to be the real problem here.

gvdhoorn gravatar imagegvdhoorn ( 2018-03-26 05:27:19 -0600 )edit

The code is here. If you duplicate that and see what is being passed to the boost::posix_time::ptime::from_time_t(..) and nanoseconds(..) function?

gvdhoorn gravatar imagegvdhoorn ( 2018-03-26 06:38:09 -0600 )edit

Thank you gvdhoorn for the link. It is very useful.

Toothless gravatar imageToothless ( 2018-03-29 01:51:16 -0600 )edit

Have you figured out what's going wrong with your conversion?

gvdhoorn gravatar imagegvdhoorn ( 2018-03-29 01:52:53 -0600 )edit

In the code, a random string was passed to this function which might be the reason for this error. However, I didn't test it as I removed the need of this conversion from the code base.

Toothless gravatar imageToothless ( 2018-03-29 01:57:47 -0600 )edit