Need help with map_saver
Hey, I'm a beginner to ros so I apologize if this is a dumb question, but I have been wanting to use the map_server package to save an OccupancyGrid. I found a tutorial for using map_saver but it was related to gmapping, which I am not using. In order to test it out, I created the following node to just publish a simple 2x2 OccupancyGrid. However when I run "rosrun map_server map_saver", it will say it is waiting for a map even though my node is running. I was wondering what I'm doing wrong here. I am using Windows 10 and running ros on the Oracle Virtual Machine using Vagrant, and have roscore running.
#!/usr/bin/env python
import rospy import sys
from nav_msgs.msg import *
from std_msgs.msg import *
def mapMethod():
pub = rospy.Publisher('saved_maps', OccupancyGrid, queue_size=10)
rospy.init_node('saved_maps_node', anonymous=True)
X_VALUE = 2
Y_VALUE = 2
rate = rospy.Rate(0.5) #delay time (times per second)
while not rospy.is_shutdown():
test_map = OccupancyGrid()
test_map.info.width = X_VALUE
test_map.info.height = Y_VALUE
test_map.info.origin.position.x = 0
test_map.info.origin.position.x = 0
array = []
for i in range(0, X_VALUE * Y_VALUE):
array.append(1)
test_map.data = array
pub.publish(test_map)
print(test_map.data)
rate.sleep()
if __name__ == '__main__': try: mapMethod() except rospy.ROSInterruptException: pass