Ask Your Question
0

Need help with map_saver

asked 2015-11-28 12:36:03 -0600

jhajj96 gravatar image

updated 2015-11-28 13:46:19 -0600

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-11-28 13:29:10 -0600

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

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-11-28 12:36:03 -0600

Seen: 82 times

Last updated: Nov 28 '15