How to return a particular response in ROS service?
I'm trying to return GetMap.srv through a python code.
The basic overlay of the process is as below,
- I have
service = rospy.Service('static_map',GetMap,static_map_callback)
an initialization as above, with theservice name
- static_map, andservice type
- GetMap. - The
static_map_callback
function is being used to process requests and finally return a response.
The callback function is defined as below.
def static_map_callback(req):
response = GetMap()
response = map_params.map_callback()
return response
The contents of GetMap.srv are,
# Get the map as a nav_msgs/OccupancyGrid
---
nav_msgs/OccupancyGrid map
- Using the
callback
, I want to return the Nav_msg/OccupancyGrid
It would be helpful if anyone could guide me on what changes the callback should undergo so that I can return the required response.
Or
How do I use the callback
to return the relative GetMap content.
I did go through the tutorials of services, I'm unable to comprehend what changes are to be made with the
example: s = rospy.Service('add_two_ints', AddTwoInts, handle_add_two_ints)
handle_add_two_ints function which represents the static_map_callback()
in case of my code, to return the required response.
Thank you.