# Timestamp Syncronization with Offboard Control

**URL:** <https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259>\
**Category:** PX4 Autopilot\
**Created:** [September 20, 2016, 5:23pm UTC](https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259 "2016-09-20T17:23:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonbeach](https://discuss.px4.io/user_avatar/discuss.px4.io/jasonbeach/32/4901_2.png) [@jasonbeach](https://discuss.px4.io/u/jasonbeach)\
**Post date:** [September 20, 2016, 5:23pm UTC](https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259/1 "2016-09-20T17:23:45Z")

</div>

Is it possible to syncronize the clocks of the Pixhawk and an offboard computer (using Pixhawk as primary since it’s connected to GPS)? Right now I’m using Copter firmware and have to perform an IMU sync event to line up data from the pixhawk and that generated by the offboard computer (Jetson TK1). I am considering moving to the PX4 flight stack for a number of reasons and I’m curious if this issue could possibly be resolved as well.  
Thanks

---

<div class="post-metadata">

**Author:** ![tommises](https://discuss.px4.io/letter_avatar_proxy/v4/letter/t/d2c977/32.png) [@tommises](https://discuss.px4.io/u/tommises)\
**Post date:** [September 22, 2016, 7:22pm UTC](https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259/2 "2016-09-22T19:22:12Z")

</div>

You need to run [mavros](http://wiki.ros.org/mavros), which is a part of ROS, on your companion computer. Synchronization is handled by [sys\_time plugin](http://wiki.ros.org/mavros#mavros.2BAC8-Plugins.sys_time) and works well.

---

<div class="post-metadata">

**Author:** ![jasonbeach](https://discuss.px4.io/user_avatar/discuss.px4.io/jasonbeach/32/4901_2.png) [@jasonbeach](https://discuss.px4.io/u/jasonbeach)\
**Post date:** [September 23, 2016, 2:43am UTC](https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259/3 "2016-09-23T02:43:40Z")

</div>

Is that the only way? There are a couple reasons I do not want to use mavros.

---

<div class="post-metadata">

**Author:** ![jasonbeach](https://discuss.px4.io/user_avatar/discuss.px4.io/jasonbeach/32/4901_2.png) [@jasonbeach](https://discuss.px4.io/u/jasonbeach)\
**Post date:** [September 28, 2016, 3:36pm UTC](https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259/4 "2016-09-28T15:36:35Z")

</div>

So I dug into the sys\_time plugin to see what it’s doing and it’s actually pretty simple. It uses the mavlink TIMESYNC message to calculate round trip time and offset (essentially what PTP does, but without transparent clocks, etc). So good info @tommises. Thanks!

---

<div class="post-metadata">

**Author:** ![ajmal](https://discuss.px4.io/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@ajmal](https://discuss.px4.io/u/ajmal)\
**Post date:** [February 18, 2017, 12:58am UTC](https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259/5 "2017-02-18T00:58:29Z")

</div>

How do I use sys\_time plugin? I did not find any reference for it. I am using Ubuntu 16.04 and ROS kinetic installed from Repository with PX4 firmware. Any help will be appreciated

---

<div class="post-metadata">

**Author:** ![tomatac](https://discuss.px4.io/letter_avatar_proxy/v4/letter/t/8dc957/32.png) [@tomatac](https://discuss.px4.io/u/tomatac)\
**Post date:** [May 2, 2017, 7:58pm UTC](https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259/6 "2017-05-02T19:58:18Z")

</div>

How do you synchronize the timestamp?  
I have mavros broadcast a tf by changing the in “px4\_config.yaml” local\_position: send: false-\>true  
The issue is that the timestamp is wrong.  
How can I change the time\_ref\_source in mavros for SITL and companion computer?  
By default time\_ref\_source: “fcu” in “px4\_config.yaml”.  
Should I use localhost / IP?

---

<div class="post-metadata">

**Author:** ![toopazo](https://discuss.px4.io/user_avatar/discuss.px4.io/toopazo/32/3544_2.png) [@toopazo](https://discuss.px4.io/u/toopazo)\
**Post date:** [October 5, 2017, 6:46pm UTC](https://discuss.px4.io/t/timestamp-syncronization-with-offboard-control/1259/7 "2017-10-05T18:46:06Z")

</div>

I was getting “[lpe] mocap timeout” messages all the time  
What I did to fix that was to re-stamp every message received from Vicon (in my case) before forwarding those to PX4 (using mavros)

msg is of type “geometry\_msgs.msg.TransformStamped”  
Then I re-stamped every message using the time of the companion PC (Odroid, Raspberry, etc…)

msg\_nwu.header.stamp = rospy.Time.now()
