ros2_control - rolling
Loading...
Searching...
No Matches
gz_custom_system.hpp
1// Copyright 2025 AIT Austrian Institute of Technology GmbH
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
16#ifndef GZ_ROS2_CONTROL_DEMOS__GZ_CUSTOM_SYSTEM_HPP_
17#define GZ_ROS2_CONTROL_DEMOS__GZ_CUSTOM_SYSTEM_HPP_
18
19#include <map>
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "gz_ros2_control/gz_system_interface.hpp"
25#include "rclcpp/duration.hpp"
26#include "rclcpp/node.hpp"
27#include "rclcpp/time.hpp"
28#include "rclcpp_lifecycle/state.hpp"
29#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
30
31namespace gz_ros2_control_demos
32{
33using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
34
35// Forward declaration
36class GazeboSimSystemPrivate;
37
38// These class must inherit `gz_ros2_control::GazeboSimSystemInterface` which implements a
39// simulated `ros2_control` `hardware_interface::SystemInterface`.
40
42{
43public:
44 // Documentation Inherited
46 override;
47
48 CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override;
49
50 // Documentation Inherited
51 std::vector<hardware_interface::StateInterface::ConstSharedPtr> on_export_state_interfaces()
52 override;
53
54 // Documentation Inherited
55 std::vector<hardware_interface::CommandInterface::SharedPtr> on_export_command_interfaces()
56 override;
57
58 // Documentation Inherited
59 CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;
60
61 // Documentation Inherited
62 CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;
63
64 // Documentation Inherited
65 hardware_interface::return_type read(
66 const rclcpp::Time & time,
67 const rclcpp::Duration & period) override;
68
69 // Documentation Inherited
70 hardware_interface::return_type write(
71 const rclcpp::Time & time,
72 const rclcpp::Duration & period) override;
73
74 // Documentation Inherited
75 bool initSim(
76 rclcpp::Node::SharedPtr & model_nh,
77 std::map<std::string, sim::Entity> & joints,
78 const hardware_interface::HardwareInfo & hardware_info,
79 sim::EntityComponentManager & _ecm,
80 unsigned int update_rate) override;
81
82private:
84 std::unique_ptr<GazeboSimSystemPrivate> dataPtr;
85};
86
87} // namespace gz_ros2_control_demos
88
89#endif // GZ_ROS2_CONTROL_DEMOS__GZ_CUSTOM_SYSTEM_HPP_
Definition gz_system_interface.hpp:86
Definition gz_custom_system.hpp:42
hardware_interface::return_type read(const rclcpp::Time &time, const rclcpp::Duration &period) override
Read the current state values from the hardware.
Definition gz_custom_system.cpp:349
bool initSim(rclcpp::Node::SharedPtr &model_nh, std::map< std::string, sim::Entity > &joints, const hardware_interface::HardwareInfo &hardware_info, sim::EntityComponentManager &_ecm, unsigned int update_rate) override
Initialize the system interface param[in] model_nh Pointer to the ros2 node param[in] joints Map with...
Definition gz_custom_system.cpp:115
CallbackReturn on_init(const hardware_interface::HardwareComponentInterfaceParams &params) override
Initialization of the hardware interface from data parsed from the robot's URDF.
Definition gz_custom_system.cpp:298
std::vector< hardware_interface::StateInterface::ConstSharedPtr > on_export_state_interfaces() override
Definition gz_custom_system.cpp:318
hardware_interface::return_type write(const rclcpp::Time &time, const rclcpp::Duration &period) override
Write the current command values to the hardware.
Definition gz_custom_system.cpp:394
std::vector< hardware_interface::CommandInterface::SharedPtr > on_export_command_interfaces() override
Definition gz_custom_system.cpp:328
Parameters required for the initialization of a specific hardware component plugin....
Definition hardware_component_interface_params.hpp:32
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:373