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"
34 class ActuatorInterface;
35 class SensorInterface;
36 class SystemInterface;
37 class ResourceStorage;
42 std::vector<std::string> failed_hardware_names;
67 const std::string & urdf,
bool validate_interfaces =
true,
bool activate_all =
false);
86 const std::string & urdf,
bool validate_interfaces =
true,
87 bool load_and_initialize_components =
true);
97 bool is_urdf_already_loaded()
const;
115 std::vector<std::string> state_interface_keys()
const;
122 std::vector<std::string> available_state_interfaces()
const;
128 bool state_interface_is_available(
const std::string & name)
const;
140 void import_controller_reference_interfaces(
141 const std::string & controller_name, std::vector<CommandInterface> & interfaces);
150 std::vector<std::string> get_controller_reference_interface_names(
151 const std::string & controller_name);
161 void make_controller_reference_interfaces_available(
const std::string & controller_name);
171 void make_controller_reference_interfaces_unavailable(
const std::string & controller_name);
180 void remove_controller_reference_interfaces(
const std::string & controller_name);
190 void cache_controller_to_hardware(
191 const std::string & controller_name,
const std::vector<std::string> & interfaces);
201 std::vector<std::string> get_cached_controllers_to_hardware(
const std::string & hardware_name);
212 bool command_interface_is_claimed(
const std::string & key)
const;
230 std::vector<std::string> command_interface_keys()
const;
237 std::vector<std::string> available_command_interfaces()
const;
244 bool command_interface_is_available(
const std::string & interface)
const;
250 size_t actuator_components_size()
const;
256 size_t sensor_components_size()
const;
262 size_t system_components_size()
const;
277 void import_component(
278 std::unique_ptr<ActuatorInterface> actuator,
const HardwareInfo & hardware_info);
293 void import_component(
294 std::unique_ptr<SensorInterface> sensor,
const HardwareInfo & hardware_info);
309 void import_component(
310 std::unique_ptr<SystemInterface> system,
const HardwareInfo & hardware_info);
316 std::unordered_map<std::string, HardwareComponentInfo> get_components_status();
335 bool prepare_command_mode_switch(
336 const std::vector<std::string> & start_interfaces,
337 const std::vector<std::string> & stop_interfaces);
352 bool perform_command_mode_switch(
353 const std::vector<std::string> & start_interfaces,
354 const std::vector<std::string> & stop_interfaces);
369 return_type set_component_state(
370 const std::string & component_name, rclcpp_lifecycle::State & target_state);
397 "The method 'activate_all_components' is deprecated. "
398 "Use the new 'hardware_components_initial_state' parameter structure to setup the "
400 activate_all_components();
407 bool command_interface_exists(
const std::string & key)
const;
413 bool state_interface_exists(
const std::string & key)
const;
416 void validate_storage(
const std::vector<hardware_interface::HardwareInfo> & hardware_info)
const;
418 void release_command_interface(
const std::string & key);
420 std::unordered_map<std::string, bool> claimed_command_interface_map_;
422 mutable std::recursive_mutex resource_interfaces_lock_;
423 mutable std::recursive_mutex claimed_command_interfaces_lock_;
424 mutable std::recursive_mutex resources_lock_;
426 std::unique_ptr<ResourceStorage> resource_storage_;
431 bool is_urdf_loaded__ =
false;
Definition: loaned_command_interface.hpp:27
Definition: loaned_state_interface.hpp:27
Definition: resource_manager.hpp:46
Definition: actuator.hpp:31
This structure stores information about hardware defined in a robot's URDF.
Definition: hardware_info.hpp:106
Definition: resource_manager.hpp:40