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

Fix ROS message migration rule tool #996

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions tools/rosbag/src/rosbag/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ def find_path(self, old_class, new_class):
found_stop = True
break

# Next see if we can create a valid rule
# Next see if we can create a valid rule, including the sub rules
if not found_stop:
for (ind, tmp_sn) in reversed(list(zip(range(len(sn_range)), sn_range))):
if (tmp_sn.new_class._type != new_class._type):
Expand All @@ -977,12 +977,13 @@ def find_path(self, old_class, new_class):
R = new_rule(self, 'GENERATED.' + new_rule.__name__)
if R.valid:
R.find_sub_paths()
sn = ScaffoldNode(tmp_sn.new_class, new_class, R)
self.extra_nodes.append(sn)
sn_range = sn_range[:ind+1]
sn_range.append(sn)
found_stop = True
break
if R.sub_rules_valid:
sn = ScaffoldNode(tmp_sn.new_class, new_class, R)
self.extra_nodes.append(sn)
sn_range = sn_range[:ind+1]
sn_range.append(sn)
found_stop = True
break

# If there were no valid implicit rules, we suggest a new one from to the end
if not found_stop:
Expand All @@ -1006,7 +1007,19 @@ def find_path(self, old_class, new_class):
found_start = True
break

# Next see if we can create a valid rule
# Next see if we can create a valid rule directly to the end, including the sub rules
if not found_start:
new_rule = self.make_update_rule(old_class, new_class)
R = new_rule(self, 'GENERATED.' + new_rule.__name__)
if R.valid:
R.find_sub_paths()
if R.sub_rules_valid:
sn = ScaffoldNode(old_class, new_class, R)
self.extra_nodes.append(sn)
self.found_paths[key] = [sn]
return [sn]

# Next see if we can create a valid rule, including the sub rules
if not found_start:
for (ind, tmp_sn) in reversed(list(zip(range(len(sn_range)), sn_range))):
if (tmp_sn.old_class._type != old_class._type):
Expand All @@ -1015,12 +1028,13 @@ def find_path(self, old_class, new_class):
R = new_rule(self, 'GENERATED.' + new_rule.__name__)
if R.valid:
R.find_sub_paths()
sn = ScaffoldNode(old_class, tmp_sn.old_class, R)
self.extra_nodes.append(sn)
sn_range = sn_range[ind:]
sn_range.insert(0,sn)
found_start = True
break
if R.sub_rules_valid:
sn = ScaffoldNode(old_class, tmp_sn.old_class, R)
self.extra_nodes.append(sn)
sn_range = sn_range[ind:]
sn_range.insert(0,sn)
found_start = True
break

# If there were no valid implicit rules, we suggest a new one from the beginning
if not found_start:
Expand Down