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

Incorrect temperature in ESC status in UAVCAN mode #169

Open
jxltom opened this issue May 15, 2020 · 3 comments
Open

Incorrect temperature in ESC status in UAVCAN mode #169

jxltom opened this issue May 15, 2020 · 3 comments

Comments

@jxltom
Copy link
Contributor

jxltom commented May 15, 2020

In

status.temperature = mc_interface_temp_fet_filtered() + 273.15;
, the returned temperature is always 298.0000 which looks like precesion is lost.

Even I changed code to status.temperature = 24.9219 + 273.15; in bldc, the parsed temperature in https://github.com/UAVCAN/gui_tool is still 298.0000

Here is the screenshot in gui_tool.

image

Maybe something wrong with canardConvertNativeFloatToFloat16?

@pavel-kirienko do you mind also having a look? Thanks.

@jxltom
Copy link
Contributor Author

jxltom commented May 15, 2020

Change to float32 is fine. It looks like using float16 is overflow or something like that for big numbers such as 280.

@pavel-kirienko
Copy link

At this exponent, the step is around 0.2:

>>> import numpy
>>> numpy.nextafter(numpy.float16(298), numpy.float16(1000))
298.2

Whereas your value falls closer to 298:

>>> 24.9219 + 273.15
298.07189999999997

The behavior you are observing is correct.

@jxltom
Copy link
Contributor Author

jxltom commented May 20, 2020

Thanks for the clarification!

So the precision of float16 for numbers such has 298 is around 0.2 or bigger.

Since uavcan is using Kelvin and motor temperature is certainly larger than 273.15, maybe it makes sense to change the definition of uavcan.equipment.esc.Status.temperature to float32, otherwise the digit 0.05 in 273.15 will definitely be lost. float32 doesn't have this issue.

>>> import numpy
>>> numpy.nextafter(numpy.float16(273.15), numpy.float16(numpy.inf))
273.5
>>> numpy.nextafter(numpy.float32(273.15), numpy.float32(numpy.inf))
273.15002

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

No branches or pull requests

2 participants