Exercise 2.7 of ROS Navigation

Respected community,
This is a pic of exercise 2.7 that’s asked

Now, I solved it by writing the code below

  1. For call_map_service.py file:
    #! /usr/bin/env python

    import rospy
    from std_srvs.srv import Empty, EmptyRequest

    rospy.init_node(‘map_server’)
    rospy.wait_for_service(’/static_map’)
    get_map_data_service = rospy.ServiceProxy(’/static_map’, Empty)
    get_map_data_object = EmptyRequest()
    result = get_map_data_service(get_map_data_object)
    print result

  2. For .launch file:

     <node pkg="map_server"
         type="map_server"
         name="map_server"
         output="screen"
         args="/home/user/catkin_ws/src/my_map.yaml"/>
    

And then I launched it using roslaunch get_map_data map_data.launch command. In the next shell, I called using rosservice call /static_map “{}”.
Below was the output

Everything went smooth without error, BUT, I’m feeling like I didn’t do it the way it was asked to or the way I was supposed to do.
Would you tell me what’s missing and how can I correct it ?
The expected output for this exercise is not written, So I can’t compare it.
The reason I have the feelings that it’s not what I was supposed to do is that it’s output is exactly the same as the exercise 2.5. And I wondered what was the objective of the exercise. Or what was the takeaway from it.

Hello @abdulbasitisdost,

You don’t need to call the service with the “rosservice call…” command because you are already calling the Service in your Python script. The purpose of this exercise is to actually test this, to call to the /static_map service using code instead of the “rosservice call…” command, and also to filter the response of the Service: the exercise asks you to print only the dimensions and resolution of the map, which is only a part of the map info (and not the whole data).

Best,

Ok Prof, But my python script is not giving me any output.