Converting ros::Time to boost ptime with nanosecond resolution

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

Ander gravatar image


I wanted to convert ros::Time to boost ptime and found this answer:

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).

I added the following line to my CMakeLists.txt:


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