Re: [ros-users] ros::time to boost::posix_time::ptime

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
Delete this message
Reply to this message
Author: User discussions
Date:  
To: User discussions
Subject: Re: [ros-users] ros::time to boost::posix_time::ptime
There is already a ROS Time to Boost time function, don't know if there is
one for the other direction:

http://ros.org/doc/electric/api/rostime/html/impl_2time_8h_source.html#l00161

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
William Woodall
Graduate Software Engineering
Auburn University


williamjwoodall.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



On Mon, Jan 23, 2012 at 9:26 AM, Markus Bader <>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
>
> https://code.ros.org/mailman/listinfo/ros-users
>