Skip to content

Commit 09244d5

Browse files
add new costmap
1 parent 67d1913 commit 09244d5

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

nav2_controller/include/nav2_controller/controller_server.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,11 @@ class ControllerServer : public nav2_util::LifecycleNode
228228
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros_;
229229
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> narrow_costmap_ros_;
230230
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> sensor_costmap_ros_;
231+
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> global_no_waiting_zone_costmap_ros_;
231232
std::unique_ptr<nav2_util::NodeThread> costmap_thread_;
232233
std::unique_ptr<nav2_util::NodeThread> narrow_costmap_thread_;
233234
std::unique_ptr<nav2_util::NodeThread> sensor_costmap_thread_;
235+
std::unique_ptr<nav2_util::NodeThread> global_no_waiting_zone_costmap_thread_;
234236

235237
// Publishers and subscribers
236238
std::unique_ptr<nav_2d_utils::OdomSubscriber> odom_sub_;

nav2_controller/src/controller_server.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ ControllerServer::ControllerServer(const rclcpp::NodeOptions & options)
8181
sensor_costmap_ros_ = std::make_shared<nav2_costmap_2d::Costmap2DROS>(
8282
"sensor_local_costmap", std::string{get_namespace()}, "sensor_local_costmap",
8383
get_parameter("use_sim_time").as_bool(), options.use_intra_process_comms());
84+
85+
// The costmap node is used by BT to validate that a path can be driven on
86+
global_no_waiting_zone_costmap_ros_ = std::make_shared<nav2_costmap_2d::Costmap2DROS>(
87+
"global_no_waiting_zones_costmap", std::string{get_namespace()}, "global_no_waiting_zones_costmap",
88+
get_parameter("use_sim_time").as_bool(), options.use_intra_process_comms());
8489
}
8590

8691
ControllerServer::~ControllerServer()
@@ -147,10 +152,12 @@ ControllerServer::on_configure(const rclcpp_lifecycle::State & state)
147152
costmap_ros_->configure();
148153
narrow_costmap_ros_->configure();
149154
sensor_costmap_ros_->configure();
155+
global_no_waiting_zone_costmap_ros_->configure();
150156
// Launch a thread to run the costmap node
151157
costmap_thread_ = std::make_unique<nav2_util::NodeThread>(costmap_ros_);
152158
narrow_costmap_thread_ = std::make_unique<nav2_util::NodeThread>(narrow_costmap_ros_);
153159
sensor_costmap_thread_ = std::make_unique<nav2_util::NodeThread>(sensor_costmap_ros_);
160+
global_no_waiting_zone_costmap_thread_ = std::make_unique<nav2_util::NodeThread>(global_no_waiting_zone_costmap_ros_);
154161

155162
for (size_t i = 0; i != progress_checker_ids_.size(); i++) {
156163
try {
@@ -294,6 +301,7 @@ ControllerServer::on_activate(const rclcpp_lifecycle::State & /*state*/)
294301
}
295302
narrow_costmap_ros_->activate();
296303
sensor_costmap_ros_->activate();
304+
global_no_waiting_zone_costmap_ros_->activate();
297305
ControllerMap::iterator it;
298306
for (it = controllers_.begin(); it != controllers_.end(); ++it) {
299307
it->second->activate();
@@ -333,6 +341,7 @@ ControllerServer::on_deactivate(const rclcpp_lifecycle::State & /*state*/)
333341
costmap_ros_->deactivate();
334342
narrow_costmap_ros_->deactivate();
335343
sensor_costmap_ros_->deactivate();
344+
global_no_waiting_zone_costmap_ros_->deactivate();
336345

337346
// Always publish a zero velocity when deactivating the controller server
338347
geometry_msgs::msg::TwistStamped velocity;

0 commit comments

Comments
 (0)