Go to the documentation of this file.00001
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 import tf
00022 import tf.transformations as tft
00023 import glob
00024 import json
00025 import yaml
00026 import time
00027 import os
00028
00029 rospy.init_node( 'derp' )
00030 vsm = viz.single_marker
00031 m_id = 0
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 fnames = glob.glob('Obj[0-9]_Trial[0-9]_Servo1_rel_results.pkl')
00054 def load( fn ):
00055 f = open( fn )
00056 dat = pkl.load( f )
00057 f.close()
00058 return dat
00059
00060 d = [ load( f ) for f in fnames ]
00061 d = [ di for di in d if di['pos_readings'] > 0 ]
00062
00063 def arrow( m_id, res_dict, color ):
00064 m = vsm( np.matrix([ res_dict['best_pos'] ]).T,
00065 np.matrix([ tft.quaternion_from_euler( 0.0,
00066 0.0,
00067 res_dict['orient_est']) ]).T,
00068 'arrow', '/map',
00069 scale = [0.5, 1.0, 1.0],
00070 color = color,
00071 duration = 10.0,
00072 m_id = m_id )
00073
00074
00075 return m
00076
00077 pub_mark = rospy.Publisher( '/tag_poses', vm.Marker )
00078
00079 tag_spheres = []
00080 servo_arrows = []
00081
00082 def hextorgba( h ):
00083 return h * 1.0 / 255.0
00084
00085 colors = [ [ hextorgba( i ) for i in [ 0x00, 0x99, 0x00, 0xFF ]],
00086 [ hextorgba( i ) for i in [ 0xEE, 0x00, 0x00, 0xFF ]],
00087 [ hextorgba( i ) for i in [ 0x00, 0xCC, 0xFF, 0xFF ]]]
00088
00089 for loc in range( 0, 9 ):
00090 m_id += 1
00091 color = colors[ loc % len(colors) ]
00092 tag_spheres.append( vsm( np.matrix([ ahe.pts[loc][1][0],
00093 ahe.pts[loc][1][1],
00094 ahe.pts[loc][1][2] ]).T,
00095 np.matrix([ [0.0], [0.0], [0.0], [1.0] ]),
00096 'sphere', '/map',
00097 color = color,
00098 duration = 10.0,
00099 m_id = m_id ))
00100
00101 for di in d:
00102 if di['loc'] == loc:
00103 m_id += 1
00104 servo_arrows.append( arrow( m_id, di, color ))
00105
00106
00107
00108 marks = tag_spheres + servo_arrows
00109
00110 while not rospy.is_shutdown():
00111 [ pub_mark.publish( x ) for x in marks ]
00112 rospy.sleep( 1.0 )
00113 print 'WOOT'
00114
00115