Skip to content
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
12 changes: 12 additions & 0 deletions nav2_costmap_2d/src/costmap_2d_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,26 +173,38 @@ Costmap2DROS::on_configure(const rclcpp_lifecycle::State & /*state*/)
RCLCPP_INFO(get_logger(), "Using plugin \"%s\"", plugin_names_[i].c_str());

std::shared_ptr<Layer> plugin = plugin_loader_.createSharedInstance(plugin_types_[i]);

// lock the costmap because no update is allowed until the plugin is initialized
std::unique_lock<Costmap2D::mutex_t> lock(*(layered_costmap_->getCostmap()->getMutex()));

layered_costmap_->addPlugin(plugin);

// TODO(mjeronimo): instead of get(), use a shared ptr
plugin->initialize(
layered_costmap_.get(), plugin_names_[i], tf_buffer_.get(),
shared_from_this(), callback_group_);

lock.unlock();

RCLCPP_INFO(get_logger(), "Initialized plugin \"%s\"", plugin_names_[i].c_str());
}
// and costmap filters as well
for (unsigned int i = 0; i < filter_names_.size(); ++i) {
RCLCPP_INFO(get_logger(), "Using costmap filter \"%s\"", filter_names_[i].c_str());

std::shared_ptr<Layer> filter = plugin_loader_.createSharedInstance(filter_types_[i]);

// lock the costmap because no update is allowed until the filter is initialized
std::unique_lock<Costmap2D::mutex_t> lock(*(layered_costmap_->getCostmap()->getMutex()));

layered_costmap_->addFilter(filter);

filter->initialize(
layered_costmap_.get(), filter_names_[i], tf_buffer_.get(),
shared_from_this(), callback_group_);

lock.unlock();

RCLCPP_INFO(get_logger(), "Initialized costmap filter \"%s\"", filter_names_[i].c_str());
}

Expand Down