Loading [MathJax]/jax/input/TeX/config.js
ros2_control - rolling
All Classes Namespaces Functions Variables Typedefs Enumerations Pages
system.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__SYSTEM_HPP_
16#define HARDWARE_INTERFACE__SYSTEM_HPP_
17
18#include <memory>
19#include <string>
20#include <vector>
21
22#include "hardware_interface/handle.hpp"
23#include "hardware_interface/hardware_info.hpp"
24#include "hardware_interface/system_interface.hpp"
25#include "hardware_interface/types/hardware_interface_return_values.hpp"
26#include "rclcpp/duration.hpp"
27#include "rclcpp/logger.hpp"
28#include "rclcpp/node_interfaces/node_clock_interface.hpp"
29#include "rclcpp/time.hpp"
30#include "rclcpp_lifecycle/state.hpp"
31
32namespace hardware_interface
33{
34class SystemInterface;
35
36class System final
37{
38public:
39 System() = default;
40
41 explicit System(std::unique_ptr<SystemInterface> impl);
42
43 explicit System(System && other) noexcept;
44
45 ~System() = default;
46
47 const rclcpp_lifecycle::State & initialize(
48 const HardwareInfo & system_info, rclcpp::Logger logger,
49 rclcpp::node_interfaces::NodeClockInterface::SharedPtr clock_interface);
50
51 const rclcpp_lifecycle::State & initialize(
52 const HardwareInfo & system_info, rclcpp::Logger logger, rclcpp::Clock::SharedPtr clock);
53
54 const rclcpp_lifecycle::State & configure();
55
56 const rclcpp_lifecycle::State & cleanup();
57
58 const rclcpp_lifecycle::State & shutdown();
59
60 const rclcpp_lifecycle::State & activate();
61
62 const rclcpp_lifecycle::State & deactivate();
63
64 const rclcpp_lifecycle::State & error();
65
66 std::vector<StateInterface::ConstSharedPtr> export_state_interfaces();
67
68 std::vector<CommandInterface::SharedPtr> export_command_interfaces();
69
70 return_type prepare_command_mode_switch(
71 const std::vector<std::string> & start_interfaces,
72 const std::vector<std::string> & stop_interfaces);
73
74 return_type perform_command_mode_switch(
75 const std::vector<std::string> & start_interfaces,
76 const std::vector<std::string> & stop_interfaces);
77
78 const std::string & get_name() const;
79
80 const std::string & get_group_name() const;
81
82 const rclcpp_lifecycle::State & get_lifecycle_state() const;
83
84 const rclcpp::Time & get_last_read_time() const;
85
86 const rclcpp::Time & get_last_write_time() const;
87
88 return_type read(const rclcpp::Time & time, const rclcpp::Duration & period);
89
90 return_type write(const rclcpp::Time & time, const rclcpp::Duration & period);
91
92 std::recursive_mutex & get_mutex();
93
94private:
95 std::unique_ptr<SystemInterface> impl_;
96 mutable std::recursive_mutex system_mutex_;
97 // Last read cycle time
98 rclcpp::Time last_read_cycle_time_;
99 // Last write cycle time
100 rclcpp::Time last_write_cycle_time_;
101};
102
103} // namespace hardware_interface
104#endif // HARDWARE_INTERFACE__SYSTEM_HPP_
Definition system.hpp:37
Definition actuator.hpp:33
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:232