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"
55 explicit ResourceManager(
const std::string & urdf,
bool validate_interfaces =
true);
71 void load_urdf(
const std::string & urdf,
bool validate_interfaces =
true);
203 std::unique_ptr<ActuatorInterface> actuator,
const HardwareInfo & hardware_info);
219 std::unique_ptr<SensorInterface> sensor,
const HardwareInfo & hardware_info);
235 std::unique_ptr<SystemInterface> system,
const HardwareInfo & hardware_info);
259 const std::vector<std::string> & start_interfaces,
260 const std::vector<std::string> & stop_interfaces);
274 const std::vector<std::string> & start_interfaces,
275 const std::vector<std::string> & stop_interfaces);
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_;
Virtual Class to implement when integrating a 1 DoF actuator into ros2_control.
Definition actuator_interface.hpp:67
Definition loaned_command_interface.hpp:27
Definition loaned_state_interface.hpp:27
void load_urdf(const std::string &urdf, bool validate_interfaces=true)
Load resources from on a given URDF.
Definition resource_manager.cpp:191
std::vector< std::string > command_interface_keys() const
Returns all registered command interfaces keys.
Definition resource_manager.cpp:284
bool command_interface_exists(const std::string &key) const
Checks whether a command interface is registered under the given key.
Definition resource_manager.cpp:294
bool command_interface_is_claimed(const std::string &key) const
Checks whether a command interface is already claimed.
Definition resource_manager.cpp:253
void import_component(std::unique_ptr< ActuatorInterface > actuator)
Import a hardware component which is not listed in the URDF.
Definition resource_manager.cpp:300
void read()
Reads all loaded hardware components.
Definition resource_manager.cpp:483
void stop_components()
Stops all loaded hardware components.
Definition resource_manager.cpp:467
void write()
Write all loaded hardware components.
Definition resource_manager.cpp:499
size_t sensor_components_size() const
Return the number of loaded sensor components.
Definition resource_manager.cpp:319
std::vector< std::string > state_interface_keys() const
Returns all registered state interfaces keys.
Definition resource_manager.cpp:237
size_t system_components_size() const
Return the number of loaded system components.
Definition resource_manager.cpp:352
void start_components()
Start all loaded hardware components.
Definition resource_manager.cpp:451
bool state_interface_exists(const std::string &key) const
Checks whether a state interface is registered under the given key.
Definition resource_manager.cpp:247
size_t actuator_components_size() const
Return the number size_t of loaded actuator components.
Definition resource_manager.cpp:308
std::unordered_map< std::string, rclcpp_lifecycle::State > get_components_states()
Return status for all components.
Definition resource_manager.cpp:357
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:395
ResourceManager()
Default constructor for the Resource Manager.
Definition resource_manager.cpp:181
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:424
LoanedCommandInterface claim_command_interface(const std::string &key)
Claim a command interface given its key.
Definition resource_manager.cpp:264
LoanedStateInterface claim_state_interface(const std::string &key)
Claim a state interface given its key.
Definition resource_manager.cpp:227
Definition resource_manager.cpp:39
Virtual Class to implement when integrating a stand-alone sensor into ros2_control.
Definition sensor_interface.hpp:67
Virtual Class to implement when integrating a complex system into ros2_control.
Definition system_interface.hpp:68
Definition actuator.hpp:29
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:101