Skip to content

Improve high_latency_tgt_dist()#32856

Open
hunt0r wants to merge 5 commits intoArduPilot:masterfrom
hunt0r:issue32838-fix-units-mistake-in-high-latency-tgt-dist
Open

Improve high_latency_tgt_dist()#32856
hunt0r wants to merge 5 commits intoArduPilot:masterfrom
hunt0r:issue32838-fix-units-mistake-in-high-latency-tgt-dist

Conversation

@hunt0r
Copy link
Copy Markdown
Contributor

@hunt0r hunt0r commented Apr 19, 2026

Summary

Some spots were incorrectly using decimeters (dm) rather than decameters (dam). Also improved some values and typecasting.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

This resolves #32838 .

  • Some unit-scaling was done outside a MAX(..., uint16_max), which means the likely-intended max-value was not possible.
  • Unit suffix is added to the function, per our preference for that in our dev wiki.
  • Some divisions are converted to multiplications, per our preference for that in our dev wiki.
  • Some implicit casts are made explicit.
  • One change from 0.001 to 1e-3 was made, because I find that easier to read for exponents >= 3.

@peterbarker
Copy link
Copy Markdown
Contributor

I wonder if we should spell out "decameters".... I didn't recognize dam

@peterbarker peterbarker requested a review from stephendade April 19, 2026 23:44
@hunt0r
Copy link
Copy Markdown
Contributor Author

hunt0r commented Apr 19, 2026

I wonder if we should spell out "decameters".... I didn't recognize dam

Just ICYDK, it's the preferred abbrev from our wiki.
(I too don't like it, FWIW.)

Comment thread ArduPlane/GCS_MAVLink_Plane.cpp Outdated
@tpwrules
Copy link
Copy Markdown
Contributor

tpwrules commented Apr 20, 2026

If you want my two cents on the units, maybe it should not be in the function name. There are all sorts of weird units in these high latency functions like duodegrees and quintimeters per second. But they are listed in the comments in GCS_Common.cpp.

Not every bug needs the entire thing rearchitected to fix :)

As mentioned I do like the improvement in very high distance scenarios.

@timtuxworth
Copy link
Copy Markdown
Contributor

timtuxworth commented Apr 20, 2026

If you want my two cents on the units, maybe it should not be in the function name. There are all sorts of weird units in these high latency functions like duodegrees and quintimeters per second. But they are listed in the comments in GCS_Common.cpp.

Not every bug needs the entire thing rearchitected to fix :)

As mentioned I do like the improvement in very high distance scenarios.

We have a fairly well discussed list of standard units here https://ardupilot.org/dev/docs/style-guide.html#preferred-abbreviations-for-units and "dam" isn't on the list. I think adding units to the method fits the pattern we are going for, but if so probably add it to the list maybe with a comment "only used for high latency mavlink messages" (or somethink like that.

@timtuxworth
Copy link
Copy Markdown
Contributor

I wonder if we should spell out "decameters".... I didn't recognize dam

lets just add it to the list: https://ardupilot.org/dev/docs/style-guide.html#preferred-abbreviations-for-units

@tpwrules
Copy link
Copy Markdown
Contributor

tpwrules commented Apr 20, 2026

I wonder if we should spell out "decameters".... I didn't recognize dam

Just ICYDK, it's the preferred abbrev from our wiki. (I too don't like it, FWIW.)

Is it? I do not see it, and it's not on the page Tim linked. Can you provide a link? How did you decide that it is?

@hunt0r
Copy link
Copy Markdown
Contributor Author

hunt0r commented Apr 20, 2026

How did you decide that it is?

Wiki says "Functions that return a single physical value or variables that represent a physical value should be suffixed by the physical unit." From NIST, the abbreviation for this unit is 'dam', and nothing in the table overrides that.

@hunt0r hunt0r force-pushed the issue32838-fix-units-mistake-in-high-latency-tgt-dist branch from a221e2b to f4fdb9b Compare April 20, 2026 14:15
@hunt0r hunt0r changed the title Fix units mistake in high_latency_tgt_dist() Improve high_latency_tgt_dist() Apr 20, 2026
@hunt0r hunt0r marked this pull request as ready for review April 20, 2026 14:19
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.

Units mistake in high_latency_tgt_dist( )

4 participants