15 #ifndef HARDWARE_INTERFACE__RESOURCE_MANAGER_HPP_
16 #define HARDWARE_INTERFACE__RESOURCE_MANAGER_HPP_
21 #include <unordered_map>
24 #include "hardware_interface/hardware_info.hpp"
25 #include "hardware_interface/loaned_command_interface.hpp"
26 #include "hardware_interface/loaned_state_interface.hpp"
27 #include "rclcpp_lifecycle/state.hpp"
31 class ActuatorInterface;
32 class SensorInterface;
33 class SystemInterface;
34 class ResourceStorage;
55 explicit ResourceManager(
const std::string & urdf,
bool validate_interfaces =
true);
71 void load_urdf(
const std::string & urdf,
bool validate_interfaces =
true);
90 std::vector<std::string> state_interface_keys()
const;
96 bool state_interface_exists(
const std::string & key)
const;
107 bool command_interface_is_claimed(
const std::string & key)
const;
126 std::vector<std::string> command_interface_keys()
const;
133 bool command_interface_exists(
const std::string & key)
const;
139 size_t actuator_components_size()
const;
151 void import_component(std::unique_ptr<ActuatorInterface> actuator);
157 size_t sensor_components_size()
const;
169 void import_component(std::unique_ptr<SensorInterface> sensor);
175 size_t system_components_size()
const;
187 void import_component(std::unique_ptr<SystemInterface> system);
202 void import_component(
203 std::unique_ptr<ActuatorInterface> actuator,
const HardwareInfo & hardware_info);
218 void import_component(
219 std::unique_ptr<SensorInterface> sensor,
const HardwareInfo & hardware_info);
234 void import_component(
235 std::unique_ptr<SystemInterface> system,
const HardwareInfo & hardware_info);
241 std::unordered_map<std::string, rclcpp_lifecycle::State> get_components_states();
258 bool prepare_command_mode_switch(
259 const std::vector<std::string> & start_interfaces,
260 const std::vector<std::string> & stop_interfaces);
273 bool perform_command_mode_switch(
274 const std::vector<std::string> & start_interfaces,
275 const std::vector<std::string> & stop_interfaces);
278 void start_components();
281 void stop_components();
290 void validate_storage(
const std::vector<hardware_interface::HardwareInfo> & hardware_info)
const;
292 void release_command_interface(
const std::string & key);
294 std::unordered_map<std::string, bool> claimed_command_interface_map_;
296 mutable std::recursive_mutex resource_lock_;
297 std::unique_ptr<ResourceStorage> resource_storage_;
Definition: loaned_command_interface.hpp:27
Definition: loaned_state_interface.hpp:27
Definition: resource_manager.hpp:37
Definition: actuator.hpp:29
This structure stores information about hardware defined in a robot's URDF.
Definition: hardware_info.hpp:101