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

DFReader: fixed handling of multlipiers from FMTU and MULT #965

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Aug 11, 2024

fixes XKF4 scaled innovations with ArduPilot master

@peterbarker
Copy link
Contributor

Ping @shancock884

@@ -166,7 +166,7 @@ def set_mult_ids(self, mult_ids, mult_lookup):
for i in range(len(self.units)):
# If the format has its own multiplier, do not adjust the unit,
# and if no unit is specified there is nothing to adjust
if self.msg_mults[i] is not None or self.units[i] == "":
if self.msg_mults[i] is not None or self.units[i] != "":
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need just:

Suggested change
if self.msg_mults[i] is not None or self.units[i] != "":
if self.msg_mults[i] is not None:

Otherwise, things like *.TimeUS will say its in 's' instead of 'μs' and PM.Load will say its in '%' instead of 'd%', when running 'dump PM --verbose'.

@@ -176,6 +176,9 @@ def set_mult_ids(self, mult_ids, mult_lookup):
self.units[i] = MULT_TO_PREFIX[unitmult]+self.units[i]
else:
self.units[i] = "%.4g %s" % (unitmult, self.units[i])
if self.units[i] in FORMAT_TO_STRUCT:
Copy link
Contributor

@shancock884 shancock884 Aug 12, 2024

Choose a reason for hiding this comment

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

I think that the "if self.units[i] in FORMAT_TO_STRUCT" bit is working because the prefix for "centi" and the code for "int16_t * 100" are both 'c' - but in my mind they aren't really the same 'c'!

Assuming your aim is that any parameter which has no-unit but does have a multiplier specified, has that multiplier applied to the value, instead of becoming a unit prefix, then maybe something like this is cleaner:

Suggested change
if self.units[i] in FORMAT_TO_STRUCT:
# For unitless values, apply multiplier to value. For params with a unit,
# turn the multiplier into a unit prefix.
if self.units[i] == "":
self.msg_mults[i] = mult_lookup[mult_ids[i]]
elif unitmult in MULT_TO_PREFIX:
self.units[i] = MULT_TO_PREFIX[unitmult]+self.units[i]
else:
self.units[i] = "%.4g %s" % (unitmult, self.units[i])

(to replace all lines 175 -181)

Not checked in detail, but I think this should then work for any multiplier which is set on a unitless parameter, even if that multiplier is not 100.

@@ -166,7 +166,7 @@ def set_mult_ids(self, mult_ids, mult_lookup):
for i in range(len(self.units)):
# If the format has its own multiplier, do not adjust the unit,
# and if no unit is specified there is nothing to adjust

Choose a reason for hiding this comment

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

Remember to update this comment based on the final test logic.

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.

5 participants