-
Notifications
You must be signed in to change notification settings - Fork 305
Service to get software version of robot #964
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
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5079a9d
Implemented get_version service
URJala 06b3345
Implemented test of get_version service and integrated it with the te…
URJala eee260c
Update ur_robot_driver/test/test_common.py
URJala f4ca63b
Renamed service to "GetRobotSoftwareVersion" everywhere.
URJala da81a68
Remove tool contact from test.
URJala 91b61b3
Implemented test of get_version service and integrated it with the te…
URJala 392fffe
Renamed service to "GetRobotSoftwareVersion" everywhere.
URJala d25981b
Remove tool contact from test.
URJala 38c4528
Create new URConfigurationController
URJala aef9dc5
Make configuration controller thread safe
URJala 91cf2d4
Use ptr-safe RealTimeBoxBestEffort
dbb495f
Added back files that were mistakenly deleted
4294aa7
Merge branch 'main' into get_version
b6ff42a
Merge branch 'main' into get_version
62a4293
Merge branch 'main' into get_version
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
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
105 changes: 105 additions & 0 deletions
105
ur_controllers/include/ur_controllers/ur_configuration_controller.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 2024, Universal Robots A/S | ||
| // | ||
| // Redistribution and use in source and binary forms, with or without | ||
| // modification, are permitted provided that the following conditions are met: | ||
| // | ||
| // * Redistributions of source code must retain the above copyright | ||
| // notice, this list of conditions and the following disclaimer. | ||
| // | ||
| // * Redistributions in binary form must reproduce the above copyright | ||
| // notice, this list of conditions and the following disclaimer in the | ||
| // documentation and/or other materials provided with the distribution. | ||
| // | ||
| // * Neither the name of the {copyright_holder} nor the names of its | ||
| // contributors may be used to endorse or promote products derived from | ||
| // this software without specific prior written permission. | ||
| // | ||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| // POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| //---------------------------------------------------------------------- | ||
| /*!\file | ||
| * | ||
| * \author Jacob Larsen [email protected] | ||
| * \date 2024-07-11 | ||
| * | ||
| * | ||
| * | ||
| * | ||
| */ | ||
| //---------------------------------------------------------------------- | ||
|
|
||
| #ifndef UR_CONTROLLERS__UR_CONFIGURATION_CONTROLLER_HPP_ | ||
| #define UR_CONTROLLERS__UR_CONFIGURATION_CONTROLLER_HPP_ | ||
|
|
||
| // TODO(fmauch): Currently, the realtime_box_best_effort doesn't include this | ||
| #include <functional> | ||
| #include <realtime_tools/realtime_box_best_effort.h> // NOLINT | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include <controller_interface/controller_interface.hpp> | ||
|
|
||
| #include "ur_msgs/srv/get_robot_software_version.hpp" | ||
| #include "ur_configuration_controller_parameters.hpp" | ||
|
|
||
| namespace ur_controllers | ||
| { | ||
|
|
||
| // Struct to hold version information | ||
| struct VersionInformation | ||
| { | ||
| uint32_t major = 0, minor = 0, build = 0, bugfix = 0; | ||
| }; | ||
|
|
||
| // Enum for indexing into state interfaces. | ||
| enum StateInterfaces | ||
| { | ||
| ROBOT_VERSION_MAJOR = 0, | ||
| ROBOT_VERSION_MINOR = 1, | ||
| ROBOT_VERSION_BUILD = 2, | ||
| ROBOT_VERSION_BUGFIX = 3, | ||
| }; | ||
|
|
||
| class URConfigurationController : public controller_interface::ControllerInterface | ||
| { | ||
| public: | ||
| controller_interface::InterfaceConfiguration command_interface_configuration() const override; | ||
|
|
||
| controller_interface::InterfaceConfiguration state_interface_configuration() const override; | ||
|
|
||
| controller_interface::return_type update(const rclcpp::Time& time, const rclcpp::Duration& period) override; | ||
|
|
||
| CallbackReturn on_configure(const rclcpp_lifecycle::State& previous_state) override; | ||
|
|
||
| CallbackReturn on_activate(const rclcpp_lifecycle::State& previous_state) override; | ||
|
|
||
| CallbackReturn on_deactivate(const rclcpp_lifecycle::State& previous_state) override; | ||
|
|
||
| CallbackReturn on_init() override; | ||
|
|
||
| private: | ||
| realtime_tools::RealtimeBoxBestEffort<std::shared_ptr<VersionInformation>> robot_software_version_{ | ||
| std::make_shared<VersionInformation>() | ||
| }; | ||
|
|
||
| rclcpp::Service<ur_msgs::srv::GetRobotSoftwareVersion>::SharedPtr get_robot_software_version_srv_; | ||
|
|
||
| bool getRobotSoftwareVersion(ur_msgs::srv::GetRobotSoftwareVersion::Request::SharedPtr req, | ||
| ur_msgs::srv::GetRobotSoftwareVersion::Response::SharedPtr resp); | ||
|
|
||
| std::shared_ptr<ur_configuration_controller::ParamListener> param_listener_; | ||
| ur_configuration_controller::Params params_; | ||
| }; | ||
| } // namespace ur_controllers | ||
|
|
||
| #endif // UR_CONTROLLERS__UR_CONFIGURATION_CONTROLLER_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,128 @@ | ||
| // Copyright 2024, Universal Robots A/S | ||
| // | ||
| // Redistribution and use in source and binary forms, with or without | ||
| // modification, are permitted provided that the following conditions are met: | ||
| // | ||
| // * Redistributions of source code must retain the above copyright | ||
| // notice, this list of conditions and the following disclaimer. | ||
| // | ||
| // * Redistributions in binary form must reproduce the above copyright | ||
| // notice, this list of conditions and the following disclaimer in the | ||
| // documentation and/or other materials provided with the distribution. | ||
| // | ||
| // * Neither the name of the {copyright_holder} nor the names of its | ||
| // contributors may be used to endorse or promote products derived from | ||
| // this software without specific prior written permission. | ||
| // | ||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| // POSSIBILITY OF SUCH DAMAGE. | ||
|
|
||
| //---------------------------------------------------------------------- | ||
| /*!\file | ||
| * | ||
| * \author Jacob Larsen [email protected] | ||
| * \date 2024-07-11 | ||
| * | ||
| * | ||
| * | ||
| * | ||
| */ | ||
| //---------------------------------------------------------------------- | ||
|
|
||
| #include <ur_controllers/ur_configuration_controller.hpp> | ||
| #include <realtime_tools/realtime_box.h> | ||
| namespace ur_controllers | ||
| { | ||
|
|
||
| controller_interface::CallbackReturn URConfigurationController::on_init() | ||
| { | ||
| return controller_interface::CallbackReturn::SUCCESS; | ||
| } | ||
|
|
||
| controller_interface::CallbackReturn | ||
| URConfigurationController::on_configure(const rclcpp_lifecycle::State& /* previous_state */) | ||
| { | ||
| param_listener_ = std::make_shared<ur_configuration_controller::ParamListener>(get_node()); | ||
| params_ = param_listener_->get_params(); | ||
|
|
||
| get_robot_software_version_srv_ = get_node()->create_service<ur_msgs::srv::GetRobotSoftwareVersion>( | ||
| "~/get_robot_software_version", std::bind(&URConfigurationController::getRobotSoftwareVersion, this, | ||
| std::placeholders::_1, std::placeholders::_2)); | ||
|
|
||
| return controller_interface::CallbackReturn::SUCCESS; | ||
| } | ||
|
|
||
| controller_interface::InterfaceConfiguration URConfigurationController::command_interface_configuration() const | ||
| { | ||
| // No command interfaces currently | ||
| controller_interface::InterfaceConfiguration config; | ||
| config.type = controller_interface::interface_configuration_type::INDIVIDUAL; | ||
|
|
||
| return config; | ||
| } | ||
|
|
||
| controller_interface::InterfaceConfiguration URConfigurationController::state_interface_configuration() const | ||
| { | ||
| controller_interface::InterfaceConfiguration config; | ||
| config.type = controller_interface::interface_configuration_type::INDIVIDUAL; | ||
|
|
||
| const std::string tf_prefix = params_.tf_prefix; | ||
|
|
||
| config.names.emplace_back(tf_prefix + "get_robot_software_version/get_version_major"); | ||
| config.names.emplace_back(tf_prefix + "get_robot_software_version/get_version_minor"); | ||
| config.names.emplace_back(tf_prefix + "get_robot_software_version/get_version_build"); | ||
| config.names.emplace_back(tf_prefix + "get_robot_software_version/get_version_bugfix"); | ||
|
|
||
| return config; | ||
| } | ||
|
|
||
| controller_interface::return_type URConfigurationController::update(const rclcpp::Time& /* time */, | ||
| const rclcpp::Duration& /* period */) | ||
| { | ||
| return controller_interface::return_type::OK; | ||
| } | ||
|
|
||
| controller_interface::CallbackReturn | ||
| URConfigurationController::on_activate(const rclcpp_lifecycle::State& /* previous_state */) | ||
| { | ||
| robot_software_version_.set([this](const std::shared_ptr<VersionInformation> ptr) { | ||
| ptr->major = state_interfaces_[StateInterfaces::ROBOT_VERSION_MAJOR].get_value(); | ||
| ptr->minor = state_interfaces_[StateInterfaces::ROBOT_VERSION_MINOR].get_value(); | ||
| ptr->build = state_interfaces_[StateInterfaces::ROBOT_VERSION_BUILD].get_value(); | ||
| ptr->bugfix = state_interfaces_[StateInterfaces::ROBOT_VERSION_BUGFIX].get_value(); | ||
| }); | ||
| return controller_interface::CallbackReturn::SUCCESS; | ||
| } | ||
|
|
||
| controller_interface::CallbackReturn | ||
| URConfigurationController::on_deactivate(const rclcpp_lifecycle::State& /* previous_state */) | ||
| { | ||
| return controller_interface::CallbackReturn::SUCCESS; | ||
| } | ||
|
|
||
| bool URConfigurationController::getRobotSoftwareVersion( | ||
| ur_msgs::srv::GetRobotSoftwareVersion::Request::SharedPtr /*req*/, | ||
| ur_msgs::srv::GetRobotSoftwareVersion::Response::SharedPtr resp) | ||
| { | ||
| std::shared_ptr<VersionInformation> temp; | ||
| return robot_software_version_.tryGet([resp](const std::shared_ptr<VersionInformation> ptr) { | ||
| resp->major = ptr->major; | ||
| resp->minor = ptr->minor; | ||
| resp->build = ptr->build; | ||
| resp->bugfix = ptr->bugfix; | ||
| }); | ||
| } | ||
| } // namespace ur_controllers | ||
|
|
||
| #include "pluginlib/class_list_macros.hpp" | ||
|
|
||
| PLUGINLIB_EXPORT_CLASS(ur_controllers::URConfigurationController, controller_interface::ControllerInterface) |
6 changes: 6 additions & 0 deletions
6
ur_controllers/src/ur_configuration_controller_parameters.yaml
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,6 @@ | ||
| ur_configuration_controller: | ||
| tf_prefix: { | ||
| type: string, | ||
| default_value: "", | ||
| description: "URDF prefix of the corresponding arm" | ||
| } |
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
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
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
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
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
Oops, something went wrong.
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.