help with simple /map publisher that will not publish - python
How do I publish this test data to the /map topic. I would like to use this routine to test other things I'm working on. I think I'm doing it right but when I type 'rostopic echo /map' I see nothing. If I run the script at the command prompt after typing 'roscore' in another terminal I see the test OccupancyGrid on the screen. I don't know what I'm doing wrong.
#!/usr/bin/env python
import rospy
import sys
from nav_msgs.msg import *
from std_msgs.msg import *
def map_stuff():
rospy.init_node('turtlebot_map', anonymous=True)
if not rospy.is_shutdown():
create_map()
rospy.spin()
def create_map( ):
test_map = OccupancyGrid()
test_map.info.resolution = 1.0
test_map.info.width = 10
test_map.info.height = 10
test_map.info.origin.position.x = 0.0
test_map.info.origin.position.y = 1.0
test_map.info.origin.position.z = 2.0
test_map.info.origin.orientation.x = 3.0
test_map.info.origin.orientation.y = 4.0
test_map.info.origin.orientation.z = 5.0
test_map.info.origin.orientation.w = 6.0
test_map.data = []
for i in range(0, 100):
test_map.data.append(i)
print test_map
map_pub = rospy.Publisher('/map', OccupancyGrid)
map_pub.publish(test_map);
return
if __name__ == '__main__':
try:
map_stuff()
except rospy.ROSInterruptException:
pass
I followed online tutorials as closely as I could. Any help would be appreciated.
You can help me build my map, it is not working?