- The node which publishes the
map
->odom
tranform this time isamcl
, but only after the 2D Pose Estimate is selected. Note that this can be very inaccurate at first, but as the robot moves around, it will become increasingly accurate.Gazebo (actual) Rviz2 (probabilistic) Detail - AMCL stands for Adaptive Monte Carlo Localization. Essentially, adaptive particle filters.
With the 2D Pose Estimate function. The estimated pose is reported as follows:
[INFO] [1724444325.415770770] [rviz2]: Setting estimate pose: Frame:map, Position(-0.921304, -1.54146, 0), Orientation(0, 0, 0.973229, 0.229838) = Angle: 2.67777
Note:
- Frame: map.
- Position: Vector3 (x, y, z).
- Oriantation: Quaternion (x, y, z, w).
- Yaw angle.
Note:
- The
amcl
node reports setting it:[amcl-2] [INFO] [1724445452.744257169] [amcl]: Setting pose (3127.998000): -0.921 -1.541 2.678
ros2 topic echo /clicked_point
.- In Rviz2, click Publish Point, the point will be published to the
/clicked_point
topic. Note that this point is only {x, y, z}, without any rotation. - Publish to the
/initialpoint
topic published byamcl
as follows, optionally populating with the echoed data:ros2 topic pub -1 /initialpose geometry_msgs/msg/PoseWithCovarianceStamped "{header: {stamp: {sec: 0}, frame_id: 'map'}, pose: {pose: {position: {x: 0.2, y: 0.0, z: 0.0}, orientation: {w: 1.0}}}}"
- Write a Python file for a node with a subscriber to
/clicked_point
and a publisher to/initialpoint
. - Put it under the
localization_server
Python package (__init__.py
), that is, inlocalization_server/localization_server
. - Add a line to
entry_points
, for example:entry_points={ 'console_scripts': [ 'initial_pose_pub = localization_server.initial_pose_pub:main', # Note: No .py! ], },
- Note that the first
initial_pose_pub
is the name of the executable and what is used in the launch file. - This is an interactive solution. When the node is running, selecting a point with Publish Point will populate the initial pose.
- Increase the number of particles as in amcl_config_global.yaml. Change the name in the launch file.
- Recompile.
- Launch the localization.
- Pick a pose estimate.
- Now execute:
ros2 service call /reinitialize_global_localization std_srvs/srv/Empty