ros2_control - jazzy
Loading...
Searching...
No Matches
hardware_component.hpp
1// Copyright 2020 - 2021 ros2_control Development Team
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 HARDWARE_INTERFACE__HARDWARE_COMPONENT_HPP_
16#define HARDWARE_INTERFACE__HARDWARE_COMPONENT_HPP_
17
18#include <cstdint>
19#include <memory>
20#include <mutex>
21#include <string>
22#include <vector>
23
24#include "hardware_interface/handle.hpp"
25#include "hardware_interface/hardware_component_interface.hpp"
26#include "hardware_interface/hardware_info.hpp"
27#include "hardware_interface/types/hardware_component_params.hpp"
28#include "hardware_interface/types/hardware_interface_return_values.hpp"
29#include "hardware_interface/types/statistics_types.hpp"
30#include "rclcpp/duration.hpp"
31#include "rclcpp/logger.hpp"
32#include "rclcpp/node_interfaces/node_clock_interface.hpp"
33#include "rclcpp/time.hpp"
34#include "rclcpp_lifecycle/state.hpp"
35
36namespace hardware_interface
37{
38class HardwareComponentInterface;
39
41{
42public:
43 HardwareComponent() = default;
44
45 explicit HardwareComponent(std::unique_ptr<HardwareComponentInterface> impl);
46
47 explicit HardwareComponent(HardwareComponent && other) noexcept;
48
50
51 HardwareComponent(const HardwareComponent & other) = delete;
52
53 HardwareComponent & operator=(const HardwareComponent & other) = delete;
54
55 HardwareComponent & operator=(HardwareComponent && other) = delete;
56
57 [[deprecated(
58 "Replaced by const rclcpp_lifecycle::State & initialize(const "
59 "hardware_interface::HardwareComponentParams & params).")]]
60 const rclcpp_lifecycle::State & initialize(
61 const HardwareInfo & component_info, rclcpp::Logger logger,
62 rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface);
63
64 [[deprecated(
65 "Replaced by const rclcpp_lifecycle::State & initialize(const "
66 "hardware_interface::HardwareComponentParams & params).")]]
67 const rclcpp_lifecycle::State & initialize(
68 const HardwareInfo & component_info, rclcpp::Logger logger, rclcpp::Clock::SharedPtr clock);
69
70 const rclcpp_lifecycle::State & initialize(
72
73 const rclcpp_lifecycle::State & configure();
74
75 const rclcpp_lifecycle::State & cleanup();
76
77 const rclcpp_lifecycle::State & shutdown();
78
79 const rclcpp_lifecycle::State & activate();
80
81 const rclcpp_lifecycle::State & deactivate();
82
83 const rclcpp_lifecycle::State & error();
84
85 std::vector<StateInterface::ConstSharedPtr> export_state_interfaces();
86
87 std::vector<CommandInterface::SharedPtr> export_command_interfaces();
88
89 return_type prepare_command_mode_switch(
90 const std::vector<std::string> & start_interfaces,
91 const std::vector<std::string> & stop_interfaces);
92
93 return_type perform_command_mode_switch(
94 const std::vector<std::string> & start_interfaces,
95 const std::vector<std::string> & stop_interfaces);
96
97 const std::string & get_name() const;
98
99 const std::string & get_group_name() const;
100
101 const rclcpp_lifecycle::State & get_lifecycle_state() const;
102
103 uint8_t get_lifecycle_id() const;
104
105 const rclcpp::Time & get_last_read_time() const;
106
107 const rclcpp::Time & get_last_write_time() const;
108
109 const HardwareComponentStatisticsCollector & get_read_statistics() const;
110
111 const HardwareComponentStatisticsCollector & get_write_statistics() const;
112
113 return_type read(const rclcpp::Time & time, const rclcpp::Duration & period);
114
115 return_type write(const rclcpp::Time & time, const rclcpp::Duration & period);
116
117 std::recursive_mutex & get_mutex();
118
119private:
120 std::unique_ptr<HardwareComponentInterface> impl_;
121 mutable std::recursive_mutex component_mutex_;
122 // Last read cycle time
123 rclcpp::Time last_read_cycle_time_;
124 // Last write cycle time
125 rclcpp::Time last_write_cycle_time_;
126 // Component statistics
127 HardwareComponentStatisticsCollector read_statistics_;
128 HardwareComponentStatisticsCollector write_statistics_;
129};
130
131} // namespace hardware_interface
132#endif // HARDWARE_INTERFACE__HARDWARE_COMPONENT_HPP_
Definition hardware_component.hpp:41
Definition mujoco_system_interface.hpp:57
Parameters required for the initialization of a specific hardware component plugin....
Definition hardware_component_params.hpp:33
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:375