@@ -574,9 +574,14 @@ ControllerManager::ControllerManager(
574574 kControllerInterfaceNamespace , kControllerInterfaceClassName )),
575575 chainable_loader_(
576576 std::make_shared<pluginlib::ClassLoader<controller_interface::ChainableControllerInterface>>(
577- kControllerInterfaceNamespace , kChainableControllerInterfaceClassName )),
578- robot_description_(resource_manager_->get_robot_description ())
577+ kControllerInterfaceNamespace , kChainableControllerInterfaceClassName ))
579578{
579+ if (resource_manager_ == nullptr )
580+ {
581+ throw std::runtime_error (" The parsed resource manager is a nullptr!" );
582+ }
583+
584+ robot_description_ = resource_manager_->get_robot_description ();
580585 initialize_parameters ();
581586 if (is_resource_manager_initialized ())
582587 {
@@ -586,8 +591,20 @@ ControllerManager::ControllerManager(
586591 }
587592 else
588593 {
589- RCLCPP_FATAL (get_logger (), " The resource manager is not properly initialized" );
590- throw std::runtime_error (" Resource manager object is not valid. See the FATAL message above." );
594+ if (!robot_description_.empty ())
595+ {
596+ RCLCPP_FATAL (get_logger (), " The resource manager is not properly initialized" );
597+ throw std::runtime_error (
598+ " Resource manager object is not valid. See the FATAL message above." );
599+ }
600+ else
601+ {
602+ RCLCPP_WARN (
603+ get_logger (),
604+ " The resource manager is not yet initialized, will wait for the robot description to "
605+ " initialize it.." );
606+ init_controller_manager ();
607+ }
591608 }
592609}
593610
@@ -803,7 +820,10 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
803820 params.return_failed_hardware_names_on_return_deactivate_write_cycle_ =
804821 params_->defaults .deactivate_controllers_on_hardware_self_deactivate ;
805822 params.handle_exceptions = params_->handle_exceptions ;
806- resource_manager_ = std::make_unique<hardware_interface::ResourceManager>(params, false );
823+ if (resource_manager_ == nullptr )
824+ {
825+ resource_manager_ = std::make_unique<hardware_interface::ResourceManager>(params, false );
826+ }
807827
808828 resource_manager_->set_on_component_state_switch_callback (
809829 std::bind (&ControllerManager::publish_activity, this ));
0 commit comments