15#ifndef HARDWARE_INTERFACE__RESOURCE_MANAGER_HPP_
16#define HARDWARE_INTERFACE__RESOURCE_MANAGER_HPP_
21#include <unordered_map>
24#include "hardware_interface/hardware_component_info.hpp"
25#include "hardware_interface/hardware_info.hpp"
26#include "hardware_interface/loaned_command_interface.hpp"
27#include "hardware_interface/loaned_state_interface.hpp"
28#include "hardware_interface/types/hardware_interface_return_values.hpp"
29#include "rclcpp/duration.hpp"
30#include "rclcpp/time.hpp"
42 std::vector<std::string> failed_hardware_names;
67 const std::string & urdf,
bool validate_interfaces =
true,
bool activate_all =
false);
93 const std::string & urdf,
bool validate_interfaces =
true,
94 bool load_and_initialize_components =
true);
148 const std::string & controller_name, std::vector<CommandInterface> & interfaces);
158 const std::string & controller_name);
198 const std::string & controller_name,
const std::vector<std::string> & interfaces);
285 std::unique_ptr<ActuatorInterface> actuator,
const HardwareInfo & hardware_info);
301 std::unique_ptr<SensorInterface> sensor,
const HardwareInfo & hardware_info);
317 std::unique_ptr<SystemInterface> system,
const HardwareInfo & hardware_info);
343 const std::vector<std::string> & start_interfaces,
344 const std::vector<std::string> & stop_interfaces);
360 const std::vector<std::string> & start_interfaces,
361 const std::vector<std::string> & stop_interfaces);
377 const std::string & component_name, rclcpp_lifecycle::State & target_state);
404 "The method 'activate_all_components' is deprecated. "
405 "Use the new 'hardware_components_initial_state' parameter structure to setup the "
423 void validate_storage(
const std::vector<hardware_interface::HardwareInfo> & hardware_info)
const;
425 void release_command_interface(
const std::string & key);
427 std::unordered_map<std::string, bool> claimed_command_interface_map_;
429 mutable std::recursive_mutex resource_interfaces_lock_;
430 mutable std::recursive_mutex claimed_command_interfaces_lock_;
431 mutable std::recursive_mutex resources_lock_;
433 std::unique_ptr<ResourceStorage> resource_storage_;
438 bool is_urdf_loaded__ =
false;
Virtual Class to implement when integrating a 1 DoF actuator into ros2_control.
Definition actuator_interface.hpp:83
Definition loaned_command_interface.hpp:27
Definition loaned_state_interface.hpp:27
void make_controller_reference_interfaces_available(const std::string &controller_name)
Add controller's reference interface to available list.
Definition resource_manager.cpp:801
std::vector< std::string > command_interface_keys() const
Returns all registered command interfaces keys.
Definition resource_manager.cpp:936
bool command_interface_exists(const std::string &key) const
Checks whether a command interface is registered under the given key.
Definition resource_manager.cpp:1319
bool command_interface_is_claimed(const std::string &key) const
Checks whether a command interface is already claimed.
Definition resource_manager.cpp:895
return_type set_component_state(const std::string &component_name, rclcpp_lifecycle::State &target_state)
Sets state of hardware component.
Definition resource_manager.cpp:1164
bool shutdown_components()
Shutdown all hardware components, irrespective of their state.
Definition resource_manager.cpp:678
std::unordered_map< std::string, HardwareComponentInfo > get_components_status()
Return status for all components.
Definition resource_manager.cpp:995
void import_component(std::unique_ptr< ActuatorInterface > actuator, const HardwareInfo &hardware_info)
Import a hardware component which is not listed in the URDF.
Definition resource_manager.cpp:964
size_t sensor_components_size() const
Return the number of loaded sensor components.
Definition resource_manager.cpp:1309
void load_urdf(const std::string &urdf, bool validate_interfaces=true, bool load_and_initialize_components=true)
Load resources from on a given URDF.
Definition resource_manager.cpp:695
std::vector< std::string > state_interface_keys() const
Returns all registered state interfaces keys.
Definition resource_manager.cpp:755
bool is_urdf_already_loaded() const
if the resource manager load_urdf(...) function has been called this returns true....
Definition resource_manager.cpp:740
size_t system_components_size() const
Return the number of loaded system components.
Definition resource_manager.cpp:1314
std::vector< std::string > get_controller_reference_interface_names(const std::string &controller_name)
Get list of reference interface of a controller.
Definition resource_manager.cpp:794
bool command_interface_is_available(const std::string &interface) const
Checks whether a command interface is available under the given name.
Definition resource_manager.cpp:955
void import_controller_reference_interfaces(const std::string &controller_name, std::vector< CommandInterface > &interfaces)
Add controllers' reference interfaces to resource manager.
Definition resource_manager.cpp:784
std::vector< std::string > get_cached_controllers_to_hardware(const std::string &hardware_name)
Return cached controllers for a specific hardware.
Definition resource_manager.cpp:888
bool state_interface_is_available(const std::string &name) const
Checks whether a state interface is available under the given key.
Definition resource_manager.cpp:774
bool state_interface_exists(const std::string &key) const
Checks whether a state interface is registered under the given key.
Definition resource_manager.cpp:1326
void make_controller_reference_interfaces_unavailable(const std::string &controller_name)
Remove controller's reference interface to available list.
Definition resource_manager.cpp:813
size_t actuator_components_size() const
Return the number size_t of loaded actuator components.
Definition resource_manager.cpp:1304
HardwareReadWriteStatus read(const rclcpp::Time &time, const rclcpp::Duration &period)
Reads all loaded hardware components.
Definition resource_manager.cpp:1249
std::vector< std::string > available_command_interfaces() const
Returns all available command interfaces keys.
Definition resource_manager.cpp:948
void remove_controller_reference_interfaces(const std::string &controller_name)
Remove controllers reference interfaces from resource manager.
Definition resource_manager.cpp:836
bool prepare_command_mode_switch(const std::vector< std::string > &start_interfaces, const std::vector< std::string > &stop_interfaces)
Prepare the hardware components for a new command interface mode.
Definition resource_manager.cpp:1014
ResourceManager()
Default constructor for the Resource Manager.
Definition resource_manager.cpp:657
bool perform_command_mode_switch(const std::vector< std::string > &start_interfaces, const std::vector< std::string > &stop_interfaces)
Notify the hardware components that realtime hardware mode switching should occur.
Definition resource_manager.cpp:1124
std::vector< std::string > available_state_interfaces() const
Returns all available state interfaces keys.
Definition resource_manager.cpp:767
void activate_all_components()
Activates all available hardware components in the system.
Definition resource_manager.cpp:1409
LoanedCommandInterface claim_command_interface(const std::string &key)
Claim a command interface given its key.
Definition resource_manager.cpp:907
void cache_controller_to_hardware(const std::string &controller_name, const std::vector< std::string > &interfaces)
Cache mapping between hardware and controllers using it.
Definition resource_manager.cpp:848
LoanedStateInterface claim_state_interface(const std::string &key)
Claim a state interface given its key.
Definition resource_manager.cpp:743
HardwareReadWriteStatus write(const rclcpp::Time &time, const rclcpp::Duration &period)
Write all loaded hardware components.
Definition resource_manager.cpp:1277
Definition resource_manager.cpp:68
Virtual Class to implement when integrating a stand-alone sensor into ros2_control.
Definition sensor_interface.hpp:68
Virtual Class to implement when integrating a complex system into ros2_control.
Definition system_interface.hpp:85
Definition mujoco_system_interface.hpp:57
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:106
Definition resource_manager.hpp:40