dronekit-pythongps-time

How can I get the GPS time from the pixhawk, on a "companion computer"


My project will have two "companion computers" on-board a quadcopter. One will speak to APMCopter autopilot running on a pixhawk, using dronekit python, and the other will communicate with it's peer over ethernet.

I'd like both computers to have closely synchronized time, and I'd like them both to be synchronized to the GPS time from the GPS connected to the pixhawk.

The documentation for mavlink indicates that there is a "system time" message which includes the GPS time in uSec. How do I obtain this data on the companion computer, using DroneKit?


Solution

  • @vehicle.on_message('SYSTEM_TIME')
    def listener(self, name, message):
        print message.time_unix_usec
    

    ArduCopter will send the system time about 4 times per second. This method will run every time.