Skip to content

Commit deb7f92

Browse files
committed
preparing for indigo. changed prints for ros logs
1 parent d04e31c commit deb7f92

17 files changed

+67
-70
lines changed

bag_tools/scripts/bag_tools/add_header_time_offset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
def add_offset(inbags, topics, offset):
4343
for inbag in inbags:
4444
outbag = "timefixed-" + inbag
45-
print ' Processing input bagfile: ', inbag
46-
print ' Writing to output bagfile: ', outbag
47-
print 'Changing header time of topics: ', topics
48-
print ' Adding offset: ', offset
45+
rospy.loginfo(' Processing input bagfile: %s', inbag)
46+
rospy.loginfo(' Writing to output bagfile: %s', outbag)
47+
rospy.loginfo('Changing header time of topics: %s', topics)
48+
rospy.loginfo(' Adding offset: %s', offset)
4949
outbag = rosbag.Bag(outbag,'w')
5050
time_offset = rospy.Duration.from_sec(offset)
5151
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages():

bag_tools/scripts/bag_tools/bag_add_time_offset.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
import argparse
4141

4242
def fix_bagfile(inbag, outbag, topics, offset):
43-
print ' Processing input bagfile: ', inbag
44-
print ' Writing to output bagfile: ', outbag
45-
print ' Changing topics: ', topics
46-
print 'Changing publishing time by: ', offset
43+
rospy.loginfo(' Processing input bagfile: %s', inbag)
44+
rospy.loginfo(' Writing to output bagfile: %s', outbag)
45+
rospy.loginfo(' Changing topics: %s', topics)
46+
rospy.loginfo(' Changing publishing time by: %s', offset)
4747

4848
outbag = rosbag.Bag(outbag, 'w')
4949

@@ -59,11 +59,11 @@ def fix_bagfile(inbag, outbag, topics, offset):
5959
count[topic] = count[topic] + 1
6060
else:
6161
outbag.write(topic, msg, t)
62-
print 'Closing output bagfile.'
62+
rospy.loginfo('Closing output bagfile.')
6363
outbag.close()
64-
print 'Changed the following:'
64+
rospy.loginfo('Changed the following:')
6565
for k, v in count.iteritems():
66-
print k, ': ', v, ' messages.'
66+
rospy.loginfo( '%s:%s messages.',k,v)
6767

6868
if __name__ == "__main__":
6969

bag_tools/scripts/bag_tools/batch_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def process(in_dir,out_dir,command):
4545
for bagfile in bagfiles:
4646
outbag = out_dir + "/" + os.path.basename(bagfile)
4747
if os.path.exists(outbag):
48-
print outbag, "exists, skipping."
48+
rospy.loginfo('%s exists, skipping.', outbag)
4949
else:
5050
cmd = command.split()
5151
cmd.append("-i")

bag_tools/scripts/bag_tools/camera_info_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def parse_yaml(filename):
5656
args = parser.parse_args()
5757
try:
5858
info = parse_yaml(args.filename)
59-
print 'Read the following info from', args.filename, '\n', info
59+
rospy.loginfo('Read the following info from %s\n%s', args.filename, info)
6060
except Exception, e:
6161
import traceback
6262
traceback.print_exc()

bag_tools/scripts/bag_tools/change_camera_info.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
import sensor_msgs.msg
4343

4444
def change_camera_info(inbag,outbag,replacements):
45-
print ' Processing input bagfile: ', inbag
46-
print ' Writing to output bagfile: ', outbag
45+
rospy.loginfo(' Processing input bagfile: %s', inbag)
46+
rospy.loginfo(' Writing to output bagfile: %s', outbag)
4747
# parse the replacements
4848
maps = {}
4949
for k, v in replacements.items():
50-
print 'Changing topic', k, 'to contain following info (header will not be changed):\n', v
50+
rospy.loginfo('Changing topic %s to contain following info (header will not be changed):\n%s',k,v)
5151

5252
outbag = rosbag.Bag(outbag,'w')
5353
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages():
@@ -56,7 +56,7 @@ def change_camera_info(inbag,outbag,replacements):
5656
new_msg.header = msg.header
5757
msg = new_msg
5858
outbag.write(topic, msg, t)
59-
print 'Closing output bagfile and exit...'
59+
rospy.loginfo('Closing output bagfile and exit...')
6060
outbag.close();
6161

6262
def replacement(replace_string):

bag_tools/scripts/bag_tools/change_frame_id.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@
4040
import argparse
4141

4242
def change_frame_id(inbag,outbag,frame_id,topics):
43-
print ' Processing input bagfile: ', inbag
44-
print ' Writing to output bagfile: ', outbag
45-
print ' Changing topics: ', topics
46-
print ' Writing frame_id: ', frame_id
43+
rospy.loginfo(' Processing input bagfile: %s', inbag)
44+
rospy.loginfo(' Writing to output bagfile: %s', outbag)
45+
rospy.loginfo(' Changing topics: %s', topics)
46+
rospy.loginfo(' Writing frame_id: %s', frame_id)
4747

