Skip to content

Commit 7350857

Browse files
committed
Change includes and rename action
1 parent 2603a1e commit 7350857

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

ur_robot_driver/include/ur_robot_driver/trajectory_until_node.hpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#include <rclcpp_action/server_goal_handle.hpp>
5353
#include <rclcpp/duration.hpp>
5454
#include <ur_msgs/action/tool_contact.hpp>
55-
#include <ur_msgs/action/trajectory_until.hpp>
55+
#include <ur_msgs/action/follow_joint_trajectory_until.hpp>
5656
#include <control_msgs/action/follow_joint_trajectory.hpp>
5757

5858
namespace ur_robot_driver
@@ -64,7 +64,9 @@ class TrajectoryUntilNode : public rclcpp::Node
6464
~TrajectoryUntilNode();
6565

6666
private:
67-
rclcpp_action::Server<ur_msgs::action::TrajectoryUntil>::SharedPtr action_server_;
67+
using TrajectoryUntilAction = ur_msgs::action::FollowJointTrajectoryUntil;
68+
69+
rclcpp_action::Server<TrajectoryUntilAction>::SharedPtr action_server_;
6870
rclcpp_action::Client<control_msgs::action::FollowJointTrajectory>::SharedPtr trajectory_action_client_;
6971

7072
// Add new until types here, when available
@@ -74,10 +76,10 @@ class TrajectoryUntilNode : public rclcpp::Node
7476
rclcpp::CallbackGroup::SharedPtr server_callback_group;
7577
rclcpp::CallbackGroup::SharedPtr clients_callback_group;
7678

77-
std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::TrajectoryUntil>> server_goal_handle_;
79+
std::shared_ptr<rclcpp_action::ServerGoalHandle<TrajectoryUntilAction>> server_goal_handle_;
7880

7981
template <class ActionType, class ClientType>
80-
void send_until_goal(std::shared_ptr<const ur_msgs::action::TrajectoryUntil::Goal> goal);
82+
void send_until_goal(std::shared_ptr<const TrajectoryUntilAction::Goal> goal);
8183

8284
template <class T>
8385
void until_response_callback(const typename rclcpp_action::ClientGoalHandle<T>::SharedPtr& goal_handle);
@@ -95,16 +97,16 @@ class TrajectoryUntilNode : public rclcpp::Node
9597
void trajectory_result_callback(
9698
const rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult& result);
9799

98-
bool assign_until_action_client(std::shared_ptr<const ur_msgs::action::TrajectoryUntil::Goal> goal);
100+
bool assign_until_action_client(std::shared_ptr<const TrajectoryUntilAction::Goal> goal);
99101

100102
rclcpp_action::GoalResponse goal_received_callback(
101-
const rclcpp_action::GoalUUID& uuid, std::shared_ptr<const ur_msgs::action::TrajectoryUntil::Goal> goal);
103+
const rclcpp_action::GoalUUID& uuid, std::shared_ptr<const TrajectoryUntilAction::Goal> goal);
102104
void goal_accepted_callback(
103-
const std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::TrajectoryUntil>> goal_handle);
105+
const std::shared_ptr<rclcpp_action::ServerGoalHandle<TrajectoryUntilAction>> goal_handle);
104106
rclcpp_action::CancelResponse goal_cancelled_callback(
105-
const std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::TrajectoryUntil>> goal_handle);
107+
const std::shared_ptr<rclcpp_action::ServerGoalHandle<TrajectoryUntilAction>> goal_handle);
106108

107-
void send_trajectory_goal(std::shared_ptr<const ur_msgs::action::TrajectoryUntil::Goal> goal);
109+
void send_trajectory_goal(std::shared_ptr<const TrajectoryUntilAction::Goal> goal);
108110

109111
void report_goal(rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult result);
110112

@@ -117,9 +119,9 @@ class TrajectoryUntilNode : public rclcpp::Node
117119
current_trajectory_goal_handle_;
118120
rclcpp_action::ClientGoalHandle<ur_msgs::action::ToolContact>::SharedPtr current_until_goal_handle_;
119121

120-
std::shared_ptr<ur_msgs::action::TrajectoryUntil::Result> prealloc_res;
122+
std::shared_ptr<TrajectoryUntilAction::Result> prealloc_res;
121123

122-
std::shared_ptr<ur_msgs::action::TrajectoryUntil::Feedback> prealloc_fb;
124+
std::shared_ptr<TrajectoryUntilAction::Feedback> prealloc_fb;
123125

124126
std::atomic<bool> trajectory_accepted_;
125127
std::atomic<bool> until_accepted_;

