Servers by jDrones

Cannot receive DISTANCE_SENSOR ( #132 ) [solved]

The communication is between Arduino and SITL ArduPlane (ArduPlane V4.1.0dev).

mavlink_msg_request_data_stream_pack(2, 0, &msg, 1, 1, MAVStreams[i], MAVRates[i], 1);
I am able to receive various messages, however, for MAV_DATA_STREAM_ALL (0), only 13 parameters appear.

If I use
mavlink_msg_command_long_pack(2, 0, &msg, 1, 1, 511, 0, 27, 100000, 0,0,0,0,2);
instead of
mavlink_msg_request_data_stream_pack(2, 0, &msg, 1, 1, MAVStreams[i], MAVRates[i], 1);
I am able to receive selectively the messages but only one of those that are sent with the stream anyway.

However, if I request any data not already received in the stream pack (as far as I know, #132 should be included in SRx_EXTRA3, but I am unable to receive it in any way), such as
mavlink_msg_command_long_pack(2, 0, &msg, 1, 1, 511, 0, 132, 100000, 0,0,0,0,2);
I do not receive this data.

From what I’ve gathered so far, it seems certain messages may not be supported by Ardupilot?

Thank you and excuse my noobieness (noobiedity?).

Some messages are not supported by ardupilot. But AFAIK DISTANCE_SENSOR is supported. Are you using master from today?

Mission Planner says: ArduPlane V4.1.0dev (7672f0a2)

However only V4.0.7 seems to be on
V4.0.7 is also on

So it seems, there is a hole in my understanding.

V4.1.0 is an alias than changes multiple times per day. My question was, how old is your V4.1.0?
Do you understand that you can get a newer V4.1.0 now?

Well, that’s an interesting choice of versioning system. I assume any new instance of Mission Planner SITL is the newest version (don’t know how to be sure, since… you know… V4.1.0)?
If so, I have the newest version.

It is a developer-only version, hence the V4.1.0-dev. It will later become V4.1.0-betaX then V4.1.0-rcX and in the very end it will loose the suffixes and become V4.1.0 to be followed by the V4.1.1

This is a normal and common versioning scheme. I assumed you to be a developer, so I assumed you knew that.

Back to the issue. My guess is that that particular message either needs a gazebo environment, or it is not simulated in SITL. Can you test with a real vehicle?

No, you are right, I am just a little frustrated by the fact I cannot find the V4.1.0-dev anywhere.

I will try with a real vehicle. It’s a shame though. I would rather try my logic in a simulated environment.
Also, what’s the difference between GCS and Arduino anyway? Shouldn’t I be able to receive all the messages that GCS receives?

Thank you for your help, by the way. Much appreciated.

There is no difference between arduino and GCS from a Ardupilot FW point of view.

You can expand the simulation environment to include the lidar simulation. We did that for some cameras.

Well, rangefinder in Mission Planner does work.
In MAVLink inspector in Mission Planner, there are transmitted messages of “distance sensor”, even containing the values. (I guess this is GCS communication, not Arduino).
It’s just that in Arduino, I can’t even receive distance sensor parameter (#132).
Also, I believe I couldn’t receive many more messages, I didn’t try though (the communication works per se, I can receive certain messages).

Are you sure you have enough bitrate available in the arduino? What baudrate are you using? How much of that is used? How much of that is available?

I can easily receive message #27.
I cannot receive any #132 message in any rate.
Baudrate 57600.
Also, the messages I can receive are always the same.

So low bandwidth doesn’t seem to me to be the issue.

My guess is that the mavlink version that you are using in the arduino is too old, does not recognize the #132, and discards it.

Please update your arduino mavlink library. Mission Planner has an updated mavlink library and #132 is relatively new.

I am using the latest Mavlink V1, so… it’s possible, I guess?

How can I know if this is caused by the version?
By the presence of “mavlink_msg_distance_sensor.h” file in the library, I assume it should be able to handle this message?

There are multiple versions of that same message. If the version does not match it will not work

EDIT: NEVERMIND, I was mistaken and was not using the version I have thought (by the time of writing the response below). With correct version AND enabled all streams (and set up range finder), I can receive #132 as I wanted. Will add more info soon.

Original post:

I have updated to the newest version of V2 mavlink and the problem still persists.

I seem to be able to get all messages that I can get with
MAV_DATA_STREAM_ALL=0, // Enable all data streams
mavlink_msg_request_data_stream_pack(2, 0, &msg, 1, 1, MAVStreams[i], MAVRates[i], 1);

30 attitude
33 global position int
1 sys status
62 nav controller output
42 mission current
74 vfr hud
36 servo output raw
35 rc channels raw
27 raw imu
29 scaled pressure
24 gps raw int
2 system time
32 local position ned

mavlink_msg_command_long_pack(2, 0, &msg, 1, 1, 511, 0, 62, 142575, 0,0,0,0,1);

But I cannot get any other.

At this point, I really don’t know what to try. But I am a noob, maybe there is something trivial. Again, thank you for your help.

OK, confirmed. With the newest version, it does work.
It is however needed to set the appropriate stream and set up the distance sensor so it is even transceived.

Servers by jDrones