Converting ros::Time to boost ptime with nanosecond resolution

asked 2018-12-04 09:55:25 -0500

Ander gravatar image

Hi,

I wanted to convert ros::Time to boost ptime and found this answer: https://answers.ros.org/question/2519...

It works fine, but the fact is that by default the output has microsecond level resolution. According to Boost documentation, the variable BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG must be defined in the library users project files (ie Makefile, Jamfile, etc). https://www.boost.org/doc/libs/1_58_0...

I added the following line to my CMakeLists.txt:

add_definitions(-DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)

After adding this variable, the call to the method toBoost() fails. I get this error:

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::gregorian::bad_year> >'
what():  Year is out of valid range: 1400..10000
Aborted (core dumped)

Any help is appreciated,

Thank you

edit retag flag offensive close merge delete