capture_experiment.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 import roslib; roslib.load_manifest('pr2_omni_teleop')
00003 import rospy
00004 import hrl_camera.ros_camera as rc
00005 import cv
00006 import hrl_lib.rutils as ru
00007 import hrl_lib.util as ut
00008 import math
00009 
00010 #TF
00011 import tf
00012 import hrl_lib.tf_utils as tfu
00013 import tf.transformations as tr
00014 
00015 
00016 if __name__ == '__main__':
00017     import sys
00018 
00019     base_name = sys.argv[1]
00020     test = 'laser'
00021     ls = ru.LaserScanner('point_cloud_srv')
00022     prosilica = rc.Prosilica('prosilica', 'streaming')
00023     tf_listener = tf.TransformListener()
00024 
00025     rospy.loginfo( 'Getting laser scan.')
00026     points = ls.scan(math.radians(180.), math.radians(-180.), 20.)
00027     rospy.loginfo('Size of point cloud: %d' % len(points.points))
00028     rospy.loginfo( 'Grabbing image.')
00029     image = prosilica.get_frame()
00030     rospy.loginfo( 'Grabbing transforms.')
00031 
00032     #transform from tilt_laser => base_footprint (pointcloud is already in base_footprint)
00033     #transform from base_footprint => (pose of head) prosilica
00034     pro_T_bf = tfu.transform('/high_def_optical_frame', '/base_footprint', tf_listener)
00035 
00036     #transform from base_footprint => map
00037     map_T_bf = tfu.transform('/map', '/base_footprint', tf_listener)
00038 
00039     #get camera's P matrix
00040     rospy.loginfo('Waiting for camera_info.')
00041     calibration = rc.ROSCameraCalibration('/prosilica/camera_info')
00042     r = rospy.Rate(10)
00043     while not rospy.is_shutdown() and calibration.has_msg == False:
00044         r.sleep()
00045 
00046     rospy.loginfo('Saving.')
00047     pkl_name = '%s.pkl' % base_name
00048     img_name = '%s.png' % base_name
00049     ut.save_pickle({'points': points, 
00050                     'pro_T_bf': pro_T_bf, 
00051                     'map_T_bf': map_T_bf, 
00052                     'camera_info': calibration},  pkl_name)
00053     cv.SaveImage(img_name, image)
00054     rospy.loginfo( 'Saved to %s and %s.' % (pkl_name, img_name))
00055 
00056 


pr2_omni_teleop
Author(s): Hai Nguyen, Marc Killpack Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 11:51:39