I think I solved it properly, but just need your confirmation. Would you please verify my python code and output ?
I got the output with the code: roslaunch get_map_data map_data.launch
Following is my launch file code:
The idea is good, but the code is not correct. You cannot change the request message that you use in order to call the service (this is what you are doing). The request will be always the same (in this case, GetMapRequest). In fact, you are using Empty here, but the correct message type is GetMap. You can see this by executing:
rosservice info /static_map
Then, once you send the request and receive the response, you can modify this response as you please. So, the code would look something like this:
#! /usr/bin/env python
from nav_msgs.srv import GetMap, GetMapRequest
rospy.init_node('service_client') # Initialise a ROS node with the name service_client
rospy.wait_for_service('/static_map') # Wait for the service /static_map to be running
get_map_service = rospy.ServiceProxy('/static_map', GetMap) # Create the connection to the service
get_map = GetMapRequest() # Create an object of type GetMapRequest
result = get_map_service(get_map) # Call the service
print result.map.info.resolution # Print the result given by the service called
Thank you Professor Alberto @albertoezquerro
But, What does import sys do ?
It’s not necessary for this program, you can remove this line if you want.
Sure. Thank you Professor