@@ -49,8 +49,7 @@ class HARDWARE_INTERFACE_PUBLIC ResourceManager
49
49
{
50
50
public:
51
51
// / Default constructor for the Resource Manager.
52
- ResourceManager (
53
- unsigned int update_rate = 100 ,
52
+ explicit ResourceManager (
54
53
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface = nullptr );
55
54
56
55
// / Constructor for the Resource Manager.
@@ -59,18 +58,16 @@ class HARDWARE_INTERFACE_PUBLIC ResourceManager
59
58
* hardware components listed within as well as populate their respective
60
59
* state and command interfaces.
61
60
*
62
- * If the interfaces ought to be validated, the constructor throws an exception
63
- * in case the URDF lists interfaces which are not available.
64
- *
65
61
* \param[in] urdf string containing the URDF.
66
- * \param[in] validate_interfaces boolean argument indicating whether the exported
67
- * interfaces ought to be validated. Defaults to true.
68
62
* \param[in] activate_all boolean argument indicating if all resources should be immediately
69
63
* activated. Currently used only in tests.
64
+ * \param[in] update_rate Update rate of the controller manager to calculate calling frequency
65
+ * of async components.
66
+ * \param[in] clock_interface reference to the clock interface of the CM node for getting time
67
+ * used for triggering async components.
70
68
*/
71
69
explicit ResourceManager (
72
- const std::string & urdf, bool validate_interfaces = true , bool activate_all = false ,
73
- unsigned int update_rate = 100 ,
70
+ const std::string & urdf, bool activate_all = false , const unsigned int update_rate = 100 ,
74
71
rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface = nullptr );
75
72
76
73
ResourceManager (const ResourceManager &) = delete ;
@@ -79,29 +76,26 @@ class HARDWARE_INTERFACE_PUBLIC ResourceManager
79
76
80
77
// / Load resources from on a given URDF.
81
78
/* *
82
- * The resource manager can be post initialized with a given URDF.
79
+ * The resource manager can be post- initialized with a given URDF.
83
80
* This is mainly used in conjunction with the default constructor
84
81
* in which the URDF might not be present at first initialization.
85
82
*
86
83
* \param[in] urdf string containing the URDF.
87
- * \param[in] validate_interfaces boolean argument indicating whether the exported
88
- * interfaces ought to be validated. Defaults to true.
89
- * \param[in] load_and_initialize_components boolean argument indicating whether to load and
90
- * initialize the components present in the parsed URDF. Defaults to true.
84
+ * \param[in] update_rate update rate of the main control loop, i.e., of the controller manager.
85
+ * \returns false if URDF validation has failed.
91
86
*/
92
- void load_urdf (
93
- const std::string & urdf, bool validate_interfaces = true ,
94
- bool load_and_initialize_components = true );
87
+ virtual bool load_and_initialize_components (
88
+ const std::string & urdf, const unsigned int update_rate = 100 );
95
89
96
90
/* *
97
- * @brief if the resource manager load_urdf (...) function has been called this returns true.
98
- * We want to permit to load the urdf later on but we currently don't want to permit multiple
99
- * calls to load_urdf (reloading/loading different urdf).
91
+ * @brief if the resource manager load_and_initialize_components (...) function has been called
92
+ * this returns true. We want to permit to loading the urdf later on, but we currently don't want
93
+ * to permit multiple calls to load_and_initialize_components (reloading/loading different urdf).
100
94
*
101
- * @return true if resource manager's load_urdf() has been already called.
102
- * @return false if resource manager's load_urdf() has not been yet called .
95
+ * @return true if the resource manager has successfully loaded and initialized the components
96
+ * @return false if the resource manager doesn't have any components loaded and initialized .
103
97
*/
104
- bool is_urdf_already_loaded () const ;
98
+ bool are_components_initialized () const ;
105
99
106
100
// / Claim a state interface given its key.
107
101
/* *
@@ -413,23 +407,24 @@ class HARDWARE_INTERFACE_PUBLIC ResourceManager
413
407
*/
414
408
bool state_interface_exists (const std::string & key) const ;
415
409
410
+ protected:
411
+ bool components_are_loaded_and_initialized_ = false ;
412
+
413
+ mutable std::recursive_mutex resource_interfaces_lock_;
414
+ mutable std::recursive_mutex claimed_command_interfaces_lock_;
415
+ mutable std::recursive_mutex resources_lock_;
416
+
416
417
private:
417
- void validate_storage (const std::vector<hardware_interface::HardwareInfo> & hardware_info) const ;
418
+ bool validate_storage (const std::vector<hardware_interface::HardwareInfo> & hardware_info) const ;
418
419
419
420
void release_command_interface (const std::string & key);
420
421
421
422
std::unordered_map<std::string, bool > claimed_command_interface_map_;
422
423
423
- mutable std::recursive_mutex resource_interfaces_lock_;
424
- mutable std::recursive_mutex claimed_command_interfaces_lock_;
425
- mutable std::recursive_mutex resources_lock_;
426
-
427
424
std::unique_ptr<ResourceStorage> resource_storage_;
428
425
429
426
// Structure to store read and write status so it is not initialized in the real-time loop
430
427
HardwareReadWriteStatus read_write_status;
431
-
432
- bool is_urdf_loaded__ = false ;
433
428
};
434
429
435
430
} // namespace hardware_interface
0 commit comments