Home        Store        Docs        Blog

Read GPS values from Pixhawk to Pi

Hello friends,I want to take longitude,altitude,latitude values from Pixhawk and read values utilizing mavlink.I found real all parameter code but I want to take only GPS values,how can ı change this code thanks a lot

from pymavlink import mavutil
import time

# Create the connection
master = mavutil.mavlink_connection('udp:0.0.0.0:14550')
# Wait a heartbeat before sending commands
master.wait_heartbeat()

# Request all parameters
master.mav.param_request_list_send(
    master.target_system, master.target_component
)
while True:
    time.sleep(0.01)
    try:
        message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
        print('name: %s\tvalue: %d' % (message['param_id'].decode("utf-8"), message['param_value']))
    except Exception as e:
        print(e)
        exit(0)

Hi,

Check our pymavlink examples, for GPS information, check the GLOBAL_POSITION_INT, it’ll probably provide what you are looking for.

Thanks a lot, In additionally I have one more question.Can I use mavlink codes(for example send rc override) in Navio 2 instead of Pixhawk