Sending altitude/distance sensor via MAVlink

#1

Hi all,
I’d like to send altitude or distance sensor information from an external computer (companion) to the autopilot via MAVlink. Is it possible?

I explain better.
Scenario 1: I have a range sensor not directly integrated with PX4 but which can publish mavlink messages “DISTANCE_SENSOR” (it can send any MAVlink message actually). Will the onboard mavlink read the message and use it as distance sensor or should I modify the code?

Scenario 2: I have an external estimation of altitude/altitude from terrain. Can I send a MAVlink message to the autopilot which overrides the actual altitude, or which use the data in the EKF2?

#2

From mavlink_receiver.cpp it seems that the distance_sensor message is handled and published on uorb so Scenario 1 should be ok.

FIK the code which handles the message in mavlink_receiver.cpp: https://github.com/PX4/Firmware/blob/master/src/modules/mavlink/mavlink_receiver.cpp#L818-L845

#3

Hi, @tuloski! Did you get it working?

I am trying to do exactly the same thing. We have Arduino connected to Pixhawk 2. Arduino is reading ultrasonic sensor information and we want to send this over MAVLink to Pixhawk 2 as distance sensor information.

Do you also know how many distance sensors PX4 supports by default?
How can I add more?