Home        Store        Learn        Blog

Information extraction on the Raspberry Pi stops automatically

Hi, i run the script that can extract information on pi, if the code master.recv_match(type=‘ATTITUDE’, blocking=True).to_dict() has * type=‘ATTITUDE’, blocking=True*, then the code will stop after running for seconds.
If i delet type=‘ATTITUDE’, blocking=True,the code can run.
The following is picture and code.The script just stops there like this.Who can tell me what is wrong?
I will be thankful.

att.txt (786 Bytes)

Yes, port 9000 is set up in mavproxy as a udp input, which is useful for things like sending a sensor reading to it for it to pass to the autopilot or up to QGC. If you want to get readings from it repeatedly then you’ll need to send it regular updates, e.g.

import time
import math
from pymavlink import mavutil

def wait_conn():
    Sends a ping to stabilish the UDP communication and awaits for a response
    msg = None
    while not msg:
            int(time.time() * 1e6),
            0, # Request ping of all systems
            0 # Request ping of all components
        msg = master.recv_match()

def send_heartbeat():
    Sends a heartbeat message to continue getting telemetry updates.
        mavutil.mavlink.MAV_TYPE_ANTENNA_TRACKER, # something that just listens
        mavutil.mavlink.MAV_AUTOPILOT_INVALID, # not an autopilot
        0, 0, 0

def get_attitude(timeout=0.1):
    return master.recv_match(type='ATTITUDE', blocking=True, timeout=timeout)

master = mavutil.mavlink_connection('udpout:')
print("connection successful")

while True:
    # get the latest attitude data
    message = get_attitude()
    while message is None:
        message = get_attitude()
    message = message.to_dict()
    # do something with it
    print("{:>5} -- pitch:{:.1f}, roll:{:.1f}, yaw:{:.1f}, pitchspeed:{:.3f}, rollspeed:{:.3f}, yawspeed:{:.3f}".format(
    # track progress
    t += 1

Well,thank you. I think the help of pymavlink should be updated.II spent a lot of time on this page .

We added several updates recently, so hopefully it was a bit easier to use than it has been previously. Is there anything in particular you’d like to see added? :slight_smile:

So you’re aware, the example I just sent you wasn’t just lying around - I just spent the time to figure out how to solve your issue, write the code for it, and test it to make sure it was working.


The code can run well. Thanks for your help. I have no problem at the moment.