-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PublishDistanceSensor to Telemetry Server #310
Add PublishDistanceSensor to Telemetry Server #310
Conversation
Maybe that's an opportunity to rename a field 😅. Say
to
So that it doesn't break anyone. For MAVSDK v2 we can even remove |
@JonasVautherin thanks for the review. How does the deprecation work? I.e.
Does the second entry override the first definition because of the same index? So it will only be there for cosmetic reasons? What does proto end up doing with the two entries? Before deciding, I would take a look at the remaining API defined in Proto, and whether it's very uncommon to have centimeters rather than meters. I think many distance sensors output centimeters, because they are often short-ranged. So that might be the more natural unit. But I don't have a strong opinion. |
Oh actually I was thinking about Protobuf, but |
Ah, that's a good argument. If we are going to break it anyway, we might as well make it obvious. I'll make the changes |
As per the discusison in mavlink#310 the existing message struct contains distance measurements specified to be in meters, which is incorrect. Users who are currently accessing this API are receiving the measurements in centimeters.
Ah I missed that when I tested locally:
So we do have to remove the old field names then completely, right? |
Apparently. But in protobuf that would still be backward compatible (somehow I thought it did support aliases). Anyway that's required for Sorry I did not catch it in the review, especially because I wrote it the day before 🤣. As you can see we don't do that very often 😁 (which is arguably a good point for an API 😇 ) |
Come to think of it, I'm not sure it would even break the API if it did work, because then you'd still have two arguments of the same type. So whatever existing apps are passing in their MAVSDK binding would still work without issues I think. What's the right approach to go about this? 😅 If i just rename the variables, users of MAVSDK with an existing app that uses this most likely won't notice. But then again the implementation does not change, so it should not matter at all. Do you agree that we should just rename the variables from |
As per the discusison in mavlink#310 the existing message struct contains distance measurements specified to be in meters, which is incorrect. Users who are currently accessing this API are receiving the measurements in centimeters.
Sorry to join late here but if something is wrong it just needs to be fixed, in my opinion. So the field stays |
All good. I reverted all the changes in this PR related to that bug now that mavlink/MAVSDK#1971 was merged. |
Thank youuu! |
Related PRs
Description
The DistanceSensor is already part of telemetry and telemetry_server. The subscriber was implemented in telemetry, but the publisher in telemetry_server is missing.
I would like to add a publisher for DISTANCE_SENSOR to MAVSDK.
The question is also whether we should include the full message spec while at it. The missing fields that exist in mavlink but not in the proto definition of DistanceSensor are:
Does it make sense to add all of them right away, or does MAVSDK deliberately leave some fields out that exist in mavlink, because they are not used by 99% of the people?
Question
I noticed a bug in the current implementation of the distance sensor subscriber implementation in MAVSDK. The distance fields in mavlink are specified to be centimeters, whereas the same fields in Proto are specified in meters, but there is no conversion happening. I fixed this in the MAVSDK implementation: https://github.com/mavlink/MAVSDK/pull/1964/files#diff-c6be7609c4729a6ca704109572c7b755aaac050cc429c91a024021d7760faf59R1440-R1442
Alternatively we could also change the unit in Proto to centimeters. But this would change the existing API. Changing the implementation though can just as well cause problems to someone who's already using this MAVSDK function 😅
Which option is better?