Skip to content

Commit d7488c9

Browse files
committed
Use parameters for action servers
Remapping actions doesn't work in Humble
1 parent cdc4f42 commit d7488c9

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

ur_robot_driver/include/ur_robot_driver/trajectory_until_node.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#define UR_ROBOT_DRIVER__TRAJECTORY_UNTIL_NODE_HPP_
4343

4444
#include <memory>
45+
#include <string>
4546
#include <variant>
4647

4748
#include <rclcpp/rclcpp.hpp>
@@ -68,10 +69,12 @@ class TrajectoryUntilNode : public rclcpp::Node
6869

6970
rclcpp_action::Server<TrajectoryUntilAction>::SharedPtr action_server_;
7071
rclcpp_action::Client<control_msgs::action::FollowJointTrajectory>::SharedPtr trajectory_action_client_;
72+
std::string trajectory_action_uri_;
7173

7274
// Add new until types here, when available
7375
using TCClient = rclcpp_action::Client<ur_msgs::action::ToolContact>::SharedPtr;
7476
std::variant<TCClient> until_action_client_variant;
77+
std::string until_action_uri_;
7578

7679
rclcpp::CallbackGroup::SharedPtr server_callback_group;
7780
rclcpp::CallbackGroup::SharedPtr clients_callback_group;

ur_robot_driver/launch/ur_control.launch.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,11 @@ def launch_setup(context, *args, **kwargs):
335335
executable="trajectory_until_node",
336336
name="trajectory_until_node",
337337
output="screen",
338-
remappings=[
339-
(
340-
"/motion_controller/follow_joint_trajectory",
341-
f"/{initial_joint_controller.perform(context)}/follow_joint_trajectory",
342-
),
338+
parameters=[
339+
{
340+
"motion_controller_uri": f"/{initial_joint_controller.perform(context)}/follow_joint_trajectory",
341+
"until_action_uri": "tool_contact_controller/detect_tool_contact",
342+
},
343343
],
344344
)
345345

ur_robot_driver/src/trajectory_until_node.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ TrajectoryUntilNode::TrajectoryUntilNode(const rclcpp::NodeOptions& options)
6666
server_callback_group = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
6767
clients_callback_group = create_callback_group(rclcpp::CallbackGroupType::MutuallyExclusive);
6868

69+
declare_parameter("motion_controller_uri", "scaled_joint_trajectory_controller/follow_joint_trajectory");
70+
get_parameter("motion_controller_uri", trajectory_action_uri_);
6971
// Initialize a trajectory action client, to a generic action that does not exist. This is remapped via ros-args when
7072
// launching the node
71-
trajectory_action_client_ = rclcpp_action::create_client<FollowJointTrajectory>(this,
72-
"/motion_controller/"
73-
"follow_joint_"
74-
"trajectory",
75-
clients_callback_group);
73+
trajectory_action_client_ =
74+
rclcpp_action::create_client<FollowJointTrajectory>(this, trajectory_action_uri_, clients_callback_group);
75+
76+
declare_parameter("until_action_uri", "tool_contact_controller/detect_tool_contact");
77+
get_parameter("until_action_uri", until_action_uri_);
7678

7779
// Create action server to advertise the "/trajectory_until_node/execute"
7880
action_server_ = rclcpp_action::create_server<TrajectoryUntilAction>(
@@ -92,10 +94,8 @@ bool TrajectoryUntilNode::assign_until_action_client(std::shared_ptr<const Traje
9294
{
9395
switch (goal->until_type) {
9496
case TrajectoryUntilAction::Goal::TOOL_CONTACT:
95-
until_action_client_variant = rclcpp_action::create_client<TCAction>(this,
96-
"/tool_contact_controller/"
97-
"detect_tool_contact",
98-
clients_callback_group);
97+
until_action_client_variant =
98+
rclcpp_action::create_client<TCAction>(this, until_action_uri_, clients_callback_group);
9999
break;
100100

101101
default:
@@ -122,12 +122,7 @@ rclcpp_action::GoalResponse TrajectoryUntilNode::goal_received_callback(
122122
}
123123

124124
if (!trajectory_action_client_->wait_for_action_server(std::chrono::seconds(1))) {
125-
std::string send_goal_service_name = get_node_base_interface()->resolve_topic_or_service_name("/motion_controller/"
126-
"follow_joint_"
127-
"trajectory/_action/"
128-
"send_goal",
129-
true);
130-
RCLCPP_ERROR(this->get_logger(), "Trajectory action server at %s not available.", send_goal_service_name.c_str());
125+
RCLCPP_ERROR(this->get_logger(), "Trajectory action server at %s not available.", trajectory_action_uri_.c_str());
131126
return rclcpp_action::GoalResponse::REJECT;
132127
}
133128

0 commit comments

Comments
 (0)