Skip to content
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

Apply automatic mapping rules in case only package+message mapping exists #382

Merged
merged 3 commits into from
Nov 6, 2022

Conversation

LoyVanBeek
Copy link
Contributor

In determine_field_mapping, there was an early return inside a loop over all mapping rules. If there were any mapping rules but they don't specify field mappings, the early return made the function return without creating field mappings automatically.

For a particular message type, ROS 1's uuid_msgs/UniqueID vs ROS 2's unique_identifier_msgs/UUID, the message definition is exactly the same but type name is not. The only mapping rule defined for unique_identifier_msgs/UUID is that it maps to uuid_msgs/UniqueID, but no field mappings are needed because the definitions are the same: https://github.com/ros2/unique_identifier_msgs/blob/rolling/mapping_rules.yaml

But, then we hit the early return (because the for-loop is ran without any rule applying to the message at hand and thus not continue-ing in a code branch handling a rule) and return without applying the normal automatic field mapping generation rules.

By removing the early return, the other rules are applied and the mapping rules for handling the exact same message definitions are applied.

This fixes the issue found in ros2/unique_identifier_msgs#25 in ros1_bridge instead of unique_identifier_msgs

This PR applies to foxy because I combine it with Noetic and can test only that combo, but the early return causing this issue is still there on the main branch: https://github.com/ros2/ros1_bridge/blob/master/ros1_bridge/__init__.py#L788

@gbiggs
Copy link
Member

gbiggs commented Oct 31, 2022

Please correct the DCO for your commits.

@gbiggs
Copy link
Member

gbiggs commented Oct 31, 2022

Please re-target your PR to the rolling branch. We will backport it to older distributions.

@LoyVanBeek
Copy link
Contributor Author

There is no rolling branch. Latest is ROS distro listed in galactic but there's also master

@gbiggs
Copy link
Member

gbiggs commented Oct 31, 2022

Sorry, you're correct. Please target it to master.

… be applied

In determine_field_mapping, there was an early return inside a loop over all mapping rules.
IF there we any mapping rules but they don't specify field mappings, the early return made the function return without creating mappings automatically.

For a particular message type, ROS 1's uuid_msgs/UniqueID vs ROS 2's unique_identifier_msgs/UUID, the message definition is exacly the same but type name is not.
The only mapping fule defined in for unique_identifier_msgs/UUID is that it maps to uuid_msgs/UniqueID, but no field mappings are needed because the definitions are the same.

But, then we hit the early return (because the for-loop is ran without any rule applying to the message at hand and thus not `continue`-ing in a code branch handling a rule)
and return without applying the normal automatic field mapping generation rules.

By removing the early return, the other rules are applied and the mapping rules for handling the exact same message defintions are applied

Signed-off-by: Loy van Beek <loy.vanbeek@mojin-robotics.de>
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

Signed-off-by: Loy van Beek <loy.vanbeek@mojin-robotics.de>
Signed-off-by: Loy van Beek <loy.vanbeek@mojin-robotics.de>
@LoyVanBeek LoyVanBeek changed the base branch from foxy to master November 1, 2022 06:58
@LoyVanBeek LoyVanBeek force-pushed the fix/mapping_uuids branch 2 times, most recently from 76a6396 to 196ca18 Compare November 1, 2022 10:49
@gbiggs
Copy link
Member

gbiggs commented Nov 3, 2022

CI:
Build Status

@gbiggs
Copy link
Member

gbiggs commented Nov 6, 2022

Looks like the instability is unrelated to this PR.

@gbiggs gbiggs merged commit 2381bf4 into ros2:master Nov 6, 2022
@gbiggs
Copy link
Member

gbiggs commented Nov 6, 2022

Thanks for the contribution!

@LoyVanBeek LoyVanBeek deleted the fix/mapping_uuids branch November 7, 2022 06:56
@LoyVanBeek
Copy link
Contributor Author

No thnx, nice to have this merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants