-
Notifications
You must be signed in to change notification settings - Fork 305
Added controller to enable and disable tool contact #940
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 36 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
af26b1e
Added service to enable and disable tool contact
URJala c1940cf
Revert "Added service to enable and disable tool contact"
URJala a62e842
Implemented tool contact
URJala da6c288
Implement test of tool contact
URJala 4a4baa9
Merge remote-tracking branch 'origin/main' into tool_contact
c499541
Merge branch 'main' into tool_contact
URJala 2992337
Intermediate commit
URJala 4e4a24b
intermediate coomit
URJala b7eaf35
Tool contact controller is functional
URJala b19f71e
Intermediate commit
URJala b17a72c
Tool contact controller works when used with an action. Chaining is s…
URJala 2224514
Merge branch 'main' into tool_contact
URJala 947c30f
Add version check and fix formatting
URJala 8b46761
started writing integration tests
URJala 395a09c
Merge branch 'main' into tool_contact
URJala 102204e
Remove chaining from controller and add trajectory_until node
URJala 8e570be
Merge branch 'main' into tool_contact
URJala bdf5ae8
Clean up of code and logging. Added comments as well.
URJala b8917af
Merge branch 'main' into tool_contact
URJala a45d546
Added documentation and started writing tests
URJala a5a3ed6
Add test parameter of initial joint controller to test with different…
URJala 57b4693
Remove until node from docs and cmake
URJala b18bfc3
Refactor tool contact controller
URJala 85b7c01
Remove trajectory until node
URJala bd7d050
Wrote more tests and a little refactoring
URJala 179224f
Merge branch 'main' into tool_contact
URJala 06a9b39
Merge branch 'main' into tool_contact
URJala 7f46156
Revert "Apply renaming of member variables of JTC (#1275)"
URJala 0f92d5f
Remove Aborted and preempted from result reports
URJala 3b27be0
Remove succesful result as well
URJala 9959221
Revert "Apply renaming of member variables of JTC (#1275)"
URJala ed02c20
Reapply "Apply renaming of member variables of JTC (#1275)"
URJala c154ea5
Reapply "Apply renaming of member variables of JTC (#1275)"
URJala f7b898c
Update test and docs to the empty action definition
URJala e65e5fe
Merge branch 'main' into tool_contact
URJala 79f3025
Update to use std::optional
URJala d3c228c
Merge remote-tracking branch 'origin/main' into tool_contact
urfeex f5bcaea
Add tool_contact_controllert to controller_switch tests
urfeex 7bc8df1
Update controller documentation
urfeex 39d1830
Use escaped parentheses in script_directory_url
urfeex 2b46088
forward command interface to state interface
URJala 2cf021f
Merge branch 'tool_contact' of github.com:URJala/Universal_Robots_ROS…
URJala e77410c
Change status to set_state in start_interfaces
URJala de7c107
Merge remote-tracking branch 'origin/main' into tool_contact
urfeex c36e961
Allow starting and stopping multiple interfaces at once
urfeex 86a59ca
Fix state interface to get version information from
urfeex baa9f7c
Apply suggestions from code review
URJala 7443b54
Merge branch 'main' into tool_contact
URJala e4a2bf4
Change name of goal_canceled_callback
URJala d173581
Tool contact is ended in the hardware interface, when controller is a…
URJala 0d1fb3b
Publish feedback and handle cancel correctly
urfeex 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
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
133 changes: 133 additions & 0 deletions
133
ur_controllers/include/ur_controllers/tool_contact_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,133 @@ | ||
| // Copyright 2025, 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 2025-01-07 | ||
| * | ||
| * | ||
| * | ||
| * | ||
| */ | ||
| //---------------------------------------------------------------------- | ||
|
|
||
| #ifndef UR_CONTROLLERS__TOOL_CONTACT_CONTROLLER_HPP_ | ||
| #define UR_CONTROLLERS__TOOL_CONTACT_CONTROLLER_HPP_ | ||
|
|
||
| #include <chrono> | ||
| #include <vector> | ||
| #include <memory> | ||
|
|
||
| #include <controller_interface/controller_interface.hpp> | ||
| #include "std_msgs/msg/bool.hpp" | ||
| #include <rclcpp_action/server.hpp> | ||
| #include <rclcpp_action/create_server.hpp> | ||
| #include <rclcpp/rclcpp.hpp> | ||
| #include <rclcpp_action/server_goal_handle.hpp> | ||
| #include <rclcpp/duration.hpp> | ||
|
|
||
| #include <realtime_tools/realtime_buffer.hpp> | ||
| #include <realtime_tools/realtime_server_goal_handle.hpp> | ||
|
|
||
| #include <ur_msgs/action/tool_contact.hpp> | ||
| #include "ur_controllers/tool_contact_controller_parameters.hpp" | ||
|
|
||
| namespace ur_controllers | ||
| { | ||
| class ToolContactController : public controller_interface::ControllerInterface | ||
| { | ||
| public: | ||
| ToolContactController() = default; | ||
| ~ToolContactController() override = default; | ||
|
|
||
| controller_interface::CallbackReturn on_init() override; | ||
|
|
||
| controller_interface::InterfaceConfiguration command_interface_configuration() const override; | ||
|
|
||
| controller_interface::InterfaceConfiguration state_interface_configuration() const override; | ||
|
|
||
| controller_interface::CallbackReturn on_configure(const rclcpp_lifecycle::State& previous_state) override; | ||
|
|
||
| controller_interface::CallbackReturn on_activate(const rclcpp_lifecycle::State& previous_state) override; | ||
|
|
||
| controller_interface::CallbackReturn on_deactivate(const rclcpp_lifecycle::State& previous_state) override; | ||
|
|
||
| controller_interface::CallbackReturn on_shutdown(const rclcpp_lifecycle::State& previous_state) override; | ||
|
|
||
| controller_interface::return_type update(const rclcpp::Time& time, const rclcpp::Duration& period) override; | ||
|
|
||
| private: | ||
| using RealtimeGoalHandle = realtime_tools::RealtimeServerGoalHandle<ur_msgs::action::ToolContact>; | ||
| using RealtimeGoalHandlePtr = std::shared_ptr<RealtimeGoalHandle>; | ||
| using RealtimeGoalHandleBuffer = realtime_tools::RealtimeBuffer<RealtimeGoalHandlePtr>; | ||
|
|
||
| RealtimeGoalHandleBuffer rt_active_goal_; ///< Currently active action goal, if any. | ||
| rclcpp::TimerBase::SharedPtr goal_handle_timer_; ///< Timer to frequently check on the running goal | ||
| rclcpp::Duration action_monitor_period_ = rclcpp::Duration::from_seconds(0.05); | ||
|
|
||
| void action_handler(); | ||
|
|
||
| rclcpp_action::GoalResponse goal_received_callback(const rclcpp_action::GoalUUID& /*uuid*/, | ||
| std::shared_ptr<const ur_msgs::action::ToolContact::Goal> goal); | ||
|
|
||
| void | ||
| goal_accepted_callback(std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::ToolContact>> goal_handle); | ||
|
|
||
| rclcpp_action::CancelResponse goal_cancelled_callback( | ||
URJala marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::ToolContact>> goal_handle); | ||
|
|
||
| std::atomic<bool> tool_contact_enable_ = false; | ||
| std::atomic<bool> tool_contact_active_ = false; | ||
| std::atomic<bool> tool_contact_abort_ = false; | ||
| std::atomic<bool> change_requested_ = false; | ||
| std::atomic<bool> logged_once_ = false; | ||
| std::atomic<bool> should_reset_goal = false; | ||
|
|
||
| std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> tool_contact_result_interface_; | ||
| std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> major_version_state_interface_; | ||
| std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>> tool_contact_state_interface_; | ||
| std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>> tool_contact_set_state_interface_; | ||
|
|
||
| rclcpp_action::Server<ur_msgs::action::ToolContact>::SharedPtr tool_contact_action_server_; | ||
|
|
||
| std::shared_ptr<tool_contact_controller::ParamListener> tool_contact_param_listener_; | ||
| tool_contact_controller::Params tool_contact_params_; | ||
|
|
||
| static constexpr double TOOL_CONTACT_STANDBY = 1.0; | ||
| static constexpr double TOOL_CONTACT_WAITING_BEGIN = 2.0; | ||
| static constexpr double TOOL_CONTACT_EXECUTING = 3.0; | ||
| static constexpr double TOOL_CONTACT_FAILURE_BEGIN = 4.0; | ||
| static constexpr double TOOL_CONTACT_WAITING_END = 5.0; | ||
| static constexpr double TOOL_CONTACT_SUCCESS_END = 6.0; | ||
| static constexpr double TOOL_CONTACT_FAILURE_END = 7.0; | ||
| }; | ||
| } // namespace ur_controllers | ||
|
|
||
| #endif // UR_CONTROLLERS__TOOL_CONTACT_CONTROLLER_HPP_ | ||
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.