-
Notifications
You must be signed in to change notification settings - Fork 430
Add component parser #122
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
Closed
Closed
Add component parser #122
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
hardware_interface/include/hardware_interface/component_info.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // 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 This structure stores information about components defined in a robot's URDF. | ||
| */ | ||
| struct ComponentInfo | ||
| { | ||
| /** | ||
| * \brief name of the component. | ||
| */ | ||
| std::string name; | ||
| /** | ||
| * \brief type of the component: joint or sensor. | ||
| */ | ||
| 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 resources'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; | ||
| }; | ||
|
|
||
| /** | ||
| * \brief This structure stores informations about ros2-control ressource defined in robot's URDF, i.e. "ros2_control"-tag. | ||
| * A ressource is composed from one or multiple joints, actuators or systems. | ||
| */ | ||
| struct ControlRessourceInfo | ||
| { | ||
| /** | ||
| * \brief name of the ressource. | ||
| */ | ||
| std::string name; | ||
| /** | ||
| * \brief type of the ressource: system, modular or sensor. | ||
| * Note: URDF always needs a "robot" tag, nevertheless in terms of ros2_control, it can hold a definition for only a joint (e.g. motor) 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> components; | ||
| }; | ||
|
|
||
| } // namespace hardware_interface | ||
|
|
||
| #endif // HARDWARE_INTERFACE__COMPONENT_INFO_HPP_ |
70 changes: 70 additions & 0 deletions
70
hardware_interface/include/hardware_interface/component_interfaces/joint_interface.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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_ |
63 changes: 63 additions & 0 deletions
63
hardware_interface/include/hardware_interface/component_interfaces/sensor_interface.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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_ |
70 changes: 70 additions & 0 deletions
70
hardware_interface/include/hardware_interface/component_interfaces/system_interface.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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__SYSTEM_INTERFACE_HPP_ | ||
| #define HARDWARE_INTERFACE__COMPONENT_INTERFACES__SYSTEM_INTERFACE_HPP_ | ||
|
|
||
| #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 SystemInterface | ||
| { | ||
| public: | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| SystemInterface() = default; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| ~SystemInterface() = default; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type configure(const SystemInfo & system_info) = 0; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| std::vector<std::string> get_interface_names() 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(std::vector<double> & data) = 0; | ||
|
|
||
| return_type | ||
| virtual | ||
| write(const std::vector<double> & data) = 0; | ||
|
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. this vector data comes from the resource manager? Or which entity is allocating the memory for the data? |
||
| }; | ||
|
|
||
| typedef SystemInterface RobotInterface; | ||
|
|
||
| } // namespace hardware_interface | ||
| #endif // HARDWARE_INTERFACE__COMPONENT_INTERFACES__SYSTEM_INTERFACE_HPP_ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
as mentioned yesterday, it is not really clear to me what read does here. Imagine I have a robot with an integrated sensor. First off, how do I know which sensor to address here and their size of data? You can imagine that different sensors have different types of data to return.