-
Notifications
You must be signed in to change notification settings - Fork 1k
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
usddeck: Add eventriggerType_fp16 #799
Conversation
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.
Do we actually have variables of this type? Your code changes look good, but I am worried about proper support on the host side. In particular, does struct.decode do the right thing and is the firmware actually using the IEEE 754 binary16 standard? Supporting this datatype on a C++ host might also be challenging, as this is none of the standard types in C(++).
Good questions! Python supports this since I think 3.6: https://docs.python.org/3/library/struct.html#format-characters, and I believe it should work. And according to @ataffanel this should work (https://forum.bitcraze.io/viewtopic.php?p=22023&sid=311d5a4e46d027554d6e04312f573ebd#p22023). I think both clang and gcc has extensions to support this. But! Your objections are fair. Perhaps instead of this PR we make it not assert and instead warn in some way? |
My (bold) suggestion would have been to just remove FP16 entirely from the firmware - less to test & maintain... I don't remember seeing it being used inside the firmware and I've also not really seen the feature being used to log data with a different type (e.g., logging a float32 variable as FP16 to fit more inside a single log block.) |
There is currently no variable that uses FP16 in the firmware memory, this is only converted to be transferred in the log packets. My intention was to implement IEEE 754 binary16 when I implemented FP16 in the Crazyflie. From my tests, the python implementation works fine with it. I do not remember being too careful about rounding and subnormalized representation is not handled, but for the purpose of compressing floating point representation it works well. For reference, the implementation is there: crazyflie-firmware/src/utils/src/num.c Lines 48 to 62 in a70c357
Now, when it comes to the SD-card deck, it may be that fp16 is not that interesting since we have a lot more bandwidth. Though if it can be handled rather than failing it would be more coherent and less surprising if anyone tries to use it. GCC support for fp16 was added right after I made my own implementation, it might also be an idea to use it in the Crazyflie so that we can be a bit more confident with interoperability. |
It is implemented in the Crazyflie lib now. It was implemented after a forum request to make this packet possible using a single log block: I do think that it is a useful functionality when it comes to the radio since we have such a limited space in each log packet. |
For this particular case, I think it makes more sense to use crazyflie-firmware/src/hal/src/pm_stm32f4.c Line 421 in 6b04364
But going back to the topic at hand: if fp16 is to remain supported, then this PR looks good. |
Fixes: #798