I am new to PX4 and mavlink and your help will be much appreciated.
My future architecture will be:
QGC ↔ PX4 ↔ Companion computer
At this moment I am running a simulation:
QGC is connected to PX4
PX4 is run under SITL using “make px4_sitl gz_x500”
I have also established a connection between the companion computer and PX4 using pymavlink.
forwarding is enabled in PX4 - ‘mavlink status’ outputs ‘forwarding on’.
I have noticed that the localhost UDP ports work this way:
QGC - 14550
PX4 - 18570 (talks to QGC), 14580 (talks to companion computer)
Companion computer - 14540
All in all, I have confirmed that the companion computer receives mavlink messages. However, it doesn’t receive “COMMAND_LONG” messages.
I have confirmed that PX4 SITL receives the command messages but does not forward them to the companion computer.
My goal is to be able to receive a notification in the companion computer for when QGC is sending a COMMAND_LONG to take a photo (MAV_CMD_DO_DIGICAM_CONTROL).
Hi,
Just curious to know where are you getting the reference list of Mavlink commands . I have a similar setup done using Pixhawk Orange Px4v1.13.3 _ QGC v4.2.8 RasPi3b+ but I am not seeing a Mavlink reference list for sending commands to the drone !!
COMAND_LONG likely won’t get forwarded because they contain a target_system and target_component field. This means the command long needs to be addressed to the companion computers sysid/compid, otherwise it’ll be dropped at PX4.
I understand that it might be unlikely to be able to receive COMMAND_LONG messages on the companion computer.
Since i haven’t established a real hardware connection (only SITL atm), I wasn’t able to see if PX4 sends mavlink messages regarding the status of the camera (taking a picture, video etc) after the camera receives a command.
I mean that I am not sure what happens after QGC sends a COMMAND_LONG to PX4 and the camera starts acting. Does PX4 publish some extra mavlink messages of camera status afterwards?
If that happens, I could receive the status messages in the companion computer and use them as an indication that a command was sent to the camera.
It all depends on which command and what the target is. QGC will send it to the camera if it has detected a proper MAVLink camera and will send camera commands there.
You can see an example for a MAVLink camera manager here:
I have another related question.
I would like to make the companion computer “disguise” itself as a camera, so it would receive camera COMMAND_LONG messages.
Basically, I made the companion computer send a heartbeat message every second declaring type = MAV_TYPE_CAMERA (sys_id = 01 like PX4).
When sending the HEARTBEAT message straight to QGC, the companion computer receives a COMMAND_LONG message according to the documentation MAV_CMD_REQUEST_CAMERA_INFORMATION (521).
When sending the HEARTBEAT message to PX4, the HEARTBEAT isn’t forwarded to QGC and as a result, there is no COMMAND_LONG message sent towards the companion computer.
I would assume that PX4 would forward the heartbeat of the camera to QGC.
This is the identification process I am trying to mimic:
Why is the heartbeat not forwarded? It should be… That’s the thing to debug first. You should see it appear in the QGC → Analyze Tools → MAVLink inspector.
I have managed to establish forwarding to QGC from the companion computer and to identify the companion computer as a camera.
The companion computer is capable of receiving camera commands now.