From 7efc9cbf90e9ba213154f94484ccc85d12157844 Mon Sep 17 00:00:00 2001 From: Stefan Hoffmann Date: Wed, 30 Oct 2024 08:12:16 +0100 Subject: [PATCH] fix missing fields check for mappings to substructures This happens for rcl_interfaces/Log 'header.stamp' gets mapped to 'stamp'. For the old check on both messages where some fields missing: 'topics' in ros2 and 'stamp' in ros1. That 'stamp' was mapped via the custom rule above wasn't recognized by the old logic. For now we say if there a custom field mappings for a field we skip this check. --- ros1_bridge/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ros1_bridge/__init__.py b/ros1_bridge/__init__.py index 049a5e7d..4fbcf0e2 100644 --- a/ros1_bridge/__init__.py +++ b/ros1_bridge/__init__.py @@ -1093,6 +1093,10 @@ def determine_field_mapping(ros1_msg, ros2_msg, mapping_rules, msg_idx): # check that no fields exist in ROS 2 but not in ROS 1 # since then it might be the case that those have been renamed and should be mapped for ros2_member in ros2_spec.structure.members: + if any(ros2_member == key[0] for key in mapping.fields_2_to_1.keys()): + # If they are explicitly mapped this should be fine... + continue + for ros1_field in ros1_spec.parsed_fields(): if ros1_field.name.lower() == ros2_member.name: break