We are working on a AUV system. Currently i am searching that how can i access to the real-time MAVLink messages. ( I want to access the datas which can seen on QGround’s MAVLink Inspector section). I’m doing researches for a long while and had no results. We are using a Pixhawk2.4.8 and a Jetson Nano.
i am using a depth sensor, how can i access to the current depth values in real time via pymavlink?
how can i access to the AHRS2 values that constantly updating on terminal?
I’ve succeeded to connect with my master computer and succeeded to print "PARAM_VALUES" on terminal, but when i try to change it to "AHRS2" from "PARAM_VALUES" it returns None on terminal.
Note: Terminal returns Null on "AHRS2" whether i arm the vehicle or not.
from pymavlink import mavutil
master = mavutil.mavlink_connection("/dev/ttyACM0", baud=115200)
m = master.recv_match(type = "PARAM_VALUES", blocking = True, timeout = 1)
if m is None:
The Pixhawk will send a small set of vital messages by default, but other messages you’re interested in need to be requested. QGC requests a large set of messages automatically, whereas if you’re connecting directly to the Pixhawk with Pymavlink you’ll need to request those messages yourself. You can request a message to be sent regularly using MAV_CMD_SET_MESSAGE_INTERVAL, which we have a Pymavlink example for here
There’s an alternative implementation here, as part of a broader full program example of controlling a vehicle (requires Python >= 3.8). The code is a bit more involved, but as a result it should be easier/simpler to use.
Thanks for the quick response @EliotBR ,
Yesterday, we implemented the code based on information that you gave me. And we succeded to see the variables that we wanted to see on terminal. I’ll be posting my code here in a few days to help other forum users.
You can use these functions to get any message you want. You just need to rename the message names with the ones you want. Additionally these functions are saving the message outputs to a empty file.
I use your and some other method but it seems like I’m only getting heartbeat and timesync messages. Do you know how can I fix this? I think it’s related to some connection issue but I’m not sure. I can run the same command in my laptop but not in laptop. Baud rates is correct.
Edit: I think it somehow related to my first connection. If I open my laptop/raspberry and directly try to print the mavlink messages I’m only getting the heartbeat. But first if I give some order via that mavlink (such as calling the parameters in mission planner, or arming the motors), I can receive the all mavlink messages.
Should I put some command before the getting the parameters??
As mentioned in my first comment, Control Station Software (like QGroundControl and Mission Planner) will request particular message rates when they connect to the vehicle, so if you open one of those softwares before running your own program then there will be additional messages being streamed because they’ve been requested.
Parameters are not accessed via standard MAVLink streams - they use the Parameter Protocol, which we have a couple of basic pymavlink examples for here.