Skip to content

Commit bdf5ae8

Browse files
committed
Clean up of code and logging. Added comments as well.
1 parent 8e570be commit bdf5ae8

File tree

3 files changed

+163
-76
lines changed

3 files changed

+163
-76
lines changed

ur_controllers/include/ur_controllers/trajectory_until_node.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ class TrajectoryUntilNode : public rclcpp::Node
6565
rclcpp_action::Client<control_msgs::action::FollowJointTrajectory>::SharedPtr trajectory_action_client_;
6666
rclcpp_action::Client<ur_msgs::action::ToolContact>::SharedPtr until_action_client_;
6767

68-
rclcpp::CallbackGroup::SharedPtr server_callback_group =
69-
create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
70-
rclcpp::CallbackGroup::SharedPtr clients_callback_group =
71-
create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
68+
rclcpp::CallbackGroup::SharedPtr server_callback_group;
69+
rclcpp::CallbackGroup::SharedPtr clients_callback_group;
7270

7371
std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::TrajectoryUntil>> server_goal_handle_;
7472

@@ -95,24 +93,26 @@ class TrajectoryUntilNode : public rclcpp::Node
9593
const std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::TrajectoryUntil>> goal_handle);
9694

9795
void send_trajectory_goal(std::shared_ptr<const ur_msgs::action::TrajectoryUntil::Goal> goal);
96+
9897
void send_until_goal(std::shared_ptr<const ur_msgs::action::TrajectoryUntil::Goal> goal);
9998

100-
void report_goal(auto result, bool until_triggered);
99+
void report_goal(rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult result);
101100

102-
void reset_vars();
101+
template <typename UntilResult>
102+
void report_goal(UntilResult result);
103103

104-
std::atomic<bool> trajectory_accepted_;
105-
std::atomic<bool> until_accepted_;
104+
void reset_node();
106105

107106
rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::SharedPtr
108107
current_trajectory_goal_handle_;
109108
rclcpp_action::ClientGoalHandle<ur_msgs::action::ToolContact>::SharedPtr current_until_goal_handle_;
110109

111-
std::shared_ptr<ur_msgs::action::TrajectoryUntil::Result> prealloc_res =
112-
std::make_shared<ur_msgs::action::TrajectoryUntil::Result>(ur_msgs::action::TrajectoryUntil::Result());
110+
std::shared_ptr<ur_msgs::action::TrajectoryUntil::Result> prealloc_res;
113111

114-
std::shared_ptr<ur_msgs::action::TrajectoryUntil::Feedback> prealloc_fb =
115-
std::make_shared<ur_msgs::action::TrajectoryUntil::Feedback>(ur_msgs::action::TrajectoryUntil::Feedback());
112+
std::shared_ptr<ur_msgs::action::TrajectoryUntil::Feedback> prealloc_fb;
113+
114+
std::atomic<bool> trajectory_accepted_;
115+
std::atomic<bool> until_accepted_;
116116

117117
std::condition_variable cv_until_;
118118
std::condition_variable cv_trajectory_;

ur_controllers/src/tool_contact_controller.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ ToolContactController::on_deactivate(const rclcpp_lifecycle::State& /* previous_
164164
rt_active_goal_.writeFromNonRT(RealtimeGoalHandlePtr());
165165
}
166166
if (tool_contact_active_) {
167+
tool_contact_active_ = false;
167168
if (!tool_contact_status_interface_->get().set_value(TOOL_CONTACT_WAITING_END)) {
168169
failed_update();
169170
return controller_interface::CallbackReturn::ERROR;

0 commit comments

Comments
 (0)