sparse_occupancy_grid_sample.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import rospy
00004 from jsk_recognition_msgs.msg import *
00005 from geometry_msgs.msg import Point
00006 rospy.init_node("test_occupancy_grid")
00007 
00008 p = rospy.Publisher("/occupancy_grid", SimpleOccupancyGridArray)
00009 
00010 r = rospy.Rate(1)
00011 
00012 def cells(x_offset):
00013     ret = []
00014     for i in range(0, 20):
00015         for j in range(0, 20):
00016             ret.append(Point(x = 0.05 * i + x_offset, y = 0.05 * j, z = 0))
00017     return ret
00018 
00019 
00020 while not rospy.is_shutdown():
00021     now = rospy.Time.now()
00022     occupancy_grid_array = SimpleOccupancyGridArray()
00023     for i in range(10):
00024         occupancy_grid = SimpleOccupancyGrid()
00025         occupancy_grid.header.frame_id = "map"
00026         occupancy_grid.header.stamp = now
00027         occupancy_grid.coefficients = [0, 0, 1, i * 0.2]
00028         occupancy_grid.resolution = 0.05      #5cm resolution
00029         occupancy_grid.cells = cells(i / 2.0)
00030         occupancy_grid_array.grids.append(occupancy_grid)
00031     occupancy_grid_array.header.stamp = now
00032     occupancy_grid_array.header.frame_id = "map"
00033     p.publish(occupancy_grid_array)
00034     r.sleep()    


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Wed May 1 2019 02:40:22