publish_trajectory.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 import roslib
00003 roslib.load_manifest('smach_ros')
00004 roslib.load_manifest('actionlib')
00005 roslib.load_manifest('rfid_datacapture')
00006 roslib.load_manifest('rfid_demos')
00007 roslib.load_manifest('rfid_behaviors')
00008 roslib.load_manifest('hrl_lib')
00009 roslib.load_manifest('tf')
00010 roslib.load_manifest('sensor_msgs')
00011 roslib.load_manifest('visualization_msgs')
00012 import rospy
00013 
00014 import cPickle as pkl
00015 import hrl_lib.rutils as ru
00016 import hrl_lib.viz as viz
00017 import sensor_msgs.msg as sm
00018 import numpy as np, math
00019 import sm_aware_home_explore as ahe
00020 import visualization_msgs.msg as vm
00021 
00022 
00023 if __name__ == '__main__':
00024     import optparse
00025     p = optparse.OptionParser()
00026     p.add_option('--trial', action='store', type='int', dest='trial',
00027                  help='trial number (0-8)')
00028     # p.add_option('--fname', action='store', type='string', dest='fname',
00029     #              help='File name. Should be woot_150_x_reads.pkl', default='')
00030 
00031     opt, args = p.parse_args()
00032     
00033     fname = 'search_aware_home/woot_150_'+str(opt.trial)+'_reads.pkl'
00034 
00035     f = open( fname, 'r' )
00036     r = pkl.load(f)
00037     f.close()
00038 
00039     xyz = np.array([ [p.ps_base_map.pose.position.x,
00040                       p.ps_base_map.pose.position.y,
00041                       p.ps_base_map.pose.position.z ] for p in r ]).T
00042 
00043     rospy.init_node( 'pub_traj' )
00044     pts = ru.np_to_pointcloud( xyz, '/map' )
00045     pub_pts = rospy.Publisher( '/robot_traj', sm.PointCloud )
00046     pub_mark = rospy.Publisher( '/tag_poses', vm.Marker )
00047     rospy.sleep( 0.5 )
00048 
00049     tag_pts = np.array([ ahe.pts[k][1] for k in ahe.pts.keys() ]).T
00050     tm = [ viz.single_marker( tag_pts[:,i].reshape([3,1]),
00051                               np.matrix([ [0.0], [0.0], [0.0], [1.0] ]),
00052                               'sphere', '/map',
00053                               color=[0.0, 1.0, 0.0, 1.0],
00054                               m_id=i ) for i in xrange( tag_pts.shape[1] )]
00055     
00056 
00057     while not rospy.is_shutdown():
00058         pts.header.stamp = rospy.Time.now()
00059         pub_pts.publish( pts )
00060         [ pub_mark.publish( x ) for x in tm ]
00061         rospy.sleep( 1.0 )
00062         


rfid_datacapture
Author(s): Travis Deyle
autogenerated on Wed Nov 27 2013 12:11:16