-
Notifications
You must be signed in to change notification settings - Fork 97
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
Rework python ROS2 (de)serialization using parsed ROS2 messages directly #415
Conversation
23625a2
to
41e9f86
Compare
Use ROS2 types as type info to ensure that serialization type matches exactly. This is necessary because the types need to match exactly, otherwise the serialization or deserialization will result in invalid data. Using arrow schemas to specify the ROS2 message types does not work because not all ROS2 message types can be represented. For example, ROS2 serializes arrays with known length differently than sequences with dynamic length.
41e9f86
to
1327382
Compare
Arrow has a special `BinaryArray` type for storing lists of variable-sized binary data efficiently. This type is equivalent to a `ListArray` of `PrimitiveArray<u8>`, but it is a different data type. This commit updates the Python ROS2 serialization code to permit BinaryArray for all uint8 array or sequence fields.
libraries/extensions/ros2-bridge/python/src/typed/serialize/mod.rs
Outdated
Show resolved
Hide resolved
Required because arrow uses column-oriented data format, which requires all struct fields to have length 1.
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.
Looks good to me. Pushed couple of amelioration. But that's it.
let empty = HashMap::new(); | ||
let package_messages = self | ||
.type_info | ||
.messages | ||
.get(self.type_info.package_name.as_ref()) | ||
.unwrap_or(&empty); | ||
let message = package_messages | ||
.get(self.type_info.message_name.as_ref()) | ||
.ok_or_else(|| { | ||
error(format!( | ||
"could not find message type {}::{}", | ||
self.type_info.package_name, self.type_info.message_name | ||
)) | ||
})?; |
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.
Same thing I think, message
can be cached, otherwise this is going to happen at each ser/de.
libraries/extensions/ros2-bridge/python/src/typed/serialize/mod.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Haixuan Xavier Tao <[email protected]>
Use ROS2 types as type info to ensure that serialization type matches exactly. This is necessary because the types need to match exactly, otherwise the serialization or deserialization will result in invalid data.
Using arrow schemas to specify the ROS2 message types does not work because not all ROS2 message types can be represented. For example, ROS2 serializes arrays with known length differently than sequences with dynamic length.
Other improvements:
Add support for serializing arrow
BinaryArray
typesArrow has a special
BinaryArray
type for storing lists of variable-sized binary data efficiently. This type is equivalent to aListArray
ofPrimitiveArray<u8>
, but it is a different data type.This PR updates the Python ROS2 serialization code to permit BinaryArray for all uint8 array or sequence fields. Fixes Error when trying to publish a PointCloud2 message from dora to ros2 dora-autoware#10