Skip to content

Commit 7232128

Browse files
committed
fix - remove duplication of add_managed_entity from interface_factory
- test fix for test_dock_database - change method name from 'activate'->'on_activate' majorly over nav2_route pkg - implement manual ordered service activation policy Signed-off-by: Prathmesh Atkale <atkaleprathmesh@gmail.com>
1 parent 8361e44 commit 7232128

32 files changed

Lines changed: 121 additions & 74 deletions

File tree

nav2_amcl/src/amcl_node.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ AmclNode::on_activate(const rclcpp_lifecycle::State & /*state*/)
167167
// create bond connection
168168
createBond();
169169

170+
global_loc_srv_->on_activate();
171+
initial_guess_srv_->on_activate();
172+
nomotion_update_srv_->on_activate();
173+
170174
return nav2::CallbackReturn::SUCCESS;
171175
}
172176

@@ -175,6 +179,10 @@ AmclNode::on_deactivate(const rclcpp_lifecycle::State & /*state*/)
175179
{
176180
RCLCPP_INFO(get_logger(), "Deactivating");
177181

182+
global_loc_srv_->on_deactivate();
183+
initial_guess_srv_->on_deactivate();
184+
nomotion_update_srv_->on_deactivate();
185+
178186
active_ = false;
179187

180188
// Lifecycle publishers must be explicitly deactivated

nav2_behavior_tree/include/nav2_behavior_tree/plugins/control/pause_resume_controller.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ class PauseResumeController : public BT::ControlNode
9191
const std::string & xml_tag_name,
9292
const BT::NodeConfiguration & conf);
9393

94+
//! @brief Destructor
95+
~PauseResumeController() override;
96+
9497
//! @brief Reset state and go to Idle
9598
void halt() override;
9699

nav2_behavior_tree/plugins/control/pause_resume_controller.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ PauseResumeController::PauseResumeController(
6161
resume_srv_->on_activate();
6262
}
6363

64+
PauseResumeController::~PauseResumeController()
65+
{
66+
pause_srv_->on_deactivate();
67+
resume_srv_->on_deactivate();
68+
69+
pause_srv_.reset();
70+
resume_srv_.reset();
71+
}
72+
6473
BT::NodeStatus PauseResumeController::tick()
6574
{
6675
unsigned int children_count = children_nodes_.size();

nav2_collision_monitor/src/collision_monitor_node.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ nav2::CallbackReturn
114114
CollisionMonitor::on_activate(const rclcpp_lifecycle::State & /*state*/)
115115
{
116116
RCLCPP_INFO(get_logger(), "Activating");
117-
toggle_cm_service_->on_activate();
118117

119118
// Activating lifecycle publisher
120119
cmd_vel_out_pub_->on_activate();
@@ -135,6 +134,8 @@ CollisionMonitor::on_activate(const rclcpp_lifecycle::State & /*state*/)
135134
// Activating main worker
136135
process_active_ = true;
137136

137+
toggle_cm_service_->on_activate();
138+
138139
// Creating bond connection
139140
createBond();
140141

nav2_costmap_2d/include/nav2_costmap_2d/clear_costmap_service.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ class ClearCostmapService
5656
*/
5757
~ClearCostmapService();
5858

59+
/**
60+
* @brief Activate the clear costmap services
61+
*/
62+
void on_activate();
63+
64+
/**
65+
* @brief Deactivate the clear costmap services
66+
*/
67+
void on_deactivate();
68+
5969
/**
6070
* @brief Clears the region outside of a user-specified area reverting to the static map
6171
*/

nav2_costmap_2d/include/nav2_costmap_2d/costmap_2d_publisher.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ class Costmap2DPublisher
9595
costmap_update_pub_->on_activate();
9696
costmap_raw_pub_->on_activate();
9797
costmap_raw_update_pub_->on_activate();
98+
costmap_service_->on_activate();
9899
}
99100

100101
/**
101102
* @brief deactivate node
102103
*/
103104
void on_deactivate()
104105
{
106+
costmap_service_->on_deactivate();
105107
costmap_pub_->on_deactivate();
106108
costmap_update_pub_->on_deactivate();
107109
costmap_raw_pub_->on_deactivate();

nav2_costmap_2d/src/clear_costmap_service.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ ClearCostmapService::~ClearCostmapService()
7575
clear_entire_service_.reset();
7676
}
7777

78+
void ClearCostmapService::on_activate()
79+
{
80+
clear_except_service_->on_activate();
81+
clear_around_service_->on_activate();
82+
clear_around_pose_service_->on_activate();
83+
clear_entire_service_->on_activate();
84+
}
85+
86+
void ClearCostmapService::on_deactivate()
87+
{
88+
clear_except_service_->on_deactivate();
89+
clear_around_service_->on_deactivate();
90+
clear_around_pose_service_->on_deactivate();
91+
clear_entire_service_->on_deactivate();
92+
}
93+
7894
void ClearCostmapService::clearExceptRegionCallback(
7995
const shared_ptr<rmw_request_id_t>/*request_header*/,
8096
const shared_ptr<ClearExceptRegion::Request> request,

nav2_costmap_2d/src/costmap_2d_ros.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ Costmap2DROS::on_activate(const rclcpp_lifecycle::State & /*state*/)
327327
std::bind(&Costmap2DROS::validateParameterUpdatesCallback, this, _1));
328328

329329
get_cost_service_->on_activate();
330+
clear_costmap_service_->on_activate();
330331

331332
return nav2::CallbackReturn::SUCCESS;
332333
}
@@ -336,6 +337,7 @@ Costmap2DROS::on_deactivate(const rclcpp_lifecycle::State & /*state*/)
336337
{
337338
RCLCPP_INFO(get_logger(), "Deactivating");
338339
get_cost_service_->on_deactivate();
340+
clear_costmap_service_->on_deactivate();
339341

340342
remove_post_set_parameters_callback(post_set_params_handler_.get());
341343
post_set_params_handler_.reset();

nav2_docking/opennav_docking/src/dock_database.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ void DockDatabase::activate()
7070
for (it = dock_plugins_.begin(); it != dock_plugins_.end(); ++it) {
7171
it->second->activate();
7272
}
73+
reload_db_service_->on_activate();
7374
}
7475

7576
void DockDatabase::deactivate()
7677
{
78+
reload_db_service_->on_deactivate();
7779
DockPluginMap::iterator it;
7880
for (it = dock_plugins_.begin(); it != dock_plugins_.end(); ++it) {
7981
it->second->deactivate();

nav2_docking/opennav_docking/test/test_dock_database.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,14 @@ TEST(DatabaseTests, ObjectLifecycle)
5757
auto node = std::make_shared<nav2::LifecycleNode>("test");
5858
std::mutex mutex;
5959
opennav_docking::DockDatabase db(mutex);
60-
db.initialize(node, nullptr);
61-
db.activate();
62-
db.deactivate();
60+
bool initialized = db.initialize(node, nullptr);
61+
EXPECT_FALSE(initialized);
62+
63+
// ONLY activate if initialization was successful
64+
if (initialized) {
65+
db.activate();
66+
db.deactivate();
67+
}
6368

6469
EXPECT_EQ(db.plugin_size(), 0u);
6570
EXPECT_EQ(db.instance_size(), 0u);
@@ -151,6 +156,7 @@ TEST(DatabaseTests, reloadDbService)
151156
db.initialize(node, nullptr);
152157
node->configure();
153158
node->activate();
159+
db.activate();
154160

155161
// Call service with a filepath
156162
auto client =

0 commit comments

Comments
 (0)