ur_robot_driver/src/trajectory_until_node.cpp

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ namespace ur_robot_driver
4646
{
4747

4848
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>;
5150
using FollowJointTrajectory = control_msgs::action::FollowJointTrajectory;
5251
using TrajectoryResult = rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult;
5352

@@ -61,8 +60,8 @@ TrajectoryUntilNode::TrajectoryUntilNode(const rclcpp::NodeOptions& options)
6160
, trajectory_accepted_(false)
6261
, until_accepted_(false)
6362
{
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());
6665

6766
// Different callback groups for the server and the clients, so their callbacks can run concurrently.
6867
server_callback_group = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
@@ -77,7 +76,7 @@ TrajectoryUntilNode::TrajectoryUntilNode(const rclcpp::NodeOptions& options)
7776
clients_callback_group);
7877

7978
// 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>(
8180
this, std::string(this->get_name()) + "/execute",
8281
std::bind(&TrajectoryUntilNode::goal_received_callback, this, std::placeholders::_1, std::placeholders::_2),
8382
std::bind(&TrajectoryUntilNode::goal_cancelled_callback, this, std::placeholders::_1),
@@ -90,11 +89,10 @@ TrajectoryUntilNode::~TrajectoryUntilNode()
9089
}
9190

9291
// 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)
9493
{
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:
9896
until_action_client_variant = rclcpp_action::create_client<TCAction>(this,
9997
"/tool_contact_controller/"
10098
"detect_tool_contact",
@@ -111,7 +109,7 @@ bool TrajectoryUntilNode::assign_until_action_client(std::shared_ptr<const Traje
111109

112110
// Check if the node is capable of accepting a new action goal right now.
113111
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)
115113
{
116114
if (server_goal_handle_) {
117115
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
184182
}
185183

186184
// 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)
188186
{
189187
auto goal_msg = FollowJointTrajectory::Goal();
190188
goal_msg.trajectory = goal->trajectory;
@@ -204,7 +202,7 @@ void TrajectoryUntilNode::send_trajectory_goal(std::shared_ptr<const TrajectoryU
204202

205203
// Send the until goal, using the relevant fields supplied from the action server.
206204
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 */)
208206
{
209207
// Setup goal
210208
auto goal_msg = typename ActionType::Goal();
@@ -219,7 +217,7 @@ void TrajectoryUntilNode::send_until_goal(std::shared_ptr<const TrajectoryUntil:
219217
}
220218

221219
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)
223221
{
224222
{
225223
std::lock_guard<std::mutex> guard(mutex_trajectory);
@@ -253,8 +251,8 @@ void TrajectoryUntilNode::until_response_callback(
253251

254252
// Just forward feedback from trajectory controller. No feedback from until controllers so far.
255253
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)
258256
{
259257
if (server_goal_handle_) {
260258
prealloc_fb->actual = feedback->actual;
@@ -270,7 +268,7 @@ void TrajectoryUntilNode::trajectory_feedback_callback(
270268

271269
// When a result is received from either trajectory or until condition, report it back to user
272270
void TrajectoryUntilNode::trajectory_result_callback(
273-
const rclcpp_action::ClientGoalHandle<control_msgs::action::FollowJointTrajectory>::WrappedResult& result)
271+
const TrajectoryResult& result)
274272
{
275273
RCLCPP_INFO(this->get_logger(), "Trajectory result received.");
276274
current_trajectory_goal_handle_.reset();
@@ -289,7 +287,7 @@ void TrajectoryUntilNode::until_result_callback(
289287
void TrajectoryUntilNode::report_goal(TrajectoryResult result)
290288
{
291289
if (server_goal_handle_) {
292-
prealloc_res->until_condition_result = TrajectoryUntil::Result::NOT_TRIGGERED;
290+
prealloc_res->until_condition_result = TrajectoryUntilAction::Result::NOT_TRIGGERED;
293291
prealloc_res->error_code = result.result->error_code;
294292
prealloc_res->error_string = result.result->error_string;
295293
switch (result.code) {
@@ -328,8 +326,8 @@ void TrajectoryUntilNode::report_goal(UntilResult result)
328326
if (server_goal_handle_) {
329327
switch (result.code) {
330328
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;
333331
prealloc_res->error_string += "Trajectory finished successfully by triggering until condition.";
334332
server_goal_handle_->succeed(prealloc_res);
335333
break;
@@ -374,8 +372,8 @@ void TrajectoryUntilNode::reset_node()
374372
current_until_goal_handle_ = nullptr;
375373
trajectory_accepted_ = false;
376374
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());
379377

380378
server_goal_handle_ = nullptr;
381379
}

0 commit comments

Comments
 (0)