ros2_rust
ros2_rust copied to clipboard
Use ndarray in messages
In Python, arrays of primitive numbers are deserialized into numpy arrays. Rust could do the same (in its idiomatic message type, not the RMW-native message type). This would make working with these vectors and matrices much easier.
There are two ways we could go about this: Either simply always use ndarray for arrays of numbers, or keep it a regular array and add conversion functions. The latter approach has the benefit that it could be feature-gated to avoid increasing compile times too much.
Maybe this whole idea could be taken a step further and we special-case the MultiDimensionalArray messages from common_interfaces, e.g. Float64MultiArray to be ndarray types.
Maybe it would be interesting to look at https://github.com/ros2/rclcpp/pull/1557 for inspiration.
Is it not more idiomatic to just implement Into for MultiDimensionalArray messages of number types? The user can choose to let val: Array3::<f64> = msg.into() etc. if they desire.
Yep, that's probably better.