Open MJafarMashhadi opened 4 years ago
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)
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.
msg[value_name]
is always of typestr
and thefieldtypes
property is ignored there (at least for numbers). It's only used when converting to/from binary.