@@ -46,8 +46,7 @@ namespace ur_robot_driver
46
46
{
47
47
48
48
using TCAction = ur_msgs::action::ToolContact;
49
- using TrajectoryUntil = ur_msgs::action::TrajectoryUntil;
50
- using GoalHandleTrajectoryUntil = rclcpp_action::ServerGoalHandle<TrajectoryUntil>;
49
+ using GoalHandleTrajectoryUntil = rclcpp_action::ServerGoalHandle<ur_msgs::action::FollowJointTrajectoryUntil>;
51
50
using FollowJointTrajectory = control_msgs::action::FollowJointTrajectory;
52
51
using TrajectoryResult = rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult;
53
52
@@ -61,8 +60,8 @@ TrajectoryUntilNode::TrajectoryUntilNode(const rclcpp::NodeOptions& options)
61
60
, trajectory_accepted_(false )
62
61
, until_accepted_(false )
63
62
{
64
- prealloc_res = std::make_shared<TrajectoryUntil ::Result>(TrajectoryUntil ::Result ());
65
- prealloc_fb = std::make_shared<TrajectoryUntil ::Feedback>(TrajectoryUntil ::Feedback ());
63
+ prealloc_res = std::make_shared<TrajectoryUntilAction ::Result>(TrajectoryUntilAction ::Result ());
64
+ prealloc_fb = std::make_shared<TrajectoryUntilAction ::Feedback>(TrajectoryUntilAction ::Feedback ());
66
65
67
66
// Different callback groups for the server and the clients, so their callbacks can run concurrently.
68
67
server_callback_group = create_callback_group (rclcpp::CallbackGroupType::MutuallyExclusive);
@@ -77,7 +76,7 @@ TrajectoryUntilNode::TrajectoryUntilNode(const rclcpp::NodeOptions& options)
77
76
clients_callback_group);
78
77
79
78
// Create action server to advertise the "/trajectory_until_node/execute"
80
- action_server_ = rclcpp_action::create_server<TrajectoryUntil >(
79
+ action_server_ = rclcpp_action::create_server<TrajectoryUntilAction >(
81
80
this , std::string (this ->get_name ()) + " /execute" ,
82
81
std::bind (&TrajectoryUntilNode::goal_received_callback, this , std::placeholders::_1, std::placeholders::_2),
83
82
std::bind (&TrajectoryUntilNode::goal_cancelled_callback, this , std::placeholders::_1),
@@ -90,11 +89,10 @@ TrajectoryUntilNode::~TrajectoryUntilNode()
90
89
}
91
90
92
91
// Assign the correct type of action client to the variant
93
- bool TrajectoryUntilNode::assign_until_action_client (std::shared_ptr<const TrajectoryUntil ::Goal> goal)
92
+ bool TrajectoryUntilNode::assign_until_action_client (std::shared_ptr<const TrajectoryUntilAction ::Goal> goal)
94
93
{
95
- int type = goal->until_type ;
96
- switch (type) {
97
- case TrajectoryUntil::Goal::TOOL_CONTACT:
94
+ switch (goal->until_type ) {
95
+ case TrajectoryUntilAction::Goal::TOOL_CONTACT:
98
96
until_action_client_variant = rclcpp_action::create_client<TCAction>(this ,
99
97
" /tool_contact_controller/"
100
98
" detect_tool_contact" ,
@@ -111,7 +109,7 @@ bool TrajectoryUntilNode::assign_until_action_client(std::shared_ptr<const Traje
111
109
112
110
// Check if the node is capable of accepting a new action goal right now.
113
111
rclcpp_action::GoalResponse TrajectoryUntilNode::goal_received_callback (
114
- const rclcpp_action::GoalUUID& /* uuid */ , std::shared_ptr<const TrajectoryUntil ::Goal> goal)
112
+ const rclcpp_action::GoalUUID& /* uuid */ , std::shared_ptr<const TrajectoryUntilAction ::Goal> goal)
115
113
{
116
114
if (server_goal_handle_) {
117
115
RCLCPP_ERROR (this ->get_logger (), " Node is currently busy, rejecting action goal." );
@@ -184,7 +182,7 @@ TrajectoryUntilNode::goal_cancelled_callback(const std::shared_ptr<GoalHandleTra
184
182
}
185
183
186
184
// Send the trajectory goal, using the relevant fields supplied from the action server
187
- void TrajectoryUntilNode::send_trajectory_goal (std::shared_ptr<const TrajectoryUntil ::Goal> goal)
185
+ void TrajectoryUntilNode::send_trajectory_goal (std::shared_ptr<const TrajectoryUntilAction ::Goal> goal)
188
186
{
189
187
auto goal_msg = FollowJointTrajectory::Goal ();
190
188
goal_msg.trajectory = goal->trajectory ;
@@ -204,7 +202,7 @@ void TrajectoryUntilNode::send_trajectory_goal(std::shared_ptr<const TrajectoryU
204
202
205
203
// Send the until goal, using the relevant fields supplied from the action server.
206
204
template <class ActionType , class ClientType >
207
- void TrajectoryUntilNode::send_until_goal (std::shared_ptr<const TrajectoryUntil ::Goal> /* goal */ )
205
+ void TrajectoryUntilNode::send_until_goal (std::shared_ptr<const TrajectoryUntilAction ::Goal> /* goal */ )
208
206
{
209
207
// Setup goal
210
208
auto goal_msg = typename ActionType::Goal ();
@@ -219,7 +217,7 @@ void TrajectoryUntilNode::send_until_goal(std::shared_ptr<const TrajectoryUntil:
219
217
}
220
218
221
219
void TrajectoryUntilNode::trajectory_response_callback (
222
- const rclcpp_action::ClientGoalHandle<control_msgs::action:: FollowJointTrajectory>::SharedPtr& goal_handle)
220
+ const rclcpp_action::ClientGoalHandle<FollowJointTrajectory>::SharedPtr& goal_handle)
223
221
{
224
222
{
225
223
std::lock_guard<std::mutex> guard (mutex_trajectory);
@@ -253,8 +251,8 @@ void TrajectoryUntilNode::until_response_callback(
253
251
254
252
// Just forward feedback from trajectory controller. No feedback from until controllers so far.
255
253
void TrajectoryUntilNode::trajectory_feedback_callback (
256
- const rclcpp_action::ClientGoalHandle<control_msgs::action:: FollowJointTrajectory>::SharedPtr& /* goal_handle */ ,
257
- const std::shared_ptr<const control_msgs::action:: FollowJointTrajectory::Feedback> feedback)
254
+ const rclcpp_action::ClientGoalHandle<FollowJointTrajectory>::SharedPtr& /* goal_handle */ ,
255
+ const std::shared_ptr<const FollowJointTrajectory::Feedback> feedback)
258
256
{
259
257
if (server_goal_handle_) {
260
258
prealloc_fb->actual = feedback->actual ;
@@ -270,7 +268,7 @@ void TrajectoryUntilNode::trajectory_feedback_callback(
270
268
271
269
// When a result is received from either trajectory or until condition, report it back to user
272
270
void TrajectoryUntilNode::trajectory_result_callback (
273
- const rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult & result)
271
+ const TrajectoryResult & result)
274
272
{
275
273
RCLCPP_INFO (this ->get_logger (), " Trajectory result received." );
276
274
current_trajectory_goal_handle_.reset ();
@@ -289,7 +287,7 @@ void TrajectoryUntilNode::until_result_callback(
289
287
void TrajectoryUntilNode::report_goal (TrajectoryResult result)
290
288
{
291
289
if (server_goal_handle_) {
292
- prealloc_res->until_condition_result = TrajectoryUntil ::Result::NOT_TRIGGERED;
290
+ prealloc_res->until_condition_result = TrajectoryUntilAction ::Result::NOT_TRIGGERED;
293
291
prealloc_res->error_code = result.result ->error_code ;
294
292
prealloc_res->error_string = result.result ->error_string ;
295
293
switch (result.code ) {
@@ -328,8 +326,8 @@ void TrajectoryUntilNode::report_goal(UntilResult result)
328
326
if (server_goal_handle_) {
329
327
switch (result.code ) {
330
328
case rclcpp_action::ResultCode::SUCCEEDED:
331
- prealloc_res->error_code = TrajectoryUntil ::Result::SUCCESSFUL;
332
- prealloc_res->until_condition_result = ur_msgs::action::TrajectoryUntil ::Result::TRIGGERED;
329
+ prealloc_res->error_code = TrajectoryUntilAction ::Result::SUCCESSFUL;
330
+ prealloc_res->until_condition_result = TrajectoryUntilAction ::Result::TRIGGERED;
333
331
prealloc_res->error_string += " Trajectory finished successfully by triggering until condition." ;
334
332
server_goal_handle_->succeed (prealloc_res);
335
333
break ;
@@ -374,8 +372,8 @@ void TrajectoryUntilNode::reset_node()
374
372
current_until_goal_handle_ = nullptr ;
375
373
trajectory_accepted_ = false ;
376
374
until_accepted_ = false ;
377
- prealloc_res = std::make_shared<TrajectoryUntil ::Result>(TrajectoryUntil ::Result ());
378
- prealloc_fb = std::make_shared<TrajectoryUntil ::Feedback>(TrajectoryUntil ::Feedback ());
375
+ prealloc_res = std::make_shared<TrajectoryUntilAction ::Result>(TrajectoryUntilAction ::Result ());
376
+ prealloc_fb = std::make_shared<TrajectoryUntilAction ::Feedback>(TrajectoryUntilAction ::Feedback ());
379
377
380
378
server_goal_handle_ = nullptr ;
381
379
}
0 commit comments