Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion controller_manager/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,12 @@ void ControllerManager::init_resource_manager(const std::string & robot_descript
{
resource_manager_->import_joint_limiters(robot_description_);
}
if (!resource_manager_->load_and_initialize_components(robot_description, update_rate_))
hardware_interface::ResourceManagerParams params;
params.robot_description = robot_description;
params.clock = trigger_clock_;
params.logger = this->get_logger();
params.executor = executor_;
if (!resource_manager_->load_and_initialize_components(params))
{
RCLCPP_WARN(
get_logger(),
Expand Down
51 changes: 51 additions & 0 deletions hardware_interface/include/hardware_interface/resource_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,57 @@ class ResourceManager
* \param[in] system pointer to the system interface.
* \param[in] hardware_info hardware info
*/
void import_component(
std::unique_ptr<SystemInterface> system, const HardwareComponentParams & params);

/// Import a hardware component which is not listed in the URDF
/**
* Components which are initialized outside a URDF can be added post initialization.
* Nevertheless, there should still be `HardwareInfo` available for this component,
* either parsed from a URDF string (easiest) or filled manually.
*
* \note this might invalidate existing state and command interfaces and should thus
* not be called when a controller is running.
* \note given that no hardware_info is available, the component has to be configured
* externally and prior to the call to import.
* \param[in] actuator pointer to the actuator interface.
* \param[in] params Struct of type HardwareComponentParams containing the hardware info
* and other parameters for the component.
*/
void import_component(
std::unique_ptr<ActuatorInterface> actuator, const HardwareComponentParams & params);

/// Import a hardware component which is not listed in the URDF
/**
* Components which are initialized outside a URDF can be added post initialization.
* Nevertheless, there should still be `HardwareInfo` available for this component,
* either parsed from a URDF string (easiest) or filled manually.
*
* \note this might invalidate existing state and command interfaces and should thus
* not be called when a controller is running.
* \note given that no hardware_info is available, the component has to be configured
* externally and prior to the call to import.
* \param[in] sensor pointer to the sensor interface.
* \param[in] params Struct of type HardwareComponentParams containing the hardware info
* and other parameters for the component.
*/
void import_component(
std::unique_ptr<SensorInterface> sensor, const HardwareComponentParams & params);

/// Import a hardware component which is not listed in the URDF
/**
* Components which are initialized outside a URDF can be added post initialization.
* Nevertheless, there should still be `HardwareInfo` available for this component,
* either parsed from a URDF string (easiest) or filled manually.
*
* \note this might invalidate existing state and command interfaces and should thus
* not be called when a controller is running.
* \note given that no hardware_info is available, the component has to be configured
* externally and prior to the call to import.
* \param[in] system pointer to the system interface.
* \param[in] params Struct of type HardwareComponentParams containing the hardware info
* and other parameters for the component.
*/
void import_component(
std::unique_ptr<SystemInterface> system, const HardwareInfo & hardware_info);

Expand Down
34 changes: 29 additions & 5 deletions hardware_interface/src/resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1908,29 +1908,53 @@ std::string ResourceManager::get_command_interface_data_type(const std::string &

void ResourceManager::import_component(
std::unique_ptr<ActuatorInterface> actuator, const HardwareInfo & hardware_info)
{
HardwareComponentParams params;
params.hardware_info = hardware_info;
import_component(std::move(actuator), params);
}

void ResourceManager::import_component(
std::unique_ptr<SensorInterface> sensor, const HardwareInfo & hardware_info)
{
HardwareComponentParams params;
params.hardware_info = hardware_info;
import_component(std::move(sensor), params);
}

void ResourceManager::import_component(
std::unique_ptr<SystemInterface> system, const HardwareInfo & hardware_info)
{
HardwareComponentParams params;
params.hardware_info = hardware_info;
import_component(std::move(system), params);
}

void ResourceManager::import_component(
std::unique_ptr<ActuatorInterface> actuator, const HardwareComponentParams & params)
{
std::lock_guard<std::recursive_mutex> guard(resources_lock_);
resource_storage_->initialize_actuator(std::move(actuator), hardware_info);
resource_storage_->initialize_actuator(std::move(actuator), params);
read_write_status.failed_hardware_names.reserve(
resource_storage_->actuators_.size() + resource_storage_->sensors_.size() +
resource_storage_->systems_.size());
}

void ResourceManager::import_component(
std::unique_ptr<SensorInterface> sensor, const HardwareInfo & hardware_info)
std::unique_ptr<SensorInterface> sensor, const HardwareComponentParams & params)
{
std::lock_guard<std::recursive_mutex> guard(resources_lock_);
resource_storage_->initialize_sensor(std::move(sensor), hardware_info);
resource_storage_->initialize_sensor(std::move(sensor), params);
read_write_status.failed_hardware_names.reserve(
resource_storage_->actuators_.size() + resource_storage_->sensors_.size() +
resource_storage_->systems_.size());
}

void ResourceManager::import_component(
std::unique_ptr<SystemInterface> system, const HardwareInfo & hardware_info)
std::unique_ptr<SystemInterface> system, const HardwareComponentParams & params)
{
std::lock_guard<std::recursive_mutex> guard(resources_lock_);
resource_storage_->initialize_system(std::move(system), hardware_info);
resource_storage_->initialize_system(std::move(system), params);
read_write_status.failed_hardware_names.reserve(
resource_storage_->actuators_.size() + resource_storage_->sensors_.size() +
resource_storage_->systems_.size());
Expand Down
Loading