Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 import roslib
00041 roslib.load_manifest('flirtlib_ros')
00042
00043 import sys
00044 import geometry_msgs.msg as gm
00045 import sensor_msgs.msg as sm
00046 import rospy
00047 import tf.transformations as trans
00048 from math import sin, cos
00049 import mongo_ros as mr
00050 import flirtlib_ros.msg as fm
00051
00052 def scan2cloud(scan, pose):
00053 x0 = pose.position.x
00054 y0 = pose.position.y
00055 print "Angle is ", pose.orientation
00056 theta0 = trans.euler_from_quaternion([pose.orientation.x, pose.orientation.y,
00057 pose.orientation.z, pose.orientation.w])[2]
00058 print "Base pos is {0}, {1}, {2}".format(x0, y0, theta0)
00059 cloud = sm.PointCloud()
00060 cloud.header.frame_id='/map'
00061 cloud.header.stamp = rospy.Time.now()
00062 cloud.points = []
00063 for i, r in enumerate(scan.ranges):
00064 theta = theta0 + scan.angle_min + i*scan.angle_increment
00065 p = gm.Point32(x0+cos(theta)*r, y0+sin(theta)*r, 0)
00066 cloud.points.append(p)
00067
00068 return cloud
00069
00070
00071 def main():
00072 rospy.init_node('test_scan')
00073 c=mr.MessageCollection('flirtlib_place_rec', 'scans', fm.RefScanRos,
00074 db_host='mongo.willowgarage.com')
00075 l = list(c.query({}))
00076 if len(sys.argv!=2):
00077 print "Usage: {0} SCAN_NUM".format(sys.argv[0])
00078 i = int(sys.argv[1])
00079 print "Visualizing scan ", i
00080 msg = l[i][0]
00081 cl = scan2cloud(msg.scan, msg.pose)
00082 pub = rospy.Publisher('saved_cloud', sm.PointCloud, latch=True)
00083 pub.publish(cl)
00084 rospy.spin()
00085
00086 if __name__=='__main__':
00087 sys.exit(main())
00088
00089
00090