From 57f0fb75c1a896c5cab698ca7ab01977661a790b Mon Sep 17 00:00:00 2001 From: Ivo Ivanov Date: Sat, 12 Nov 2022 11:44:51 +0100 Subject: [PATCH] ros_numpy Implemented fix for converting messaged from rosbags from https://github.com/eric-wieser/ros_numpy/pull/6 --- libs/ros_numpy/src/ros_numpy/registry.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/ros_numpy/src/ros_numpy/registry.py b/libs/ros_numpy/src/ros_numpy/registry.py index 5442b93..9d10cfe 100644 --- a/libs/ros_numpy/src/ros_numpy/registry.py +++ b/libs/ros_numpy/src/ros_numpy/registry.py @@ -34,10 +34,16 @@ def numpify(msg, *args, **kwargs): if not conv: - raise ValueError("Unable to convert message {} - only supports {}".format( - msg.__class__.__name__, - ', '.join(cls.__name__ + ("[]" if pl else '') for cls, pl in _to_numpy.keys()) - )) + for class_instance, _ in _to_numpy.keys(): + if msg._type == class_instance._type: + if msg._md5sum == class_instance._md5sum: + conv = _to_numpy.get((class_instance, False)) + break + else: + raise ValueError("Unable to convert message {} - only supports {}".format( + msg.__class__.__name__, + ', '.join(cls.__name__ + ("[]" if pl else '') for cls, pl in _to_numpy.keys()) + )) return conv(msg, *args, **kwargs)