-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathsdc_rosbag_viewer.py
executable file
·57 lines (42 loc) · 1.89 KB
/
sdc_rosbag_viewer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
#!/usr/bin/python
"""
sdc_rosbag_viewer.py: version 0.1 by Marius Slavescu
"""
import rospy
import pygame, sys
from pygame.locals import *
from sensor_msgs.msg import CompressedImage
import numpy as np
import cStringIO
#Initiates the display
pygame.init()
windowSurfaceObj= pygame.display.set_mode((320*3,240))
pygame.display.set_caption('SDC Viewer')
yellow = pygame.Color(245,210,0)
windowSurfaceObj.fill(pygame.Color(0,0,0))
pygame.display.update()
imgleft = pygame.surface.Surface((320,240),0,24).convert()
imgcenter = pygame.surface.Surface((320,240),0,24).convert()
imgright = pygame.surface.Surface((320,240),0,24).convert()
def compressedImageCB(ros_data):
fstr = cStringIO.StringIO(ros_data.data)
if ros_data._connection_header['topic'] == '/left_camera/image_color/compressed':
imgleft = pygame.transform.scale(pygame.image.load(fstr), (320, 240))
windowSurfaceObj.blit(imgleft, (0,0))
elif ros_data._connection_header['topic'] == '/center_camera/image_color/compressed':
imgcenter = pygame.transform.scale(pygame.image.load(fstr), (320, 240))
windowSurfaceObj.blit(imgcenter, (320,0))
elif ros_data._connection_header['topic'] == '/right_camera/image_color/compressed':
imgright = pygame.transform.scale(pygame.image.load(fstr), (320, 240))
windowSurfaceObj.blit(imgright, (640,0))
#pygame.display.flip() #
pygame.display.update()
def listener():
rospy.init_node('odom_graph', anonymous=True)
rospy.Subscriber("/left_camera/image_color/compressed", CompressedImage, compressedImageCB)
rospy.Subscriber("/center_camera/image_color/compressed", CompressedImage, compressedImageCB)
rospy.Subscriber("/right_camera/image_color/compressed", CompressedImage, compressedImageCB)
rospy.spin()
if __name__=="__main__":
listener()