Skip to content

Commit

Permalink
Account for fields mapped by rules when checking for missed fields
Browse files Browse the repository at this point in the history
The code after the early return mentioned in the previous commit assumed all fields would match by name,
which was of course true. But not anymore, so the missing check now only fails when the missing fields are also not already accounted for via a mapping
  • Loading branch information
LoyVanBeek committed Oct 24, 2022
1 parent 8455224 commit 338c7f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ros1_bridge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,16 +757,21 @@ def determine_field_mapping(ros1_msg, ros2_msg, mapping_rules, msg_idx):
# apply name based mapping of fields
ros1_field_missing_in_ros2 = False

ros1_fields_not_mapped = []
for ros1_field in ros1_spec.parsed_fields():
for ros2_member in ros2_spec.structure.members:
if ros1_field.name.lower() == ros2_member.name:
# get package name and message name from ROS 1 field type
update_ros1_field_information(ros1_field, ros1_msg.package_name)
mapping.add_field_pair(ros1_field, ros2_member)
break
else:

ros1_fields_mapped_to_a_ros2_member = [field[0].name for field in mapping.fields_1_to_2.keys()]
if not ros1_field.name in ros1_fields_mapped_to_a_ros2_member:
# this allows fields to exist in ROS 1 but not in ROS 2
ros1_field_missing_in_ros2 = True
ros1_fields_not_mapped += [ros1_field]

ros1_field_missing_in_ros2 = any(ros1_fields_not_mapped)

if ros1_field_missing_in_ros2:
# if some fields exist in ROS 1 but not in ROS 2
Expand Down

0 comments on commit 338c7f8

Please sign in to comment.