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

BUG: Python's PprzMessage doesn't cast values to the specified types #124

Open
MJafarMashhadi opened this issue Jul 9, 2020 · 2 comments

Comments

@MJafarMashhadi
Copy link
Contributor

msg[value_name] is always of type str and the fieldtypes property is ignored there (at least for numbers). It's only used when converting to/from binary.

@gautierhattenberger
Copy link
Member

Yes, it is true that data in message fields have the same type than the element stored inside. So when they are filled from IVY strings, I guess they all end up as str as well.
It's not really a bug, nor a feature... Mostly laziness I guess :(
If you have a clean solution for that, it could be integrated, as there is no reason to store data with the wrong type. And that would avoid explicit cast when extracting them on user side (like here: https://github.com/paparazzi/paparazzi/blob/master/sw/ground_segment/python/multi/fc_rotor/fc_rotor.py#L116)

@MJafarMashhadi
Copy link
Contributor Author

MJafarMashhadi commented Jul 9, 2020

Explicit casting was exactly what I had to do as well!

I think doing the type casting right in ivy_string_to_payload and binary_to_payload would do the job. Also it'd be nicer to have a dictionary mapping names to a 3-tuple of value, dtype, and coef instead of keeping 4 separate lists in-sync for them.

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