How to call an msg file inside an srv file?
In the project I am currently working on, I am trying to call the /static_map
service using python file.
Generally, what I am trying to do is print the map
from /static_map
in which /static_map
is of type nav_msgs/GetMap
.
GetMap.srv
on the other hand consists of:
# Get the map as a nav_msgs/OccupancyGrid
---
nav_msgs/OccupancyGrid map
My question is how can I print the map
from the GetMap.srv
file considering that OccupancyGrid
is an msg
file?
This is OccupancyGrid.msg
file:
# This represents a 2-D grid map, in which each cell represents the probability of
# occupancy.
Header header
#MetaData for the map
MapMetaData info
# The map data, in row-major order, starting with (0,0). Occupancy
# probabilities are in the range [0,100]. Unknown is -1.
int8[] data
What I have implemented so far is as follow:
#! /usr/bin/env python
import rospy
from nav_msgs.srv import GetMap, GetMapResponse
from nav_msgs.msg import OccupancyGrid
def my_callback(request):
my_response = GetMapResponse()
return my_response
rospy.init_node('get_map_service')
map_service = rospy.Service('/static_map', GetMap, my_callback)
rospy.spin()
I have no errors whatsoever when I run this python file, but I just need it to print the map
.
@gvdhoorn I have tried to answer this question twice, and both times it was rejected as spam. The 2nd attempt did not even contain a live url.
Not entirely sure why you @-mention me specifically, but I guess it's because of this.
I've also opened osrf/infrastructure#6.
@gvdhoorn Thank you for opening the ticket. Your username has the highest karma I've seen here, so I figured you might be able to do something about it. To who should these kinds of site issues be reported?
I'm just a user, like you. But with more imaginary internet points.
There is an issue tracker specifically for ROS Answers: ros-infrastructure/answers.ros.org.
And a more generic one for "OSRF hosted infrastructure": osrf/infrastructure.
I've broken etiquette by posting to both (and ROS Discourse), but I figured it might save some people some frustration (this being a weekend and all, and it'll probably take some time to get things fixed).