Manually feeding depth data to autopilot by pymavlink

I’m trying to manually input the depth data from external depth sensor. I’ve tried modifying the code from GPS_INPUT tutorial from, and my code looks running good as it connects the autopilot correctly and no error appears. My code is attached here.

But when I open the Qgoundcontrol and check the data in MAVLink Inspector, the data remains to be unchanged.

How I suppose to do next?

Hi @evantianyn,

SCALED_PRESSURE2 is a message the autopilot sends out to report the status of its second pressure sensor. It’s not possible to just send that to the autopilot to convince it that it’s actually got a depth sensor connected that’s sending those values.

From the available incoming messages that the autopilot handles, you may be able to use GPS_INPUT or VISION_POSITION_ESTIMATE to provide depth values to the autopilot, but it won’t accept temperature inputs - just depth. You’ll likely need to adjust the EK3_SRC1_POSZ parameter to GPS or ExternalNav accordingly, and there may be other parameter changes required as well.

Alternatively if you’re just wanting to see the current depth estimate in the topside then you could send SCALED_PRESSURE2 messages to QGroundControl instead of to the autopilot, but that’s only useful for a visual value when doing manual control - it wouldn’t allow using depth-enabled flight modes (like depth hold).

Hi @EliotBR,

Actually, that’s what i needed at first place, using external depth sensor for depth hold mode. I’ve tried to send GPS_INPUT, but I cannot find the EK3_SRC1_POSZ parameter as mentioned. I’m using ArduSub 4.1.0 and companion 0.0.30. I’ll try again soon and let you updated.

I’m not certain what you mean by this. EKF3 is a new Extended Kalman Filter that’s used in ArduSub 4.1, and if you’re running ArduSub 4.1 you should be able to access the parameters for it via MAVLink (or via the Parameters page in QGroundControl, or the latest BlueOS beta, which both use MAVLink to get the parameters).

If by “cannot find it” you mean you can’t find the documentation for it, it being new means it’s not covered in our old 4.0 documentation (at We’re currently in the process of a documentation transfer to a new system - the ArduSub 4.1 parameters are documented here :slight_smile:

Hi @EliotBR ,

Thanks for the update.

I tried to change some parameters related to ‘POSZ’ from ‘Baro’ to ‘GPS’ last week, but the ‘relative altitude’ remains to be ‘0’. Then I tried to monitor the MavLink messages and found when I send ‘GPS_INPUT’ in pymavlink, the altitude in ‘raw_gps’ changes but the ‘global position’ (not quite sure right now) did not.

I’m on a business trip right now with no Pixhawk nearby. I’ll try again ASAP when I come back. Thanks again.

Does VFR_HUD.alt change? I believe GLOBAL_POSITION_INT messages only change if there’s active and high confidence tracking of the full vehicle position (not just its depth).

I haven’t actually tried simulating just sending depth via GPS messages, so I can’t guarantee it will work, but hopefully it does. If not we can try to investigate further :slight_smile: