4242#include < functional>
4343#include < thread>
4444
45- template <class T >
46- struct until_container
47- {
48- T until_client_type;
49- };
50-
5145namespace ur_robot_driver
5246{
5347
@@ -82,7 +76,7 @@ TrajectoryUntilNode::TrajectoryUntilNode(const rclcpp::NodeOptions& options)
8276 " trajectory" ,
8377 clients_callback_group);
8478
85- // Create action server to advertise the "/trajectory_until /execute"
79+ // Create action server to advertise the "/trajectory_until_node /execute"
8680 action_server_ = rclcpp_action::create_server<TrajectoryUntil>(
8781 this , std::string (this ->get_name ()) + " /execute" ,
8882 std::bind (&TrajectoryUntilNode::goal_received_callback, this , std::placeholders::_1, std::placeholders::_2),
@@ -95,6 +89,7 @@ TrajectoryUntilNode::~TrajectoryUntilNode()
9589{
9690}
9791
92+ // Assign the correct type of action client to the variant
9893bool TrajectoryUntilNode::assign_until_action_client (std::shared_ptr<const TrajectoryUntil::Goal> goal)
9994{
10095 int type = goal->until_type ;
@@ -134,12 +129,12 @@ rclcpp_action::GoalResponse TrajectoryUntilNode::goal_received_callback(
134129 }
135130
136131 // Check until action server, send action goal to until-controller and wait for it to be accepted.
137- if (std::holds_alternative<tc_client >(until_action_client_variant)){
138- if (!std::get<tc_client >(until_action_client_variant)->wait_for_action_server (std::chrono::seconds (1 ))) {
132+ if (std::holds_alternative<TCClient >(until_action_client_variant)){
133+ if (!std::get<TCClient >(until_action_client_variant)->wait_for_action_server (std::chrono::seconds (1 ))) {
139134 RCLCPP_ERROR (this ->get_logger (), " Until action server not available." );
140135 return rclcpp_action::GoalResponse::REJECT;
141136 }
142- send_until_goal<TCAction, tc_client >(goal);
137+ send_until_goal<TCAction, TCClient >(goal);
143138 }
144139 else {
145140 throw std::runtime_error (" Until type not implemented. This should not happen." );
@@ -186,8 +181,6 @@ TrajectoryUntilNode::goal_cancelled_callback(const std::shared_ptr<GoalHandleTra
186181 trajectory_action_client_->async_cancel_goal (current_trajectory_goal_handle_);
187182 }
188183
189- // server_goal_handle_ = nullptr;
190-
191184 return rclcpp_action::CancelResponse::ACCEPT;
192185}
193186
@@ -259,7 +252,7 @@ void TrajectoryUntilNode::until_response_callback(
259252 cv_until_.notify_one ();
260253}
261254
262- /* Just forward feedback from trajectory controller */
255+ // Just forward feedback from trajectory controller. No feedback from until controllers so far.
263256void TrajectoryUntilNode::trajectory_feedback_callback (
264257 const rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::SharedPtr& /* goal_handle */ ,
265258 const std::shared_ptr<const control_msgs::action::FollowJointTrajectory::Feedback> feedback)
@@ -276,6 +269,7 @@ void TrajectoryUntilNode::trajectory_feedback_callback(
276269 }
277270}
278271
272+ // When a result is received from either trajectory or until condition, report it back to user
279273void TrajectoryUntilNode::trajectory_result_callback (
280274 const rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult& result)
281275{
@@ -312,7 +306,7 @@ void TrajectoryUntilNode::report_goal(TrajectoryResult result)
312306 prealloc_res->error_string += " Trajectory action was canceled." ;
313307 server_goal_handle_->canceled (prealloc_res);
314308 break ;
315-
309+
316310 default :
317311 prealloc_res->error_string += " Unknown result code received from trajectory action, this should not happen. "
318312 " Aborting goal." ;
0 commit comments