Navigation - Exercise 3.5

Respected Professor,
I was trying to solve exercise 3.5.

I ran into error, so I went for solution.

Now I had my python and launch file ready. I tried the following commands in shell #1 and #2 respectively:


As I opened the rviz window, I got the map given below:

I have quite a few doubts in this exercise. So would you please clarify them:

  1. Why did I get the map like in the image above where there’s nothing shown? Also there are few things shown in red and orange which I suppose imply Errors and warning.
  2. How do I call my get_pose_service.py file properly so that the map grid appears, without these errors and warnings ?
  3. In the Exercise, point e) says, “Using your Service, get the pose data from these 2 spots in the environment”. I can’t get my head around this. How would I do that ? Do I need to launch any keyboard_teleop file too for this task?

Now there are few things I didn’t understand while going through the solution. They are:
4. Why do we need this line of code:
from std_srvs.srv import Empty, EmptyResponse

  1. Usually we write the Response of whatever we import from a message. But, here we have imported PoseWithCovarianceStamped from geometry_msgs.msg without writing PoseWithCovarianceStampedResponse with it.

  2. Why do we import Pose here. I saw the structure of PoseWithCovarianceStamped and realized that it gives position and orientation. So isn’t that enough. What if we don’t import Pose.

  3. Again, Why do we mention Empty in rospy.Service(). I expected PoseWithCovarianceStamped here. And why do we return EmptyResponse(), why not PoseWithCovarianceStampedResponse() ?

  4. Would the code not suffice upto this point. Why do we further put rospy.Subscriber(). Also, why /amcl_pose topic here ?

  5. Why do we define a sub_callback() ?

  6. Why do we write global robot_pose ? Isn’t it already global. What’s the logic in putting global again here ?

  7. What is robot_pose = msg.pose.pose ?

Thank you so much Professor.

Hello @abdulbasitisdost,

  1. This is probably because you haven’t launched the amcl node.

  2. Launching the amcl node.

  3. Yes, you need to move the robot to those spots and then call the service in order to get the pose.

  4. Because you need to import the messages that your Service /get_pose_service uses.

  5. Because this message (PoseWithCovarianceStamped) is not a service message, it’s a regular message.

  6. Yes that’s right, you don’t need to import Pose() here. You can just use PoseWithCovarianceStamped().

  7. Because the message used in the service is Empty. The PoseWithCovariacneStamped message is not used in any service, but in a subscriber.

  8. Because we want to get the pose of the robot. Therefore, we subscribe to the topic /amcl_pose in order to get this data. This is explained in the notebook of the Unit.

  9. Because we want to create a Subscriber in order to read the pose of the robot from the /amcl_pose topic. Therefore we need to define a callback function.

  10. Because you need to specify the keyword global whenever you want to modify a global variable. You can see this in the Python for robotics course.

  11. robot_pose is a variable that you have defined. msg.pose.pose is accessing the full message read from the /amcl_pose topic (which is of the type PoseWithCovarianceStamped), and getting only the Pose information (without the covariance part in this case).

PS: I think it would be good if you review the ROS Basics course since you are lacking some of the basic concepts explained there. It’s much more complicated to understand more complex programs without this basic knowledge.

Best,

1 Like

Thank you so much Professor Alberto @albertoezquerro for your precious time.
Actually I didn’t do the last project of ROS Basics yet. So I think solving that would make my basics strong again. I was in hurry to complete navigation part to submit my project report here. I took this risk of accepting navigation part and now I’m in hurry to understand and work on it before 9th of this month.
Once again, thank you Professor for your kind responses.