Skip to content
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 multiplier value for GPS_STATUS.satellite_azimuth where 255 means 360deg #885

Merged
merged 1 commit into from
May 27, 2024

Conversation

shancock884
Copy link
Contributor

Relates to mavlink/mavlink#2062, point 2.

2/ Satellite Azimuth unit doesn't consider scale factor
The satellite_azimuth field of the GPS_STATUS message has a unit of "deg", but the description says "0: 0 deg, 255: 360 deg".
To be consistent with other units, and allow automatic value decoding, I would propose that a specific unit is used here too.
e.g. "degS8" (meaning "Degree Scaled to 8 bit integer"), or "deg/360*255" or any sensible simplification thereof.
I would also question if 255 is really supposed to be 360deg - as this means a value of 0 and 255 represents the same angle.
Perhaps what was intended is that 255 represents 360-(360/256) = 358.59375 ?

This PR adds the "degS8" unit, and an associated comment to the mavschema.xsd file.

The description specifies that 255 represents 360 deg, therefore multiplier is 360/255
@shancock884 shancock884 changed the title Add degS8 unit for degrees scaled to fit in 8-bit integer Add multiplier value for GPS_STATUS.satellite_azimuth where 255 means 360deg May 1, 2024
@shancock884
Copy link
Contributor Author

Following merging of #894, this now proposes to add a multiplier value of 360/255 to be used by satellite_azimuth, rather than create a new not-a-real-unit.
I specified this literally as "360/255" rather than a value to be more accurate and readable, but happy to change if it doesn't seem right.
@peterbarker, @hamishwillee

@@ -178,6 +178,7 @@
<xs:simpleType name="factor">
<xs:restriction base="xs:string">
<xs:enumeration value="1E-2"/> <!-- actual value = stated value / 100 -->
<xs:enumeration value="360/255"/> <!-- actual value = stated value * 360/255, as used for GPS_STATUS.satellite_azimuth -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterbarker How about

Suggested change
<xs:enumeration value="360/255"/> <!-- actual value = stated value * 360/255, as used for GPS_STATUS.satellite_azimuth -->
<xs:enumeration value="360div255"/> <!-- actual value = stated value * 360/255, as used for GPS_STATUS.satellite_azimuth -->

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or to put it another way, I have no strong opinions, but good to put this in.

degScaledToByte? degScaled255

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I'd prefer "360/255" because, it is both:

  • directly evaluatable in pretty much any programming language for when the actual value is required for maths.
  • humanly understandable as text if printed as-is (e.g. web page, Wireshark dissector, code comments, etc).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see what @peterbarker says - I dislike the slash sorry!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the slash. It means we can continue to just eval these things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer the slash

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pushing this @shancock884

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marked this for DevCall to make sure tridge is good with this.

@@ -178,6 +178,7 @@
<xs:simpleType name="factor">
<xs:restriction base="xs:string">
<xs:enumeration value="1E-2"/> <!-- actual value = stated value / 100 -->
<xs:enumeration value="360/255"/> <!-- actual value = stated value * 360/255, as used for GPS_STATUS.satellite_azimuth -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the slash. It means we can continue to just eval these things.

@amilcarlucas
Copy link
Contributor

360/256 seams more logical
0° == 360°
8 LSBs of 0 bin == 8 LSBs of 256 bin

@peterbarker peterbarker merged commit 9606dbc into ArduPilot:master May 27, 2024
12 checks passed
@shancock884
Copy link
Contributor Author

360/256 seams more logical
0° == 360°
8 LSBs of 0 bin == 8 LSBs of 256 bin

yes I made the same suggestion when raising the original issue mavlink/mavlink#2062, but in the end it seemed safer to keep the range in line with the historic description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants