Debug Mavlink range finder

I send Mavlink DISTANCE_SENSOR message.
sensorId == 1

RNGFND1_TYPE == 10 (Mavlink)

EK3_SRC1_POSZ == RangeFinder
EK3_SRC2_POSZ == RangeFinder
EK3_SRC3_POSZ == RangeFinder

But it ignores and uses Baro.
The way I send DISTANCE_SENSOR I also send GPS_INPUT and it works.

Thanks

what are you trying to do with it?

Right now I try to fly in my flat but baro is not good enough when used in a room. It works outdoors. But in a room copter by itself change pressurse. I learnt how to parse laser sensor protocol with esp32 and so I like to send data to flight controller. I can send GPS data via Mavlink. GPS works that way but I do not have X and Y for GPS. So I try to send Mavlink DISTANCE_SENSOR. I lack some debugging tools. No idea if packet came, parsed, something failed and it fallbacks to baro. Just no idea what happens.

Have you got the orientation set to 25?

yes and
quaternion is 1 0 0 0
signalQuality = 100
covariance = 255
orientation = 25
sensorId = 0 also tried 1
sensorType = 8
timeBootMs = 0 (also use 0 for GPS)
minDistance = 1,
maxDistance = 5000,
currentDistance = lr.meters * 100,

what flight controller are you using ?

can you show what the its sending on mavlink inspector?

void send_mavlink() {

  //MAVLINK DISTANCE MESSAGE
  int sysid = 1;
  //< The component sending the message.
  int compid = 196;
  uint32_t time_boot_ms = 0;                   /*< Time since system boot*/
  uint16_t min_distance = 5;                   /*< Minimum distance the sensor can measure in centimeters*/
  uint16_t max_distance = 600;                 /*< Maximum distance the sensor can measure in centimeters*/
  uint16_t current_distance = (Distance / 10); /*< Current distance reading*/
  uint8_t type = 0;                            /*< Type from MAV_DISTANCE_SENSOR enum.*/
  uint8_t id = 1;                              /*< Onboard ID of the sensor*/
  uint8_t orientation = 25;                    /*(0=forward, each increment is 45degrees more in clockwise direction), 24 (upwards) or 25 (downwards)*/
  uint8_t covariance = 0;                      /*< Measurement covariance in centimeters, 0 for unknown / invalid readings*/
  float horizontal_fov = 0;
  float vertical_fov = 0;
  uint8_t signal_quality = 0;
  const float quaternion = 0;

  // Initialize the required buffers
  mavlink_message_t msg;
  uint8_t buf[MAVLINK_MAX_PACKET_LEN];

  // Pack the message
  mavlink_msg_distance_sensor_pack(sysid, compid, &msg, time_boot_ms, min_distance, max_distance, current_distance, type, id, orientation, covariance, horizontal_fov, vertical_fov, signal_quality, quaternion);
  // Copy the message to the send buffer
  uint16_t len = mavlink_msg_to_send_buffer(buf, &msg);
  // Send the message (.write sends as bytes)
  //delay(1);
  Serial.write(buf, len);

I use something unnamed from aliexpress. I guess it is some omnibus clone.

Good point for Mavlink Inspector ! It shows data I send


Thank You. May be I should try to fly it,

I expect range finder data to appear in VFR_HUD.

Rangefinder should only be used as EKF source in specific circumstances and if you understand the limitations of such configuration.

I have quite limited understanding.

In other words If I set Range Finder like that and enable AltHold. Will it use range finder?

yes if you leave the EK3 settings alone with baro for altitude, it will use the rangefinder for alt hold if its in orientation 25.

If you set EK3_SRCx_POSZ to 2 any unevenness in terrain will upset the EKF.