Skip to content

Commit 3da3a72

Browse files
committed
update to python 3
1 parent 1095118 commit 3da3a72

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

bag_tools/scripts/change_camera_info.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def replacement(replace_string):
6565
raise argparse.ArgumentTypeError("Replace string must have the form /topic=calib_file.yaml")
6666
if pair[0][0] != '/':
6767
pair[0] = '/'+pair[0]
68-
stream = file(pair[1], 'r')
69-
calib_data = yaml.load(stream)
68+
stream = open(pair[1], 'r')
69+
calib_data = yaml.load(stream, Loader=yaml.FullLoader)
7070
cam_info = sensor_msgs.msg.CameraInfo()
7171
cam_info.width = calib_data['image_width']
7272
cam_info.height = calib_data['image_height']
@@ -78,17 +78,21 @@ def replacement(replace_string):
7878
return pair[0], cam_info
7979

8080
if __name__ == "__main__":
81+
82+
"CALL : python3 change_camera_info.py --inbag in.bag --outbag out.bag --replacement /stereo_down/left/camera_info=left.yaml"
83+
8184
rospy.init_node('change_camera_info')
8285
parser = argparse.ArgumentParser(description='Change camera info messages in a bagfile.')
83-
parser.add_argument('inbag', help='input bagfile')
84-
parser.add_argument('outbag', help='output bagfile')
85-
parser.add_argument('replacement', type=replacement, nargs='+', help='replacement in form "TOPIC=CAMERA_INFO_FILE", e.g. /stereo/left/camera_info=my_new_info.yaml')
86+
parser.add_argument('--inbag', help='input bagfile')
87+
parser.add_argument('--outbag', help='output bagfile')
88+
parser.add_argument('--replacement', type=replacement, nargs='+', help='replacement in form "TOPIC=CAMERA_INFO_FILE", e.g. /stereo/left/camera_info=my_new_info.yaml')
8689
args = parser.parse_args()
8790
replacements = {}
91+
8892
for topic, calib_file in args.replacement:
8993
replacements[topic] = calib_file
9094
try:
9195
change_camera_info(args.inbag, args.outbag, replacements)
92-
except Exception, e:
96+
except Exception as e:
9397
import traceback
9498
traceback.print_exc()

0 commit comments

Comments
 (0)