-
Notifications
You must be signed in to change notification settings - Fork 428
Hardware component interfaces #121
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
Merged
bmagyar
merged 29 commits into
ros-controls:master
from
destogl:hardware_component_interfaces
Aug 22, 2020
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
ceb4d67
Initial version of new package implementing components for controling…
destogl 3ceb98c
Add control component interfaces.
destogl 9ddc603
Added initial tests for Joint and JointInterface
destogl eeaff7e
Extended SensorInterface to work with hardware. Added Example for Dum…
destogl d7eae16
Remove component types since they are not used yet.
destogl 818846d
Added tests for all interfaces and implemented review comments
destogl 3fead1f
Added HardwareInfo as the main structure in the robot's URDF file
destogl 2fea78d
Add Hardware and Component base classes and tests.
destogl 182d7f1
Update hardware_interface/include/hardware_interface/sensor_hardware_…
destogl 90b6ee2
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl 53e83c4
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl 7f922dd
Update hardware_interface/include/hardware_interface/system_hardware_…
destogl ef5a259
Split Component and Hardware Infos into two files
destogl 374aeb0
Use separated headers for components_info and hardware_info
destogl daaac84
Style corrections
destogl 5e4ed73
Add documentation for joint and sensor components
destogl 3053824
Update hardware_interface/test/test_component_interfaces.cpp
destogl 7089abe
Style corrections
destogl f9c1d15
The base classes for Joints and Sensors are implemented
destogl ed11e86
Add more tests to get better coverage
destogl f6a731a
Updated after comments and added helper header
destogl 8dbe0bc
Implementation moved to cpp files
destogl f871d5e
Removed virtual function for checking limits
destogl fbed601
Use inline functions in helper header and make API-consistent return …
destogl 62cf9ab
Correct faulty header guard
destogl 567b774
Corrected depency export and sorting of includes and namespaces in te…
destogl 71aafc2
remove helpers namespace
destogl 3d5f7a5
osx touchups
Karsten1987 00b73ee
move components into components folder
Karsten1987 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
60 changes: 60 additions & 0 deletions
60
hardware_interface/include/hardware_interface/actuator_hardware.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,60 @@ | ||
| // 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__ACTUATOR_HARDWARE_HPP_ | ||
| #define HARDWARE_INTERFACE__ACTUATOR_HARDWARE_HPP_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "hardware_interface/hardware_info.hpp" | ||
| #include "hardware_interface/types/hardware_interface_return_values.hpp" | ||
| #include "hardware_interface/types/hardware_interface_status_values.hpp" | ||
| #include "hardware_interface/visibility_control.h" | ||
|
|
||
| namespace hardware_interface | ||
| { | ||
|
|
||
| namespace components | ||
| { | ||
| class Joint; | ||
| } // namespace components | ||
| class ActuatorHardwareInterface; | ||
|
|
||
| class ActuatorHardware final | ||
| { | ||
| public: | ||
| ActuatorHardware() = default; | ||
|
|
||
| explicit ActuatorHardware(std::unique_ptr<ActuatorHardwareInterface> impl); | ||
|
|
||
| ~ActuatorHardware() = default; | ||
|
|
||
| return_type configure(const HardwareInfo & actuator_info); | ||
|
|
||
| return_type start(); | ||
|
|
||
| return_type stop(); | ||
|
|
||
| hardware_interface_status get_status() const; | ||
|
|
||
| return_type read_joint(std::shared_ptr<components::Joint> joint); | ||
|
|
||
| return_type write_joint(const std::shared_ptr<components::Joint> joint); | ||
|
|
||
| private: | ||
| std::unique_ptr<ActuatorHardwareInterface> impl_; | ||
| }; | ||
|
|
||
| } // namespace hardware_interface | ||
| #endif // HARDWARE_INTERFACE__ACTUATOR_HARDWARE_HPP_ |
105 changes: 105 additions & 0 deletions
105
hardware_interface/include/hardware_interface/actuator_hardware_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,105 @@ | ||
| // 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__ACTUATOR_HARDWARE_INTERFACE_HPP_ | ||
| #define HARDWARE_INTERFACE__ACTUATOR_HARDWARE_INTERFACE_HPP_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "hardware_interface/components/joint.hpp" | ||
| #include "hardware_interface/hardware_info.hpp" | ||
| #include "hardware_interface/types/hardware_interface_return_values.hpp" | ||
| #include "hardware_interface/types/hardware_interface_status_values.hpp" | ||
| #include "hardware_interface/visibility_control.h" | ||
|
|
||
| namespace hardware_interface | ||
| { | ||
|
|
||
| /** | ||
| * \brief Virtual Class to implement when integrating a 1 DoF actuator into ros2_control. | ||
| * The typical examples are conveyors or motors. | ||
| */ | ||
| class ActuatorHardwareInterface | ||
| { | ||
| public: | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| ActuatorHardwareInterface() = default; | ||
|
|
||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| ~ActuatorHardwareInterface() = default; | ||
|
|
||
| /** | ||
| * \brief Configuration of the actuator from data parsed from the robot's URDF. | ||
| * | ||
| * \param actuator_info structure with data from URDF. | ||
| * \return return_type::OK if required data are provided and can be parsed, | ||
| * return_type::ERROR otherwise. | ||
| */ | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type configure(const HardwareInfo & actuator_info) = 0; | ||
|
|
||
| /** | ||
| * \brief Start exchange data with the hardware. | ||
| * | ||
| * \return return_type:OK if everything worked as expected, return_type::ERROR otherwise. | ||
| */ | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type start() = 0; | ||
|
|
||
| /** | ||
| * \brief Stop exchange data with the hardware. | ||
| * | ||
| * \return return_type:OK if everything worked as expected, return_type::ERROR otherwise. | ||
| */ | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type stop() = 0; | ||
|
|
||
| /** | ||
| * \brief Get current state of the system hardware. | ||
| * | ||
| * \return hardware_interface_status current status. | ||
| */ | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| hardware_interface_status get_status() const = 0; | ||
|
|
||
| /** | ||
| * \brief Read data fromt the hardware into the joint using "set_state" function of the Joint class. | ||
| * This function is always called by the resource manager. | ||
| * | ||
| * \param joint joint where data from the hardware are stored. | ||
| * \return return_type:OK if everything worked as expected, return_type::ERROR otherwise. | ||
| */ | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type read_joint(std::shared_ptr<components::Joint> joint) const = 0; | ||
|
|
||
| /** | ||
| * \brief Write data from the joint to the hardware using "get_command" function of the Joint class. | ||
| * This function is always called by the resource manager. | ||
| * | ||
| * \param joint the joint from which data are written to the hardware. | ||
| * \return return_type:OK if everything worked as expected, return_type::ERROR otherwise. | ||
| */ | ||
| HARDWARE_INTERFACE_PUBLIC | ||
| virtual | ||
| return_type write_joint(const std::shared_ptr<components::Joint> joint) = 0; | ||
| }; | ||
|
|
||
| } // namespace hardware_interface | ||
| #endif // HARDWARE_INTERFACE__ACTUATOR_HARDWARE_INTERFACE_HPP_ | ||
63 changes: 63 additions & 0 deletions
63
hardware_interface/include/hardware_interface/components/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,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__COMPONENTS__COMPONENT_INFO_HPP_ | ||
| #define HARDWARE_INTERFACE__COMPONENTS__COMPONENT_INFO_HPP_ | ||
|
|
||
| #include <string> | ||
| #include <unordered_map> | ||
| #include <vector> | ||
|
|
||
| namespace hardware_interface | ||
| { | ||
| namespace components | ||
| { | ||
|
|
||
| /** | ||
| * \brief This structure stores information about components defined for a specific hardware | ||
| * in robot's URDF. | ||
| */ | ||
| struct ComponentInfo | ||
| { | ||
| /** | ||
| * \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 name of the command interfaces that can be set, e.g. "position", "velocity", etc. | ||
| * Used by joints. | ||
| */ | ||
| std::vector<std::string> command_interfaces; | ||
| /** | ||
| * \brief name of the state interfaces that can be read, e.g. "position", "velocity", etc. | ||
| * Used by Joints and Sensors. | ||
| */ | ||
| std::vector<std::string> state_interfaces; | ||
| /** | ||
| * \brief (optional) key-value pairs of components parameters. | ||
| */ | ||
| std::unordered_map<std::string, std::string> parameters; | ||
| }; | ||
|
|
||
| } // namespace components | ||
| } // namespace hardware_interface | ||
| #endif // HARDWARE_INTERFACE__COMPONENTS__COMPONENT_INFO_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.
Uh oh!
There was an error while loading. Please reload this page.