Go to the documentation of this file.00001
00002 import roslib; roslib.load_manifest('jsk_pr2_startup')
00003 import rospy
00004 import math
00005 from struct import *
00006 from sensor_msgs.msg import *
00007
00008 def talker():
00009 rospy.init_node('empty_cloud_publisher')
00010 pub = rospy.Publisher('empty_cloud', PointCloud2)
00011 frame_id = rospy.get_param('frame_id', '/base_laser_link')
00012 while not rospy.is_shutdown():
00013 msg = PointCloud2()
00014 msg.header.stamp = rospy.Time.now()
00015 msg.header.frame_id = frame_id
00016 msg.height = 1
00017 msg.width = 72
00018
00019
00020 msg_fieldx = PointField()
00021 msg_fieldy = PointField()
00022 msg_fieldz = PointField()
00023 msg_fieldx.name = 'x'
00024 msg_fieldx.offset = 0
00025 msg_fieldx.datatype = 7
00026 msg_fieldx.count = 1
00027 msg_fieldy.name = 'y'
00028 msg_fieldy.offset = 4
00029 msg_fieldy.datatype = 7
00030 msg_fieldy.count = 1
00031 msg_fieldz.name = 'z'
00032 msg_fieldz.offset = 8
00033 msg_fieldz.datatype = 7
00034 msg_fieldz.count = 1
00035
00036 msg.fields = [msg_fieldx, msg_fieldy, msg_fieldz]
00037 msg.point_step = 16
00038 msg.row_step = msg.point_step * msg.width;
00039 msg.is_dense = True
00040
00041 for i in range(-32,32):
00042 x = 25*math.cos(i*0.01)
00043 y = 25*math.sin(i*0.01)
00044 z = 0.0
00045 msg.data += pack('<f', x)
00046 msg.data += pack('<f', y)
00047 msg.data += pack('<f', z)
00048 msg.data += pack('<f', 0)
00049
00050 pub.publish(msg)
00051 rospy.sleep(0.1)
00052
00053 if __name__ == '__main__':
00054 try:
00055 talker()
00056 except rospy.ROSInterruptException: pass