File tree Expand file tree Collapse file tree 2 files changed +37
-9
lines changed Expand file tree Collapse file tree 2 files changed +37
-9
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ def main(args=None):
234
234
235
235
node .get_logger ().info (
236
236
bcolors .OKGREEN
237
- + "Configured and activated all the parsed controllers list!"
237
+ + f "Configured and activated all the parsed controllers list : { controller_names } !"
238
238
+ bcolors .ENDC
239
239
)
240
240
@@ -258,16 +258,25 @@ def main(args=None):
258
258
)
259
259
return 1
260
260
261
- node .get_logger ().info ("Deactivated controller" )
262
-
263
- ret = unload_controller (node , controller_manager_name , controller_name )
264
- if not ret .ok :
265
- node .get_logger ().error (
266
- bcolors .FAIL + "Failed to unload controller" + bcolors .ENDC
261
+ node .get_logger ().info (
262
+ f"Successfully deactivated controllers : { controller_names } "
267
263
)
268
- return 1
269
264
270
- node .get_logger ().info ("Unloaded controller" )
265
+ unload_status = True
266
+ for controller_name in controller_names :
267
+ ret = unload_controller (node , controller_manager_name , controller_name )
268
+ if not ret .ok :
269
+ unload_status = False
270
+ node .get_logger ().error (
271
+ bcolors .FAIL
272
+ + f"Failed to unload controller : { controller_name } "
273
+ + bcolors .ENDC
274
+ )
275
+
276
+ if unload_status :
277
+ node .get_logger ().info (f"Successfully unloaded controllers : { controller_names } " )
278
+ else :
279
+ return 1
271
280
return 0
272
281
except KeyboardInterrupt :
273
282
pass
Original file line number Diff line number Diff line change @@ -328,6 +328,25 @@ TEST_F(TestLoadController, unload_on_kill)
328
328
ASSERT_EQ (cm_->get_loaded_controllers ().size (), 0ul );
329
329
}
330
330
331
+ TEST_F (TestLoadController, unload_on_kill_activate_as_group)
332
+ {
333
+ // Launch spawner with unload on kill
334
+ // timeout command will kill it after the specified time with signal SIGINT
335
+ ControllerManagerRunner cm_runner (this );
336
+ cm_->set_parameter (rclcpp::Parameter (" ctrl_3.type" , test_controller::TEST_CONTROLLER_CLASS_NAME));
337
+ cm_->set_parameter (rclcpp::Parameter (" ctrl_2.type" , test_controller::TEST_CONTROLLER_CLASS_NAME));
338
+ std::stringstream ss;
339
+ ss << " timeout --signal=INT 5 "
340
+ << std::string (coveragepy_script) +
341
+ " $(ros2 pkg prefix controller_manager)/lib/controller_manager/spawner "
342
+ << " ctrl_3 ctrl_2 --activate-as-group -c test_controller_manager --unload-on-kill" ;
343
+
344
+ EXPECT_NE (std::system (ss.str ().c_str ()), 0 )
345
+ << " timeout should have killed spawner and returned non 0 code" ;
346
+
347
+ ASSERT_EQ (cm_->get_loaded_controllers ().size (), 0ul );
348
+ }
349
+
331
350
TEST_F (TestLoadController, spawner_test_fallback_controllers)
332
351
{
333
352
const std::string test_file_path = ament_index_cpp::get_package_prefix (" controller_manager" ) +
You can’t perform that action at this time.
0 commit comments