OccupancyGrid not getting published - Python.
Hi, so I want to publish an occupancy grid of a map.png file I have.
After running this node, I do rostopic list but it doesn't show me any published map. Can someone tell what am I doing wrong?
#!/usr/bin/env python
import rospy
import cv2 as cv
from nav_msgs.msg import *
from std_msgs.msg import *
grid = OccupancyGrid()
def load():
img = cv.imread('map.png', 0)
for i in range(len(img)):
img[i] = (img[i] / 255) * 100
grid.data = img
pub.publish(grid)
def main():
rospy.init_node('loadmap', anonymous = True)
global pub
pub = rospy.Publisher('/map', OccupancyGrid, queue_size = 10)
load()
rospy.spin
if __name__ == '__main__':
try:
main()
except rospy.ROSInterruptException:
pass