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’s sys_time plugin implements the mavros/ROS side
- ArduPilot’s AP_RTC library implements the ArduPilot side
conn: timesync_rate: 10.0 system_time_rate: 1.0 time: timesync_mode: MAVLINK
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.
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.