Time syncronisation mechanisms in BlueOs

Hi, I’m wondering if anyone can provide some information about the mechanisms used by BlueOs to synchronise the system time? We have a custom USV running BlueOs on a raspberry pi 4 as a companion to a pixhawk 6c running ardupilot rover. The pixhawk has gps/compass module connected for global position. In the field we do not have any internet connection so the pi cannot synchronize time via ntp. It seems that we should be able to synchronise time via the gnss connection however it is unclear as to whether there is mechanism to do this automatically exists. I’ve found a couple of forum threads discussing similar issues (although with slightly different hardware) but they contain conflicting information. Does this mechanism exists? Or does BlueOs use any other methods to sychronise the time such as checking the ground station computer via the browser? If so, how can we monitor if/when they are triggered. If not they we may consider writing a small utility plugin to monitor for gnss messages via mavlink2rest to set the system time and/or integrating an RTC. Thanks

Hi @hbt -
Welcome to the forums!
The BRD_RTC_TYPES parameter controls where BlueOS is pulling time-sync from. If you open the BlueOS web interface in a browser window, it will sync to the computer you’re using’s time. Otherwise, it gets time either from GPS (if checked.)

I don’t think it’s possible to “monitor” - it just happens!

Hi @tony-white, thanks for your reply!

I can see that we have only GPS selected for this parameter. Although is this not an autopilot parameter and would therefore be configuring the board time on the pixhawk? I can see from our telemetry logs (tlogs) that the ardupilot time syncs with gps when we get a connections. I’m more concerned with how the system time on the pi gets synchronised. Should this update when there is accurate time available in the mavlink messages from the pixhawk? Thanks

Hi @hbt, welcome to the forum! :slight_smile:

If I’m understanding correctly, BlueOS does this when the interface loads, and has an API endpoint (/set_time) that allows setting it yourself if you want to, although it is apparently set up to reject changes that are within 5 minutes of its current time.

The use of that endpoint should appear in the system logs of the commander service.

I agree that in the presence of an autopilot with an accurate time source (e.g. a GNSS connection) it makes sense to sync to that, especially in the absence of the BlueOS frontend getting loaded (since users do not always have reason to do so). You are welcome to raise an issue to that effect (or better yet, a pull request) - presumably it should see if there is are any SYSTEM_TIME MAVLink messages in the stream, and if not request one, then if the calculated time (time in message + time since message) is more recent than the onboard computer’s time it should try to update itself using that time with the set_time API.

There is some confusion around determining if a system has more accurate time, but my understanding from the preceding discussion is that later time is broadly considered to be more accurate (perhaps especially if there is a substantial difference). You could also specifically try to check for a GPS connection if you want, but that may miss out on alternative time sources (including, for example, the autopilot’s time being updated by a GCS).

Hi @EliotBR, thank you for your response! I’ve had a look into the source code and can see that the /set_time endpoint does indeed set the system time on the pi. I can also see from the frontend code that this endpoint is called on page load.

Regarding accurate time sources it does seem to make sense that monitoring and syncing to SYSTEM_TIME messages would be a useful feature in blueos. Especially for our ‘no internet connection’ use case. I’ve found a couple of useful pages regarding this. In the ardupilot docs it does suggest that it is appropriate to synchronise a companion computer to the autopilot using SYSTEM_TIME and TIMESYNCmesages. Time Synchronization Protocol v2 | MAVLink Guide

Also, this page describes how to sync the system clocks using the round trip time of TIMESYNC messages.

I plan to raise an issue to this effect. I’d be happy to work on a pull request but am not familiar enough with the code base currently to know where the appropriate place to implement this behavior is.

1 Like