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

Synchronize map size information during map initialization #4015

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions nav2_costmap_2d/src/costmap_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@
Costmap2D::Costmap2D(
unsigned int cells_size_x, unsigned int cells_size_y, double resolution,
double origin_x, double origin_y, unsigned char default_value)
: size_x_(cells_size_x), size_y_(cells_size_y), resolution_(resolution), origin_x_(origin_x),
: resolution_(resolution), origin_x_(origin_x),
origin_y_(origin_y), costmap_(NULL), default_value_(default_value)
{
access_ = new mutex_t();

// create the costmap
initMaps(size_x_, size_y_);
initMaps(cells_size_x, cells_size_y);
resetMaps();
}

Expand Down Expand Up @@ -102,15 +102,15 @@
{
std::unique_lock<mutex_t> lock(*access_);
delete[] costmap_;
size_x_ = size_x;
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
size_y_ = size_y;
costmap_ = new unsigned char[size_x * size_y];
}

void Costmap2D::resizeMap(
unsigned int size_x, unsigned int size_y, double resolution,
double origin_x, double origin_y)
{
size_x_ = size_x;
size_y_ = size_y;
resolution_ = resolution;
origin_x_ = origin_x;
origin_y_ = origin_y;
Expand Down Expand Up @@ -166,15 +166,12 @@
// ROS_ERROR("Cannot window a map that the window bounds don't fit inside of");
return false;
}

size_x_ = upper_right_x - lower_left_x;
size_y_ = upper_right_y - lower_left_y;
resolution_ = map.resolution_;
origin_x_ = win_origin_x;
origin_y_ = win_origin_y;

// initialize our various maps and reset markers for inflation
initMaps(size_x_, size_y_);
initMaps(upper_right_x - lower_left_x, upper_right_y - lower_left_y);

Check warning on line 174 in nav2_costmap_2d/src/costmap_2d.cpp

View check run for this annotation

Codecov / codecov/patch

nav2_costmap_2d/src/costmap_2d.cpp#L174

Added line #L174 was not covered by tests

// copy the window of the static map and the costmap that we're taking
copyMapRegion(
Expand Down