Home        Store        Docs        Blog

How to get GPS_RTK mavlink message with pymavlink?

Hi, Everyone
To check the time information received from GPS satellites, I want to get information from the GPS_RTK message.
I connected my odroid xu4 and pixhawk with a usb cable and simply wrote the code below.

from pymavlink import mavutil 
import time

connection = mavutil.mavlink_connection('/dev/ttyACM0')
connection.mav.command_long_send(
    connection.target_system,
    connection.target_component,
    mavutil.mavlink.MAV_CMD_SET_MESSAGE_INTERVAL,
    0,
    127, 10000000, 0, 0, 0, 0, 1)
try:
    message = connection.recv_msg().to_dict()
    print message
except Exception as e:
    print(e)
    exit(0)

However, I failed to read the detailed information from the GPS_RTK (# 127) message and the following error occurred.

odroid@odroid:~$ python RTKGPSTest2.py 
{'mavpackettype': 'BAD_DATA', 'reason': u'Bad prefix', 'data': bytearray(b'5')}
odroid@odroid:~$

It didn’t work with the RTK GPS because I executed the code indoors, but I think there is a problem with not getting any data from the pixhawk. Tommorrow, I’m going to install the base station of the RTK GPS outdoors and run the code again, but I want to see what’s wrong before that.

BR,
Hooyeop