# MAVROS Time Sync issues with SITL Gazebo LockStep

**URL:** <https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978>\
**Category:** ROS 1 / ROS 2\
**Created:** [June 2, 2020, 10:53pm UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978 "2020-06-02T22:53:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexandreBorowczyk](https://discuss.px4.io/user_avatar/discuss.px4.io/alexandreborowczyk/32/12383_2.png) [@AlexandreBorowczyk](https://discuss.px4.io/u/AlexandreBorowczyk)\
**Post date:** [June 2, 2020, 10:53pm UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978/1 "2020-06-02T22:53:25Z")

</div>

I’m currently testing my system using the standard SITL Gazebo simulation. The simulation is set to run realtime but sometimes lags a bit due to system load. Eventually it create sync reset between MAVROS and Px4. Is there anyway of fixing times?

---

<div class="post-metadata">

**Author:** ![JulianOes](https://discuss.px4.io/user_avatar/discuss.px4.io/julianoes/32/30_2.png) [@JulianOes](https://discuss.px4.io/u/JulianOes)\
**Post date:** [June 4, 2020, 1:24pm UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978/2 "2020-06-04T13:24:36Z")

</div>

One way would be to disable locktep [https://dev.px4.io/master/en/simulation/index.html#disable-lockstep-simulation](https://dev.px4.io/master/en/simulation/index.html#disable-lockstep-simulation)

I don’t see how you can stay in sync with something that is not running in sync with time 🤔

---

<div class="post-metadata">

**Author:** ![Georacer-avy](https://discuss.px4.io/user_avatar/discuss.px4.io/georacer-avy/32/6923_2.png) [@Georacer-avy](https://discuss.px4.io/u/Georacer-avy)\
**Post date:** [June 5, 2020, 7:46am UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978/3 "2020-06-05T07:46:27Z")

</div>

> [@JulianOes](#):
>
> I don’t see how you can stay in sync with something that is not running in sync with time

Isn’t the whole point of lockstep in SITL to provide a fixed timestep and deterministic evolution during variable system loads and comms?

---

<div class="post-metadata">

**Author:** ![JulianOes](https://discuss.px4.io/user_avatar/discuss.px4.io/julianoes/32/30_2.png) [@JulianOes](https://discuss.px4.io/u/JulianOes)\
**Post date:** [June 5, 2020, 9:16am UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978/4 "2020-06-05T09:16:46Z")

</div>

Right but the MAVROS or rather the time it is working on is not part of that lockstep. So yes it should be as deterministic as possible internally but when it comes to the outside world like MAVROS that’s hard to do.

---

<div class="post-metadata">

**Author:** ![Georacer-avy](https://discuss.px4.io/user_avatar/discuss.px4.io/georacer-avy/32/6923_2.png) [@Georacer-avy](https://discuss.px4.io/u/Georacer-avy)\
**Post date:** [June 5, 2020, 9:31am UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978/5 "2020-06-05T09:31:26Z")

</div>

Hm… I’m not aware of MAVROS internals. Perhaps it doesn’t use the simulated clock (published by Gazebo) and uses the wallclock instead, in which case it could drift from the sim clock, yes.

---

<div class="post-metadata">

**Author:** ![JulianOes](https://discuss.px4.io/user_avatar/discuss.px4.io/julianoes/32/30_2.png) [@JulianOes](https://discuss.px4.io/u/JulianOes)\
**Post date:** [June 8, 2020, 8:01am UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978/6 "2020-06-08T08:01:06Z")

</div>

> [@Georacer-avy](#):
>
> Perhaps it doesn’t use the simulated clock (published by Gazebo) and uses the wallclock instead

Right, that seems plausible.

---

<div class="post-metadata">

**Author:** ![AlexandreBorowczyk](https://discuss.px4.io/user_avatar/discuss.px4.io/alexandreborowczyk/32/12383_2.png) [@AlexandreBorowczyk](https://discuss.px4.io/u/AlexandreBorowczyk)\
**Post date:** [June 8, 2020, 4:00pm UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978/7 "2020-06-08T16:00:47Z")

</div>

In fact, I guess I was wondering if you setup ROS to use the simulated time would work with MAVROS.

---

<div class="post-metadata">

**Author:** ![JulianOes](https://discuss.px4.io/user_avatar/discuss.px4.io/julianoes/32/30_2.png) [@JulianOes](https://discuss.px4.io/u/JulianOes)\
**Post date:** [June 9, 2020, 5:44am UTC](https://discuss.px4.io/t/mavros-time-sync-issues-with-sitl-gazebo-lockstep/16978/8 "2020-06-09T05:44:45Z")

</div>

I have not tried that, no.

Maybe @mhkabir has?
