adnanademovic / serde_rosmsg

ROSMSG Serialization for Rust
MIT License
6 stars 2 forks source link

Unable to deserialize fixed size arrays with sizes larger than 32 elements #2

Open Carter12s opened 8 months ago

Carter12s commented 8 months ago

I'm not sure there is going to be a solution here, but I wanted to check with the authors of this crate if they've come across this problem before and if they have solutions.

I'm struggling / un-able to use this crate to deserialize messages containing fixed sized arrays with more than 32 elements in them. from_slice<> obviously requires that Deserialize is implemented for the type in question, but #[derive(Deserialize)] is only able to produce valid deserialization impls for fixed size arrays of 32 elements or less. Otherwise you get:

error[E0277]: the trait bound `[f64; 33]: Deserialize<'_>` is not satisfied
  --> src/datatests/nav_sat_fix.rs:14:9
   |
14 |         pub r#position_covariance: [f64; 33],
   |         ^^^ the trait `Deserialize<'_>` is not implemented for `[f64; 33]`
   |
   = help: the following other types implement trait `Deserialize<'de>`:
             [T; 0]
             [T; 1]
             [T; 2]

This is particularly challenging because several "standard" ros messages like TwistWithCovariance have fixed sized arrays with 36 members.

I'm assuming someone has already solved this and I'm just being dumb in roslibrust, but not excited about a solution like this: https://stackoverflow.com/questions/62665558/how-can-i-implement-serdedeserialize-for-arrays-larger-than-32

Looking for any guidance.

Carter12s commented 1 week ago

Note. I ended up finding work around using https://docs.rs/serde-big-array/latest/serde_big_array/

Had to include the "BigArray" serde tag on the message types I was generating, which roslibrust's code generation now supports.