-
Notifications
You must be signed in to change notification settings - Fork 428
WIP: Implementation of components for controlling robots #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f57147f
fe1acd1
64e22a7
1b40e73
8325d77
dc8f303
3dc9426
085748a
cdc9eb9
5f9978d
6c43b2a
8339225
afff3aa
1bc5dce
4034cef
16e7f31
191b15d
cf9ea6c
6af1296
488b90d
b88faec
c59575a
3d4b282
cdbb2cc
5b7919d
075312a
9f24c3d
355048d
e0aa6f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| // Copyright 2020 ros2_control Development Team | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
|
|
||
| #ifndef HARDWARE_INTERFACE__COMPONENT_INFO_HPP_ | ||
| #define HARDWARE_INTERFACE__COMPONENT_INFO_HPP_ | ||
|
|
||
| #include <string> | ||
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
||
| namespace hardware_interface | ||
| { | ||
|
|
||
| /** | ||
| * \brief constants for types of components. | ||
| */ | ||
| constexpr const auto robotType = "robot"; | ||
| constexpr const auto actuatorType = "actuator"; | ||
| constexpr const auto sensorType = "sensor"; | ||
|
|
||
| /** | ||
| * \brief This structure stores information about components defined in a robot's URDF. | ||
| */ | ||
| struct ComponentInfo | ||
destogl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| /** | ||
| * \brief name of the component. | ||
| */ | ||
| std::string name; | ||
| /** | ||
| * \brief type of the component: sensor or actuator. | ||
| */ | ||
| std::string type; | ||
| /** | ||
| * \brief component's class, which will be dynamically loaded. | ||
| */ | ||
| std::string class_type; | ||
| /** | ||
| * \brief joint where component is placed. | ||
| */ | ||
| std::string joint; | ||
| /** | ||
| * \brief name of the interface, e.g. "position", "velocity", etc. for meaning of data this component holds. | ||
| */ | ||
| std::vector<std::string> interface_names; | ||
| /** | ||
| * \brief (optional) key-value pairs of components parameters. | ||
| */ | ||
| std::unordered_map<std::string, std::string> parameters; | ||
|
|
||
| /** | ||
| * \brief (optional) hardware class of the component that will be dynamically loaded. If not defined, the system's hardware class has to be defined. | ||
| */ | ||
| std::string hardware_class_type; | ||
| /** | ||
| * \brief (optional) key-value pairs for components hardware. | ||
| */ | ||
| std::unordered_map<std::string, std::string> hardware_parameters; | ||
|
Comment on lines
+67
to
+70
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the difference here to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }; | ||
|
|
||
| /** | ||
| * \brief This structure stores informations about system defined in robot's URDF, i.e. "ros2_control"-tag. | ||
| */ | ||
| struct SystemInfo | ||
| { | ||
| /** | ||
| * \brief name of the system. | ||
| */ | ||
| std::string name; | ||
| /** | ||
| * \brief type of the system: robot, actuator or sensor. Note: URDF always needs a "robot" tag, nevertheless in terms of ros2_control, it can hold a definition for an actuator or sensor. | ||
| */ | ||
| std::string type; | ||
| /** | ||
| * \brief (optional) hardware class of the system, which will be dynamically loaded. If not defined, a hardware class for each subcomponent has to be defined. | ||
| */ | ||
| std::string hardware_class_type; | ||
| /** | ||
| * \brief (optional) key-value pairs for systems hardware. | ||
| */ | ||
| std::unordered_map<std::string, std::string> hardware_parameters; | ||
|
|
||
| /** | ||
| * \brief list of subcomponents in the system, i.e., list of sensors and actuators. | ||
| */ | ||
| std::vector<ComponentInfo> subcomponents; | ||
|
Comment on lines
+95
to
+98
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't understand why we need this. Can a system not be treated as a single black-box component?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to your figure yes. You are right, this is not the best way, at least it shouldn't be placed inside The I hope you got my idea, and if you have any proposal, I would be happy to discuss it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair enough. I am cross-posting here as I just went through #121 but I think we definitely need a piece of URDF here which dictates how the individual components as well as the systems are supposed to be specified. |
||
| }; | ||
|
|
||
| } // namespace hardware_interface | ||
|
|
||
| #endif // HARDWARE_INTERFACE__COMPONENT_INFO_HPP_ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Copyright 2020 ros2_control Development Team | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef HARDWARE_INTERFACE__COMPONENT_INTERFACES__JOINT_INTERFACE_HPP_ | ||
| #define HARDWARE_INTERFACE__COMPONENT_INTERFACES__JOINT_INTERFACE_HPP_ | ||
|
|
||
| #include <algorithm> | ||
| #include <array> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| #include "hardware_interface/component_info.hpp" | ||
| #include "hardware_interface/types/hardware_interface_return_values.hpp" | ||
| #include "hardware_interface/visibility_control.h" | ||
|
|
||
| namespace hardware_interface | ||
| { | ||
|
|
||
| class JointInterface | ||
| { | ||
| public: | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| JointInterface() = default; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| ~JointInterface() = default; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type configure(const ComponentInfo & actuator_info) = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| std::string get_interface_name() const = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type start() = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type stop() = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| bool is_started() const = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type read(double & data) = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type write(const double & data) = 0; | ||
| }; | ||
|
|
||
| } // namespace hardware_interface | ||
| #endif // HARDWARE_INTERFACE__COMPONENT_INTERFACES__JOINT_INTERFACE_HPP_ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright 2020 ros2_control Development Team | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef HARDWARE_INTERFACE__COMPONENT_INTERFACES__SENSOR_INTERFACE_HPP_ | ||
| #define HARDWARE_INTERFACE__COMPONENT_INTERFACES__SENSOR_INTERFACE_HPP_ | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "hardware_interface/component_info.hpp" | ||
| #include "hardware_interface/types/hardware_interface_return_values.hpp" | ||
| #include "hardware_interface/visibility_control.h" | ||
|
|
||
| namespace hardware_interface | ||
| { | ||
|
|
||
| class SensorInterface | ||
| { | ||
| public: | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| SensorInterface() = default; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| ~SensorInterface() = default; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type configure(const ComponentInfo & sensor_info) = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| std::string get_interface_name() const = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type start() = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type stop() = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| bool is_started() const = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type read(double & data) = 0; | ||
| }; | ||
|
|
||
| } // namespace hardware_interface | ||
| #endif // HARDWARE_INTERFACE__COMPONENT_INTERFACES__SENSOR_INTERFACE_HPP_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be
systemType?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. Those types are for definitions for
ResourceManagerto get correct type fromtypeproperty when initializing components.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand this.