Skip to content
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

Fixed bug causing global planner to plan to wrong cell #1219

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

Conversation

siferati
Copy link

@siferati siferati commented Oct 6, 2022

Description

Fixed a bug that was causing the global planner to compute paths to the wrong cell.
This allowed the global planner to return paths that were in collision.
You can see in the picture below how the global plan clearly ends inside the inscribed region of the costmap (i.e. collision!)

image

When the param old_navfn_behavior was set to false, the worldToMap function was subtracting 0.5 from the resulting cell coordinates, which is wrong. Although it makes sense to add 0.5 when converting from map to world (in order to return the center of the cell rather than the corner), the opposite is not true!

You can also confirm how in Costmap2D::mapToWorld we add 0.5 to get the center of the cell, but we don't subtract 0.5 when doing the opposite operation in Costmap2D::worldToMap.

void Costmap2D::mapToWorld(unsigned int mx, unsigned int my, double& wx, double& wy) const
{
wx = origin_x_ + (mx + 0.5) * resolution_;
wy = origin_y_ + (my + 0.5) * resolution_;
}

bool Costmap2D::worldToMap(double wx, double wy, unsigned int& mx, unsigned int& my) const
{
if (wx < origin_x_ || wy < origin_y_)
return false;
mx = (int)((wx - origin_x_) / resolution_);
my = (int)((wy - origin_y_) / resolution_);
if (mx < size_x_ && my < size_y_)
return true;
return false;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants