Skip to content

Commit

Permalink
rosbag_fix_all.py: make it easier to clean up failed output bags (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
trey0 authored Jun 3, 2022
1 parent c0ead3d commit a09b270
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 13 additions & 3 deletions tools/bag_processing/scripts/Makefile.rosbag_fix_all
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ endif
%.rewrite_types.bag: %.bag
${REWRITE_TYPES} -v ${REWRITE_RULES} $< -o $@

%.fix_all.bag: %.rewrite_types.bag
%.fix_all_pre_check.bag: %.rewrite_types.bag
rosbag fix $< $@ ${BMR}
rm $< # explicitly delete right away to save disk space
rosbag check $@ # test: post-migration consistency
${ROSBAG_VERIFY} ${ROSBAG_VERIFY_ARGS} $@ $(@:.fix_all.bag=.bag)

# The fix_all_check targets are .PHONY but too much trouble and not
# necessary to declare that.

fix_all_check1-%: %.fix_all_pre_check.bag
rosbag check $<

fix_all_check2-%: %.fix_all_pre_check.bag
${ROSBAG_VERIFY} ${ROSBAG_VERIFY_ARGS} $< $(<:.fix_all_pre_check.bag=.bag)

%.fix_all.bag: %.fix_all_pre_check.bag fix_all_check1-% fix_all_check2-%
mv $< $@ # checks complete
8 changes: 7 additions & 1 deletion tools/bag_processing/scripts/rosbag_fix_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def dosys(cmd):
def rosbag_fix_all(inbag_paths_in, jobs, deserialize=False):
this_folder = os.path.dirname(os.path.realpath(__file__))
makefile = os.path.join(this_folder, "Makefile.rosbag_fix_all")
inbag_paths = [p for p in inbag_paths_in if not p.endswith(".fix_all.bag")]
inbag_paths = [p for p in inbag_paths_in if not ".fix_all" in p]
skip_count = len(inbag_paths_in) - len(inbag_paths)
if skip_count:
logging.info(
Expand All @@ -67,6 +67,12 @@ def rosbag_fix_all(inbag_paths_in, jobs, deserialize=False):
logging.info(" %s", outbag_path)
else:
logging.warning("Not all bags were fixed successfully (see errors above).")
logging.warning(
"You can debug any failed output bags - ending in .fix_all_pre_check.bag"
)
logging.warning(
"If you want to try again, clean first: rm *.fix_all_pre_check.bag"
)

return ret

Expand Down

0 comments on commit a09b270

Please sign in to comment.