Rosanswers logo

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)

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):

    test_map.data = array



if name == 'main': try: mapMethod() except rospy.ROSInterruptException: pass

Originally posted by jhajj96 on ROS Answers with karma: 1 on 2015-11-28

Post score: 0


1 Answer 1


Rosanswers logo

Check your topics - I think map_saver will be subscribing to the topic /map and waiting for a map to be published on that topic

Originally posted by nickw with karma: 1504 on 2015-11-28

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.