Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 import sys
00008 import re
00009 import roslib; roslib.load_manifest('modular_cloud_matcher')
00010 import rospy
00011 import point_cloud
00012 from std_msgs.msg import String, Header
00013 from sensor_msgs.msg import PointCloud
00014 from geometry_msgs.msg import *
00015 from modular_cloud_matcher.srv import *
00016
00017 def createCloud(fileName):
00018 points = []
00019 for line in open(fileName):
00020 splittedLine = re.split('(?:\s|[,]|\n)+', line.strip())
00021 coord = map(float, splittedLine)
00022 while len(coord) < 3:
00023 coord.append(0)
00024 points.append(coord)
00025 return point_cloud.create_cloud_xyz32(Header(),points)
00026
00027 def icpcontrol(referenceFileName, readingsFileName):
00028 serviceName = '/match_clouds'
00029 rospy.init_node('cloud_matcher_control')
00030 rospy.wait_for_service(serviceName)
00031
00032 reference = createCloud(referenceFileName)
00033
00034 readings = createCloud(readingsFileName)
00035
00036 try:
00037 matchClouds = rospy.ServiceProxy(serviceName, MatchClouds)
00038 finalTransform = matchClouds(reference, readings)
00039 print finalTransform
00040 except rospy.ServiceException, e:
00041 print "Service call failed: %s"%e
00042
00043 if __name__ == '__main__':
00044 if len(sys.argv) != 3:
00045 print 'Usage: ' + sys.argv[0] + ' reference reading'
00046 sys.exit()
00047 icpcontrol(sys.argv[1], sys.argv[2])