Skip to content

Commit dc8b203

Browse files
committed
Pass trajectory controller as parameter
Remapping actions doesn't work on ROS humble
1 parent 8cad6e7 commit dc8b203

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

ur_robot_driver/launch/ur_control.launch.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,10 @@ def launch_setup(context):
163163
executable="trajectory_until_node",
164164
name="trajectory_until_node",
165165
output="screen",
166-
remappings=[
167-
(
168-
"/motion_controller/follow_joint_trajectory",
169-
f"/{initial_joint_controller.perform(context)}/follow_joint_trajectory",
170-
),
166+
parameters=[
167+
{
168+
"motion_controller": initial_joint_controller,
169+
},
171170
],
172171
)
173172

ur_robot_driver/src/trajectory_until_node.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,14 @@ 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+
this->declare_parameter("motion_controller", "scaled_joint_trajectory_controller");
70+
std::string motion_controller = this->get_parameter("motion_controller").as_string();
71+
6972
// Initialize a trajectory action client, to a generic action that does not exist. This is remapped via ros-args when
7073
// launching the node
7174
trajectory_action_client_ = rclcpp_action::create_client<FollowJointTrajectory>(this,
72-
"/motion_controller/"
73-
"follow_joint_"
75+
motion_controller +
76+
"/follow_joint_"
7477
"trajectory",
7578
clients_callback_group);
7679

ur_robot_driver/test/integration_test_trajectory_until.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def setUp(self):
105105
# Tests
106106
#
107107

108-
def test_trajectory_with_tool_contact_no_trigger_succeeds(self, tf_prefix):
108+
def test_trajectory_with_tool_contact_no_trigger_succeeds(self, tf_prefix, initial_joint_controller):
109+
self._controller_manager_interface.wait_for_controller(initial_joint_controller)
109110
self.assertTrue(
110111
self._controller_manager_interface.switch_controller(
111112
strictness=SwitchController.Request.BEST_EFFORT,
@@ -133,18 +134,13 @@ def test_trajectory_with_tool_contact_no_trigger_succeeds(self, tf_prefix):
133134
self.assertEqual(
134135
result.until_condition_result, FollowJointTrajectoryUntil.Result.NOT_TRIGGERED
135136
)
136-
self.assertTrue(
137-
self._controller_manager_interface.switch_controller(
138-
strictness=SwitchController.Request.BEST_EFFORT,
139-
deactivate_controllers=["tool_contact_controller"],
140-
).ok
141-
)
142137

143-
def test_trajectory_until_can_cancel(self, tf_prefix):
138+
def test_trajectory_until_can_cancel(self, tf_prefix, initial_joint_controller):
139+
self._controller_manager_interface.wait_for_controller(initial_joint_controller)
144140
self.assertTrue(
145141
self._controller_manager_interface.switch_controller(
146142
strictness=SwitchController.Request.BEST_EFFORT,
147-
activate_controllers=["tool_contact_controller"],
143+
activate_controllers=["tool_contact_controller", initial_joint_controller],
148144
).ok
149145
)
150146
trajectory = JointTrajectory()
@@ -162,9 +158,3 @@ def test_trajectory_until_can_cancel(self, tf_prefix):
162158
self.assertTrue(goal_handle.accepted)
163159
result = self._trajectory_until_interface.cancel_goal(goal_handle)
164160
self.assertEqual(result.return_code, CancelGoal_Response.ERROR_NONE)
165-
self.assertTrue(
166-
self._controller_manager_interface.switch_controller(
167-
strictness=SwitchController.Request.BEST_EFFORT,
168-
deactivate_controllers=["tool_contact_controller"],
169-
).ok
170-
)

0 commit comments

Comments
 (0)