Skip to main content

🎯 Pose Setter Node

See the source code for implementation details.

The Pose Setter Node ensures that the robot's internal localization system starts from a known, accurate position on the map.
It publishes an initial pose to Nav2's AMCL (Adaptive Monte Carlo Localization) or other localization systems.


🗺 Pose Management System​

When Nav2 starts, it needs to know where the robot is in the map coordinate frame.
If the pose is wrong, navigation will fail or produce unsafe paths.

Pose Setter Node functions:

  1. Publishes /initialpose (geometry_msgs/PoseWithCovarianceStamped) with predefined coordinates.
  2. Ensures AMCL aligns the robot with the saved map.
  3. Can be triggered manually or run automatically at startup.

🔄 Coordinate Transformations​

ROS2 uses the TF2 transform system to keep track of coordinate frames:

  • map → global reference frame
  • odom → short-term odometry frame
  • base_link → robot's base frame

When you set an initial pose, you are placing base_link in the map frame.

Example transform chain after pose set:

map → odom → base_link → camera_link / arm_link

📏 Calibration Procedures​

One-time setup:

  1. Place the robot at your desired "base position" in the real world.
  2. In RViz, use the 2D Pose Estimate tool to align robot on the map.
  3. Echo /amcl_pose:
    ros2 topic echo /amcl_pose
  4. Copy the position (x, y) and orientation quaternion (or yaw) into your pose_setter.py file:
    BASE_POSE = (1.9525, -9.8651, 108.25)  # x, y, yaw in degrees

▶️ Usage Examples​

1. Run Pose Setter at Startup​

ros2 run pose_setter pose_setter_node

This will automatically publish the stored base pose.

2. Update Base Pose via Parameters​

ros2 run pose_setter pose_setter_node --ros-args -p base_x:=2.0 -p base_y:=-8.0 -p base_yaw:=90.0

3. Verify in RViz​

Open RViz and check robot position aligns with the map.


🛠 Troubleshooting Guide​

IssuePossible CauseSolution
Robot starts in wrong locationIncorrect pose values or wrong map frameRecalibrate in RViz, update BASE_POSE
Pose doesn't update in Nav2AMCL not running or /initialpose not receivedEnsure AMCL node is active
Robot drifts after setting posePoor localization quality or sensor noiseImprove map quality, check LiDAR alignment
Node crashes on startInvalid parameter typesEnsure numbers are floats, yaw in degrees
Pro Tip

Always set the pose before sending navigation goals to avoid planning errors.


📚 Learn More​


🎯 Next Steps​