4848
outbag = rosbag.Bag(outbag,'w')
4949
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages():
5050
if topic in topics:
5151
if msg._has_header:
5252
msg.header.frame_id = frame_id
5353
outbag.write(topic, msg, t)
54-
print 'Closing output bagfile and exit...'
54+
rospy.loginfo('Closing output bagfile and exit...')
5555
outbag.close();
5656

5757
if __name__ == "__main__":

bag_tools/scripts/bag_tools/change_topics.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
import argparse
4141

4242
def change_topics(inbag,outbag,replacements):
43-
print ' Processing input bagfile: ', inbag
44-
print ' Writing to output bagfile: ', outbag
45-
print ' Replacements: ', replacements
43+
rospy.loginfo(' Processing input bagfile: %s', inbag)
44+
rospy.loginfo(' Writing to output bagfile: %s', outbag)
45+
rospy.loginfo(' Replacements: %s', replacements)
4646

4747
outbag = rosbag.Bag(outbag,'w')
4848
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages():
4949
if topic in replacements:
5050
topic = replacements[topic]
5151
outbag.write(topic, msg, t)
52-
print 'Closing output bagfile and exit...'
52+
rospy.loginfo('Closing output bagfile and exit...')
5353
outbag.close();
5454

5555
def replacement(replace_string):
@@ -72,7 +72,7 @@ def replacement(replace_string):
7272
replacements = {}
7373
for topic, new_topic in args.replacement:
7474
replacements[topic] = new_topic
75-
75+
7676
try:
7777
change_topics(args.inbag,args.outbag,replacements)
7878
except Exception, e:

bag_tools/scripts/bag_tools/check_delay.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
def check_delay(inbags):
4343
delays = {}
4444
for inbag in inbags:
45-
print ' Processing input bagfile: ', inbag
45+
rospy.loginfo(' Processing input bagfile: %s', inbag)
4646
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages():
4747
if topic == "/tf":
4848
for transform in msg.transforms:
@@ -65,8 +65,7 @@ def check_delay(inbags):
6565
delay_list.sort()
6666
dmin, dmax, dmean = min(delay_list), max(delay_list), sum(delay_list)/len(delay_list)
6767
dmedian = delay_list[len(delay_list)/2]
68-
print topic.ljust(max_len + 2), ": mean = ", dmean, ", min = ", dmin, ", max = ", dmax, ", median = ", dmedian
69-
68+
rospy.loginfo('%s : mean = %s, min = %s, max = %s, median = %s', topic.ljust(max_len + 2), dmean, dmin, dmax, dmedian)
7069

7170
if __name__ == "__main__":
7271
parser = argparse.ArgumentParser(

bag_tools/scripts/bag_tools/cut.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,24 @@
4141
def cut(inbags, outbagfile, start, duration):
4242
start_time = rospy.Time.from_sec(999999999999)
4343
for inbag in inbags:
44-
print ' Looking for smallest time in:', inbag
44+
rospy.loginfo(' Looking for smallest time in: %s', inbag)
4545
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages():
4646
if t < start_time:
4747
start_time = t
4848
break
49-
print ' Bagfiles start at', start_time
49+
rospy.loginfo(' Bagfiles start at %s', start_time)
5050
start_time = start_time + rospy.Duration.from_sec(start)
5151
end_time = start_time + rospy.Duration.from_sec(duration)
52-
print ' Cutting out from', start_time, 'to', end_time
52+
rospy.loginfo(' Cutting out from %s to %s',start_time, end_time)
5353
outbag = rosbag.Bag(outbagfile, 'w')
5454
num_messages = 0
5555
for inbag in inbags:
56-
print ' Extracting messages from:', inbag
56+
rospy.loginfo(' Extracting messages from:', inbag
5757
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages(start_time=start_time, end_time=end_time):
5858
outbag.write(topic, msg, t)
5959
num_messages = num_messages + 1
6060
outbag.close()
61-
print' New output bagfile has', num_messages, 'messages'
61+
rospy.loginfo(' New output bagfile has %s messages', num_messages)
6262

6363

6464
if __name__ == "__main__":

bag_tools/scripts/bag_tools/extract_topics.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@
4040
import argparse
4141

4242
def extract_topics(inbag,outbag,topics):
43-
print ' Processing input bagfile: ', inbag
44-
print ' Writing to output bagfile: ', outbag
45-
print ' Extracting topics: ', topics
43+
rospy.loginfo(' Processing input bagfile: %s', inbag)
44+
rospy.loginfo(' Writing to output bagfile: %s', outbag)
45+
rospy.loginfo(' Extracting topics: %s', topics)
4646

4747
outbag = rosbag.Bag(outbag,'w')
4848
for topic, msg, t in rosbag.Bag(inbag,'r').read_messages():
4949
if topic in topics:
5050
outbag.write(topic, msg, t)
51-
print 'Closing output bagfile and exit...'
51+
rospy.loginfo('Closing output bagfile and exit...')
5252
outbag.close();
5353

5454
if __name__ == "__main__":

0 commit comments

Comments
 (0)