Clock/Time Syncronisation

The flight controller and companion computer clocks can be syncronised using MAVLink’s SYSTEM_TIME and TIMESYNC messages. This is important so that each side can blend data from the other side into its EKF.

Mavros Configuration

Mavros’s apm_config.yaml file can be modified to configure the rate of the SYSTEM_TIME and TIMESYNC messages. Below are the recommended settings.

conn:
  timesync_rate: 10.0
  system_time_rate: 1.0

time:
  timesync_mode: MAVLINK

ArduPilot Configuration

The flight controller’s time is set from the GPS by default but this can be modified to be set from the SYSTEM_TIME command by setting RTC_TYPES = 1 (for “MAVLINK_SYSTEM_TIME”)

For Rover or Plane, the SCHED_LOOP_RATE parameter should be increased to 200 because mavros ignores TIMESYNC messages if the round trip time is more than 10ms. It may also be necessary to increase the update rate of the gcs related tasks in the scheduler.

For rover, open APMrover2.cpp and within the scheduler_tasks[] array ensure the gcs entries have their update rate set to 200 like below:

SCHED_TASK(gcs_retry_deferred,    200,    500),
SCHED_TASK(gcs_update,            200,    500),
SCHED_TASK(gcs_data_stream_send,  200,   1000),

After making this change you will need to compile rover and upload the new binary to the flight controller. Hopefully this will not be necessary in future versions of Plane or Rover.

Testing

A MAVLink inspector (available using QGC or MissionPlanner) can be used to check that the system times are syncronised. If using Mission Planner, press Ctrl-F and push the “MAVLink Inspector” button.

../_images/ros-time-sync-testing.png