Skip to content

Commit e8b1ff1

Browse files
mamueluthmergify[bot]
authored andcommitted
add spawner for hardware (#941)
* add spwaner for hardware * aplly suggestions from code review * move comment (cherry picked from commit 937817c) # Conflicts: # controller_manager/src/controller_manager.cpp
1 parent d6b660e commit e8b1ff1

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

controller_manager/src/controller_manager.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
406406
// inactive (configured)
407407
// BEGIN: Keep old functionality on for backwards compatibility (Remove at the end of 2023)
408408
std::vector<std::string> configure_components_on_start = std::vector<std::string>({});
409+
<<<<<<< HEAD
409410
get_parameter("configure_components_on_start", configure_components_on_start);
410411
if (!configure_components_on_start.empty())
411412
{
@@ -427,10 +428,25 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
427428
"hardware_components_initial_state.inactive",
428429
rclcpp_lifecycle::State(
429430
State::PRIMARY_STATE_INACTIVE, hardware_interface::lifecycle_state_names::INACTIVE));
431+
=======
432+
if (get_parameter("configure_components_on_start", configure_components_on_start))
433+
{
434+
RCLCPP_WARN_STREAM(
435+
get_logger(),
436+
"[Deprecated]: Usage of parameter \"activate_components_on_start\" is deprecated. Use "
437+
"hardware_spawner instead.");
438+
rclcpp_lifecycle::State inactive_state(
439+
State::PRIMARY_STATE_INACTIVE, hardware_interface::lifecycle_state_names::INACTIVE);
440+
for (const auto & component : configure_components_on_start)
441+
{
442+
resource_manager_->set_component_state(component, inactive_state);
443+
}
444+
>>>>>>> 937817c (add spawner for hardware (#941))
430445
}
431446

432447
// BEGIN: Keep old functionality on for backwards compatibility (Remove at the end of 2023)
433448
std::vector<std::string> activate_components_on_start = std::vector<std::string>({});
449+
<<<<<<< HEAD
434450
get_parameter("activate_components_on_start", activate_components_on_start);
435451
rclcpp_lifecycle::State active_state(
436452
State::PRIMARY_STATE_ACTIVE, hardware_interface::lifecycle_state_names::ACTIVE);
@@ -441,13 +457,22 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
441457
"Parameter 'activate_components_on_start' is deprecated. "
442458
"Components are activated per default. Don't use this parameters in combination with the new "
443459
"'hardware_components_initial_state' parameter structure.");
460+
=======
461+
if (get_parameter("activate_components_on_start", activate_components_on_start))
462+
{
463+
RCLCPP_WARN_STREAM(
464+
get_logger(),
465+
"[Deprecated]: Usage of parameter \"activate_components_on_start\" is deprecated. Use "
466+
"hardware_spawner instead.");
467+
>>>>>>> 937817c (add spawner for hardware (#941))
444468
rclcpp_lifecycle::State active_state(
445469
State::PRIMARY_STATE_ACTIVE, hardware_interface::lifecycle_state_names::ACTIVE);
446470
for (const auto & component : activate_components_on_start)
447471
{
448472
resource_manager_->set_component_state(component, active_state);
449473
}
450474
}
475+
<<<<<<< HEAD
451476
// END: Keep old functionality on humble for backwards compatibility (Remove at the end of 2023)
452477
else
453478
{
@@ -458,6 +483,17 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
458483
State::PRIMARY_STATE_ACTIVE, hardware_interface::lifecycle_state_names::ACTIVE);
459484
resource_manager_->set_component_state(component, active_state);
460485
}
486+
=======
487+
// if both parameter are empty or non-existing preserve behavior where all components are
488+
// activated per default
489+
if (configure_components_on_start.empty() && activate_components_on_start.empty())
490+
{
491+
RCLCPP_WARN_STREAM(
492+
get_logger(),
493+
"[Deprecated]: Automatic activation of all hardware components will not be supported in the "
494+
"future anymore. Use hardware_spawner instead.");
495+
resource_manager_->activate_all_components();
496+
>>>>>>> 937817c (add spawner for hardware (#941))
461497
}
462498
}
463499

0 commit comments

Comments
 (0)