[ros-users] ros::time to boost::posix_time::ptime
Lorenz Mösenlechner
moesenle at in.tum.de
Mon Jan 23 15:32:22 UTC 2012
Hi,
according to the API docs, there is already a function to convert from
ros::Time to boost. The function is called toBoost, docs can be found here:
http://ros.org/doc/electric/api/rostime/html/classros_1_1TimeBase.html
Lorenz
On Mon, Jan 23, 2012 at 4:26 PM, Markus Bader <markus.bader at tuwien.ac.at>wrote:
> Hi
>
> ROS is using many boost libs, but has his own time/duration/.. implentation
> Would it be possible to add at least a convertion funtion to the boost
> time classes
>
> like:
>
> boost::posix_time::ptime rostime2ptime_utc(const ros::Time &t) {
> using namespace boost::posix_time;
> typedef boost::date_time::subsecond_duration<time_duration,1000000000>
> nanoseconds;
> boost::gregorian::date d(1970, boost::gregorian::Jan, 1);
> ptime t_utc(d, seconds(t.sec) + nanoseconds(t.nsec));
> return t_utc;
> }
>
> boost::posix_time::ptime rostime2ptime_local(const ros::Time &t) {
> using namespace boost::posix_time;
> ptime t_utc = rostime2ptime_utc(t);
> ptime t_local =
> boost::date_time::c_local_adjustor<ptime>::utc_to_local(t_utc);
> return t_local;
> }
>
> Greetings
> Markus
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
>
--
Lorenz Mösenlechner | moesenle at in.tum.de
Technische Universität München | Karlstraße 45
80335 München | Germany
http://ias.cs.tum.edu/ | Tel: +49 (89) 289-26910
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20120123/61cf2d63/attachment-0004.html>
More information about the ros-users
mailing list