-
Notifications
You must be signed in to change notification settings - Fork 598
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
base: master
Are you sure you want to change the base?
Conversation
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] != "": |
There was a problem hiding this comment.
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:
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: |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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.
fixes XKF4 scaled innovations with ArduPilot master