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:
- 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.
- How do I call my get_pose_service.py file properly so that the map grid appears, without these errors and warnings ?
- 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
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.
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.
Again, Why do we mention
rospy.Service(). I expected
PoseWithCovarianceStamped here. And why do we
EmptyResponse(), why not
Would the code not suffice upto this point. Why do we further put
rospy.Subscriber(). Also, why /amcl_pose topic here ?
Why do we define a
Why do we write
global robot_pose ? Isn’t it already global. What’s the logic in putting global again here ?
robot_pose = msg.pose.pose ?
Thank you so much Professor.
This is probably because you haven’t launched the amcl node.
Launching the amcl node.
Yes, you need to move the robot to those spots and then call the service in order to get the pose.
Because you need to import the messages that your Service /get_pose_service uses.
Because this message (PoseWithCovarianceStamped) is not a service message, it’s a regular message.
Yes that’s right, you don’t need to import Pose() here. You can just use PoseWithCovarianceStamped().
Because the message used in the service is Empty. The PoseWithCovariacneStamped message is not used in any service, but in a subscriber.
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.
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.
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.
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.
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.