Skip to content

SS-814 Revert "add intial_pose_is_ready flag" - Fix: robot localized with rviz, but keeps doing initialization behaviour #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: humble-devel
Choose a base branch
from

Conversation

TanmayDeshmukh
Copy link

@TanmayDeshmukh TanmayDeshmukh commented Apr 16, 2025

Problem

If robot is localized very quickly with rviz at launch (before AMCL was activated), it appears to be localized on rviz, but BT continues to perform initial location behaviour (spinning in place).
This can also happen if it saw a fiducial only once, and then robot spun and the fiducial immediately went out of sight.

Solution/Reason

This reverts commit 6d97e0e, which introduces a new flag initial_pose_is_ready_, to use in place of the existing initial_pose_is_ready_.

If an initial pose is received before activate, it is cached (through last_published_pose_) and used later when amcl is activated. This introduces a bug where the newly introduced initial_pose_is_ready_ never gets set to True so the service call BT uses to check if robot is localized keeps returning false

initial_pose_is_ready_ should have been set to true in places where the already existing initial_pose_is_known_ is set. (inside handleInitialPose() and globalLocalizationCallback())

initial_pose_is_ready_ would then become identical to initial_pose_is_known_, with the only difference being that the new variable is set before handleInitialPose().

handleInitialPose() delays setting it to true due to a lookuptransform inside - so the introduction of the new variable this was seemingly done for a minor time optimization as lookup transform takes time (100ms?). However this doesn't actually work because service calls and initial pose callback are on the same (main)executor anyway, which means while an initial pose is being processed, initialPoseStatus service calls get queued and wont respond until handleInitialPose() completes.

Note: AMCL has only two threads:

  • laser callback + the TF buffer on one Mutually exclusive cb group.
  • Everything else - lifecycle, services, dynamic parameter, odom, initial, external pose callbacks, particle filter

Related PR -

This reverts commit 6d97e0e.

If an initial pose is recieved before activate, it is cached and used later when amcl is activated. This introduces a bug where initial_pose_is_ready_ never gets set to True.
initial_pose_is_ready_ should have been set to true in places where the already existing initial_pose_is_known_ is set. (mainly handleInitialPose())

initial_pose_is_ready_ would then become identical to initial_pose_is_known_, with the only difference being that the new variable is set before handleInitialPose() which delays setting it to true due to a lookuptransform inside - this was supposedly done for a minor time optimization as lookup transform can take 100ms.
@TanmayDeshmukh TanmayDeshmukh requested a review from arekin19 April 16, 2025 09:07
Copy link

@TanmayDeshmukh TanmayDeshmukh changed the title Fix: robot localized with rviz, but keeps doing initialization behaviour- Revert "add intial_pose_is_ready flag" SS-814 Fix: robot localized with rviz, but keeps doing initialization behaviour- Revert "add intial_pose_is_ready flag" Apr 16, 2025
@TanmayDeshmukh TanmayDeshmukh changed the title SS-814 Fix: robot localized with rviz, but keeps doing initialization behaviour- Revert "add intial_pose_is_ready flag" SS-814 Revert "add intial_pose_is_ready flag" - Fix: robot localized with rviz, but keeps doing initialization behaviour Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant