ros2_control - rolling
Loading...
Searching...
No Matches
gz_system.hpp
1// Copyright 2021 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
16#ifndef GZ_ROS2_CONTROL__GZ_SYSTEM_HPP_
17#define GZ_ROS2_CONTROL__GZ_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_lifecycle/state.hpp"
26#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
27
28namespace gz_ros2_control
29{
30using CallbackReturn = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
31
32// Forward declaration
33class GazeboSimSystemPrivate;
34
35// These class must inherit `gz_ros2_control::GazeboSimSystemInterface` which implements a
36// simulated `ros2_control` `hardware_interface::SystemInterface`.
37
39{
40public:
41 // Documentation Inherited
43 override;
44
45 CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override;
46
47 // Documentation Inherited
48 std::vector<hardware_interface::StateInterface::ConstSharedPtr>
50
51 // Documentation Inherited
52 std::vector<hardware_interface::CommandInterface::SharedPtr>
54
55 // Documentation Inherited
56 CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;
57
58 // Documentation Inherited
59 CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;
60
61 // Documentation Inherited
62 hardware_interface::return_type perform_command_mode_switch(
63 const std::vector<std::string> & start_interfaces,
64 const std::vector<std::string> & stop_interfaces) override;
65
66 // Documentation Inherited
67 hardware_interface::return_type read(
68 const rclcpp::Time & time,
69 const rclcpp::Duration & period) override;
70
71 // Documentation Inherited
72 hardware_interface::return_type write(
73 const rclcpp::Time & time,
74 const rclcpp::Duration & period) override;
75
76 // Documentation Inherited
77 bool initSim(
78 rclcpp::Node::SharedPtr & model_nh,
79 std::map<std::string, sim::Entity> & joints,
80 const hardware_interface::HardwareInfo & hardware_info,
81 sim::EntityComponentManager & _ecm,
82 unsigned int update_rate) override;
83
84private:
85 // Register a sensor (for now just IMUs)
86 // \param[in] hardware_info hardware information where the data of
87 // the sensors is extract.
88 void registerSensors(
89 const hardware_interface::HardwareInfo & hardware_info);
90
92 std::unique_ptr<GazeboSimSystemPrivate> dataPtr;
93};
94
95} // namespace gz_ros2_control
96
97#endif // GZ_ROS2_CONTROL__GZ_SYSTEM_HPP_
Definition gz_system_interface.hpp:77
Definition gz_system.hpp:39
std::vector< hardware_interface::StateInterface::ConstSharedPtr > on_export_state_interfaces() override
Definition gz_system.cpp:644
CallbackReturn on_init(const hardware_interface::HardwareComponentInterfaceParams &params) override
Initialization of the hardware interface from data parsed from the robot's URDF.
Definition gz_system.cpp:624
hardware_interface::return_type read(const rclcpp::Time &time, const rclcpp::Duration &period) override
Read the current state values from the hardware.
Definition gz_system.cpp:672
hardware_interface::return_type write(const rclcpp::Time &time, const rclcpp::Duration &period) override
Write the current command values to the hardware.
Definition gz_system.cpp:807
std::vector< hardware_interface::CommandInterface::SharedPtr > on_export_command_interfaces() override
Definition gz_system.cpp:655
hardware_interface::return_type perform_command_mode_switch(const std::vector< std::string > &start_interfaces, const std::vector< std::string > &stop_interfaces) override
Definition gz_system.cpp:761
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_system.cpp:239
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:370