ros2_control - rolling
Loading...
Searching...
No Matches
gz_resource_manager.hpp
1// Copyright 2026 Open Source Robotics Foundation, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GZ_RESOURCE_MANAGER_HPP_
16#define GZ_RESOURCE_MANAGER_HPP_
17
18#include <functional>
19#include <map>
20#include <memory>
21#include <string>
22
23#include <gz/sim/Entity.hh>
24#include <gz/sim/EntityComponentManager.hh>
25
26#include <hardware_interface/resource_manager.hpp>
27#include <hardware_interface/types/resource_manager_params.hpp>
28#include <pluginlib/class_loader.hpp>
29#include <rclcpp/logger.hpp>
30#include <rclcpp/node.hpp>
31
32#include "gz_ros2_control/gz_system_interface.hpp"
33
34// Internal resource manager of GazeboSimROS2ControlPlugin. Not installed, only shared with the
35// tests.
36namespace gz_ros2_control
37{
41{
42public:
44 using SystemLoader = std::function<
45 std::unique_ptr<GazeboSimSystemInterface>(const std::string & plugin_name)>;
46
54 rclcpp::Node::SharedPtr & node,
55 gz::sim::EntityComponentManager & ecm,
56 std::map<std::string, gz::sim::Entity> enabledJoints,
57 SystemLoader system_loader = nullptr);
58
59 GZResourceManager(const GZResourceManager &) = delete;
60
65 const hardware_interface::ResourceManagerParams & params) override;
66
67private:
68 std::shared_ptr<rclcpp::Node> node_;
69 gz::sim::EntityComponentManager * ecm_;
70 std::map<std::string, gz::sim::Entity> enabledJoints_;
71
73 std::unique_ptr<pluginlib::ClassLoader<GazeboSimSystemInterface>> gz_system_loader_;
74
75 SystemLoader system_loader_;
76
77 rclcpp::Logger logger_;
78};
79} // namespace gz_ros2_control
80
81#endif // GZ_RESOURCE_MANAGER_HPP_
Resource manager that loads GazeboSimSystemInterface plugins and initializes them with the simulation...
Definition gz_resource_manager.hpp:41
std::function< std::unique_ptr< GazeboSimSystemInterface >(const std::string &plugin_name)> SystemLoader
Creates a hardware component from its plugin name, throws std::exception on failure.
Definition gz_resource_manager.hpp:45
bool load_and_initialize_components(const hardware_interface::ResourceManagerParams &params) override
Called from Controller Manager when robot description is initialized from callback.
Definition gz_resource_manager.cpp:55
Definition resource_manager.hpp:59
Parameters required for the construction and initial setup of a ResourceManager. This struct is typic...
Definition resource_manager_params.hpp:30