ros2_control - galactic
Loading...
Searching...
No Matches
ign_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 IGN_ROS2_CONTROL__IGN_SYSTEM_HPP_
17#define IGN_ROS2_CONTROL__IGN_SYSTEM_HPP_
18
19#include <map>
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "ign_ros2_control/ign_system_interface.hpp"
25#include "rclcpp_lifecycle/state.hpp"
26#include "rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp"
27
28namespace ign_ros2_control
29{
30// Forward declaration
31class IgnitionSystemPrivate;
32
33// These class must inherit `ign_ros2_control::IgnitionSystemInterface` which implements a
34// simulated `ros2_control` `hardware_interface::SystemInterface`.
35
37{
38public:
39 // Documentation Inherited
40 CallbackReturn on_init(const hardware_interface::HardwareInfo & system_info)
41 override;
42
43 CallbackReturn on_configure(const rclcpp_lifecycle::State & previous_state) override;
44
45 // Documentation Inherited
46 std::vector<hardware_interface::StateInterface> export_state_interfaces() override;
47
48 // Documentation Inherited
49 std::vector<hardware_interface::CommandInterface> export_command_interfaces() override;
50
51 // Documentation Inherited
52 CallbackReturn on_activate(const rclcpp_lifecycle::State & previous_state) override;
53
54 // Documentation Inherited
55 CallbackReturn on_deactivate(const rclcpp_lifecycle::State & previous_state) override;
56
57 // Documentation Inherited
58 hardware_interface::return_type read() override;
59
60 // Documentation Inherited
61 hardware_interface::return_type write() override;
62
63 // Documentation Inherited
64 bool initSim(
65 rclcpp::Node::SharedPtr & model_nh,
66 std::map<std::string, ignition::gazebo::Entity> & joints,
67 const hardware_interface::HardwareInfo & hardware_info,
68 ignition::gazebo::EntityComponentManager & _ecm,
69 int & update_rate) override;
70
71private:
72 // Register a sensor (for now just IMUs)
73 // \param[in] hardware_info hardware information where the data of
74 // the sensors is extract.
75 void registerSensors(
76 const hardware_interface::HardwareInfo & hardware_info);
77
79 std::unique_ptr<IgnitionSystemPrivate> dataPtr;
80};
81
82} // namespace ign_ros2_control
83
84#endif // IGN_ROS2_CONTROL__IGN_SYSTEM_HPP_
Definition ign_system_interface.hpp:76
Definition ign_system.hpp:37
CallbackReturn on_init(const hardware_interface::HardwareInfo &system_info) override
Initialization of the hardware interface from data parsed from the robot's URDF.
Definition ign_system.cpp:330
hardware_interface::return_type write() override
Write the current command values to the actuator.
Definition ign_system.cpp:415
std::vector< hardware_interface::StateInterface > export_state_interfaces() override
Exports all state interfaces for this hardware interface.
Definition ign_system.cpp:349
std::vector< hardware_interface::CommandInterface > export_command_interfaces() override
Exports all command interfaces for this hardware interface.
Definition ign_system.cpp:355
bool initSim(rclcpp::Node::SharedPtr &model_nh, std::map< std::string, ignition::gazebo::Entity > &joints, const hardware_interface::HardwareInfo &hardware_info, ignition::gazebo::EntityComponentManager &_ecm, int &update_rate) override
Initialize the system interface param[in] model_nh Pointer to the ros2 node param[in] joints Map with...
Definition ign_system.cpp:142
hardware_interface::return_type read() override
Read the current state values from the actuator.
Definition ign_system.cpp:372
This structure stores information about hardware defined in a robot's URDF.
Definition hardware_info.hpp:101