-
Notifications
You must be signed in to change notification settings - Fork 166
Description
Description
When attempting to serialize a ROS 2 message (like sensor_msgs/msg/Imu) where a fixed-size array field (e.g., orientation_covariance: float64[9]) is initialized as a NumPy ndarray, the mcap-ros2-support library throws a ValueError. The serialization checker strictly expects a standard Python sequence (list or tuple) for array types, even though the array is numeric.
-
Version:
mcap-ros2-support(PyPI)
mcap1.3.0 (PyPI) -
Platform:
ROS2 Jazzy
Python 3.12
Steps To Reproduce
- Set up a minimal ROS 2 package environment with the recorder running.
- Publish a
sensor_msgs/msg/Imumessage using a tool (e.g.,ros2 topic pub) that initializes the fixed-size array fields (likeorientation_covariance) as a NumPy ndarray object.
Note: The issue persists even when initializing with a Python list structure, indicating the conversion to ndarray happens upstream of the writer.
Expected Behavior
The message should be successfully serialized and recorded, as the fixed-size array conversion should be handled by the installed mcap-ros2-support version.
** Actual Behavior**
ValueError: Field "orientation_covariance" is not an array (<class 'numpy.ndarray'>) but has array type "float64[]"
...
File "/home/user/.local/lib/python3.12/site-packages/mcap_ros2/_dynamic.py", line 431, in _write_complex_type
raise ValueError(
Proposed Fix Location
The fix likely needs to ensure that numpy.ndarray objects for numeric fixed-size arrays (float64[]) are explicitly handled within the dynamic encoding logic:
| if ( |