Time Sync Pixhawk 4 and Raspberry Pi Zero

Hey everyone, I am new to the forum but have been using existing posts and the Ardupilot documentation for a while now and it has proven to be very useful. Myself and a few friends are working on a custom drone project using a Marvelmind indoor positioning system to fly the drone indoors, hooked up to the Pixhawk 4 GPS port, and using a raspberry pi zero w, hooked up to the Pixhawk 4 Telem 1 port, to scan the temperature across a room with a heat source in the middle. The goal is to produce a temperature map of the room. I have the pi and the Pixhawk communicating to each other.

The pi is getting all of the Pixhawk data live with no problems, and can command the Pixhawk just fine (like toggling flight modes, reboot, etc). I am able to fly the drone indoors and get an accurate Lat/Long position of the drone. When pulling a flight log, I can see its flight path and any other parameters that the pixhawk data logs show. I also have a log from the raspberry pi which gives me temperature values at various time intervals at a fixed refresh rate. The trouble is I have these 2 separate logs, and no way of syncing them so that the temperature is linked to a point XYZ. I know the pixhawk uses what is called GPS time, based off of seconds since the last epoch. The pi’s time stamp does this as well, and when putting the pi’s time values into an epoch to real world time calculator, time and date is 100% accurate. My trouble is, I can get the pi to have accurate epoch time, however, in the logs of the pixhawk, the epoch time it gives is always some time long in the past, like in 1974. Ardupilot has very little documentation on using the TIMESYNC and SYSTEM_TIME functions, (located here https://ardupilot.org/dev/docs/ros-timesync.html) and I have tried to implement them both to get the raspberry pi to send its accurate time to the pixhawk, so that that pixhawk time matches the pi’s time. Neither of these seem to change the time of the pixhawk that is stored in the flight logs.

Does anyone have any documentation or useful information for getting the time of the two synced together somehow? This is the last hurdle of the project to getting a temperature map and we haven’t found a solution yet. We have tried using the “time sync” button on the Marvelmind software which should send accurate time data to the Pixhawk. This works for updating the time stamps on the pixhawk’s data log file names, but does not change the internal time logged in the Pixhawk. Even so, the time stamps on the data log file names are 3 days behind for some reason (we were testing on 4/12/20 at 2pm, and the time stamps of the log file names said it was 4/9/20 at 9am). Please let me know. Thanks!

take a look at apsync. AFAIK it handles this synchronization using ROS as well

Hello, you can look in ardupilot github closed PR related to the timesync implementation, you will find very valuable information in the discussion between programmers, mainly @peterbarker and @tridge

Thank you for the tip! I found some useful posts, specifically this one

It seems like TIMESYNC should be our solution. We tried this thoroughly on Sunday but were not getting any messages back from the Pixhawk like suggested in the thread above and thought that this was not our solution. Seems like there is some troubleshooting to be done on our end with the TIMESYNC functionality then. Wish there was some more documentation on troubleshooting it but will do our best. Thank you!

1 Like