This depends on where your robot is spawned. In the end, the pose
in /odom
is only the dead-reckoning pose, i.e. estimated from wheel revolutions.
What you would need to do this properly is some kind of localization algorithm that corrects the odometry drift using e.g. a laserscanner. amcl
is a package that implements this. See this section about the used/provided transforms.
EDIT
To fake a localization, you can use a static_transform_publisher
(documented on the wiki) to publish the transform from map
to odom
. This can then be static, as we are assuming that the transfrom from odom
to base_link
is accurate. This should however be published by your robot's base driver / simulation.
Obviously, the transform from map
to odom
needs to reflect the starting position of your robot.
Originally posted by mgruhler with karma: 12390 on 2019-03-08
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by anirban on 2019-03-08:
Thank you for your response and I know that /odom
data is inaccurate. Assuming /odom
data as actual robot location, my question is how to know coordinate of the robot in occupancy grid map so that I can use my custom planner.
Comment by mgruhler on 2019-03-08:
see edit above
Comment by anirban on 2019-03-08:
Thank you for the edit which is really helpful. I think what you said regarding transform between from \map
frame to \odom
frame is correct in the context of localization in unknown map. But since I am interested in planning
when the map
is known, I need transform from \odom
to \map
.
Comment by mgruhler on 2019-03-11:
@anirban well, one is the inverse of the other, so it doesn't really matter much. You can get the transforms in any direction you want with a transform listener...
However, as the ROS tf tree is using a directed structure, I suggest to use the standard approach of using map
as parent and odom
as child frame.
But I agree that the direction of the graph can be confusing.
Comment by anirban on 2019-03-11:
@mgruhler thanks for the clarification. Yes it is better to stick with the convention that \odom
as a child of \map
frame.