Skip to content

Commit 5cf7bfb

Browse files
committed
pre-commit changes
1 parent a37987f commit 5cf7bfb

File tree

6 files changed

+46
-42
lines changed

6 files changed

+46
-42
lines changed

ur_robot_driver/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ target_link_libraries(trajectory_until_node PUBLIC
148148
${std_msgs_TARGETS}
149149
rclcpp_action::rclcpp_action
150150
${ur_msgs_TARGETS}
151-
)
151+
)
152152

153153
install(
154154
TARGETS

ur_robot_driver/doc/trajectory_until_node.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Implementation details
1919
""""""""""""""""""""""
2020
Upon instantiation of the node, the internal trajectory action client will connect to an action named ``motion_controller/follow_joint_trajectory``.
2121
This action does not exist, but upon launch of the driver, the node is remapped to connect to the ``initial_joint_controller``, default is ``scaled_joint_trajectory_controller``.
22-
If you wish to use the node with another motion controller use the launch argument ``initial_joint_controller:=<your_motion_controller>`` when launching the driver.
22+
If you wish to use the node with another motion controller use the launch argument ``initial_joint_controller:=<your_motion_controller>`` when launching the driver.

ur_robot_driver/include/ur_robot_driver/trajectory_until_node.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
#include <ur_msgs/action/trajectory_until.hpp>
5656
#include <control_msgs/action/follow_joint_trajectory.hpp>
5757

58-
5958
namespace ur_robot_driver
6059
{
6160
class TrajectoryUntilNode : public rclcpp::Node
@@ -77,16 +76,14 @@ class TrajectoryUntilNode : public rclcpp::Node
7776

7877
std::shared_ptr<rclcpp_action::ServerGoalHandle<ur_msgs::action::TrajectoryUntil>> server_goal_handle_;
7978

80-
template<class ActionType, class ClientType>
79+
template <class ActionType, class ClientType>
8180
void send_until_goal(std::shared_ptr<const ur_msgs::action::TrajectoryUntil::Goal> goal);
8281

83-
template<class T>
84-
void
85-
until_response_callback(const typename rclcpp_action::ClientGoalHandle<T>::SharedPtr& goal_handle);
82+
template <class T>
83+
void until_response_callback(const typename rclcpp_action::ClientGoalHandle<T>::SharedPtr& goal_handle);
8684

87-
template<class T>
88-
void
89-
until_result_callback(const typename rclcpp_action::ClientGoalHandle<T>::WrappedResult& result);
85+
template <class T>
86+
void until_result_callback(const typename rclcpp_action::ClientGoalHandle<T>::WrappedResult& result);
9087

9188
void cancel_until_goal();
9289

ur_robot_driver/launch/ur_control.launch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,11 @@ def launch_setup(context):
164164
name="trajectory_until_node",
165165
output="screen",
166166
remappings=[
167-
('/motion_controller/follow_joint_trajectory', f'/{initial_joint_controller.perform(context)}/follow_joint_trajectory'),
168-
]
167+
(
168+
"/motion_controller/follow_joint_trajectory",
169+
f"/{initial_joint_controller.perform(context)}/follow_joint_trajectory",
170+
),
171+
],
169172
)
170173

171174
# Spawn controllers

ur_robot_driver/src/trajectory_until_node.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ bool TrajectoryUntilNode::assign_until_action_client(std::shared_ptr<const Traje
9696
switch (type) {
9797
case TrajectoryUntil::Goal::TOOL_CONTACT:
9898
until_action_client_variant = rclcpp_action::create_client<TCAction>(this,
99-
"/tool_contact_controller/"
100-
"detect_tool_contact",
101-
clients_callback_group);
99+
"/tool_contact_controller/"
100+
"detect_tool_contact",
101+
clients_callback_group);
102102
break;
103103

104104
default:
@@ -118,7 +118,7 @@ rclcpp_action::GoalResponse TrajectoryUntilNode::goal_received_callback(
118118
return rclcpp_action::GoalResponse::REJECT;
119119
}
120120

121-
if(!assign_until_action_client(goal)){
121+
if (!assign_until_action_client(goal)) {
122122
RCLCPP_ERROR(this->get_logger(), "Until type not defined, double check the types in the action "
123123
"definition.");
124124
return rclcpp_action::GoalResponse::REJECT;
@@ -129,17 +129,16 @@ rclcpp_action::GoalResponse TrajectoryUntilNode::goal_received_callback(
129129
}
130130

131131
// Check until action server, send action goal to until-controller and wait for it to be accepted.
132-
if(std::holds_alternative<TCClient>(until_action_client_variant)){
132+
if (std::holds_alternative<TCClient>(until_action_client_variant)) {
133133
if (!std::get<TCClient>(until_action_client_variant)->wait_for_action_server(std::chrono::seconds(1))) {
134134
RCLCPP_ERROR(this->get_logger(), "Until action server not available.");
135135
return rclcpp_action::GoalResponse::REJECT;
136136
}
137137
send_until_goal<TCAction, TCClient>(goal);
138-
}
139-
else{
138+
} else {
140139
throw std::runtime_error("Until type not implemented. This should not happen.");
141140
}
142-
141+
143142
// If it is not accepted within 1 seconds, it is
144143
// assumed to be rejected.
145144
std::unique_lock<std::mutex> until_lock(mutex_until);
@@ -204,19 +203,19 @@ void TrajectoryUntilNode::send_trajectory_goal(std::shared_ptr<const TrajectoryU
204203
}
205204

206205
// Send the until goal, using the relevant fields supplied from the action server.
207-
template<class ActionType, class ClientType>
206+
template <class ActionType, class ClientType>
208207
void TrajectoryUntilNode::send_until_goal(std::shared_ptr<const TrajectoryUntil::Goal> /* goal */)
209208
{
210-
// Setup goal
209+
// Setup goal
211210
auto goal_msg = typename ActionType::Goal();
212211
auto send_goal_options = typename rclcpp_action::Client<ActionType>::SendGoalOptions();
213212
send_goal_options.goal_response_callback =
214-
std::bind(&TrajectoryUntilNode::until_response_callback<ActionType>, this, std::placeholders::_1);
213+
std::bind(&TrajectoryUntilNode::until_response_callback<ActionType>, this, std::placeholders::_1);
215214
send_goal_options.result_callback =
216-
std::bind(&TrajectoryUntilNode::until_result_callback<ActionType>, this, std::placeholders::_1);
215+
std::bind(&TrajectoryUntilNode::until_result_callback<ActionType>, this, std::placeholders::_1);
217216

218217
// Send goal
219-
std::get<ClientType>(until_action_client_variant) -> async_send_goal(goal_msg, send_goal_options);
218+
std::get<ClientType>(until_action_client_variant)->async_send_goal(goal_msg, send_goal_options);
220219
}
221220

222221
void TrajectoryUntilNode::trajectory_response_callback(
@@ -235,7 +234,7 @@ void TrajectoryUntilNode::trajectory_response_callback(
235234
cv_trajectory_.notify_one();
236235
}
237236

238-
template<class T>
237+
template <class T>
239238
void TrajectoryUntilNode::until_response_callback(
240239
const typename rclcpp_action::ClientGoalHandle<T>::SharedPtr& goal_handle)
241240
{
@@ -263,7 +262,7 @@ void TrajectoryUntilNode::trajectory_feedback_callback(
263262
prealloc_fb->error = feedback->error;
264263
prealloc_fb->header = feedback->header;
265264
prealloc_fb->joint_names = feedback->joint_names;
266-
if(server_goal_handle_){
265+
if (server_goal_handle_) {
267266
server_goal_handle_->publish_feedback(prealloc_fb);
268267
}
269268
}
@@ -278,8 +277,9 @@ void TrajectoryUntilNode::trajectory_result_callback(
278277
report_goal(result);
279278
}
280279

281-
template<class T>
282-
void TrajectoryUntilNode::until_result_callback(const typename rclcpp_action::ClientGoalHandle<T>::WrappedResult& result)
280+
template <class T>
281+
void TrajectoryUntilNode::until_result_callback(
282+
const typename rclcpp_action::ClientGoalHandle<T>::WrappedResult& result)
283283
{
284284
RCLCPP_INFO(this->get_logger(), "Until result received.");
285285
current_until_goal_handle_.reset();
@@ -345,8 +345,9 @@ void TrajectoryUntilNode::report_goal(UntilResult result)
345345
break;
346346

347347
default:
348-
prealloc_res->error_string += "Unknown result code received from until action, this should not happen. Aborting "
349-
"goal.";
348+
prealloc_res->error_string += "Unknown result code received from until action, this should not happen. "
349+
"Aborting "
350+
"goal.";
350351
server_goal_handle_->abort(prealloc_res);
351352

352353
break;
@@ -380,10 +381,10 @@ void TrajectoryUntilNode::reset_node()
380381
}
381382

382383
// Cancel the action contained in the variant, regardless of what type it is.
383-
void TrajectoryUntilNode::cancel_until_goal(){
384-
std::visit([this](const auto& until_client) {
385-
until_client->async_cancel_goal(current_until_goal_handle_);
386-
}, until_action_client_variant);
384+
void TrajectoryUntilNode::cancel_until_goal()
385+
{
386+
std::visit([this](const auto& until_client) { until_client->async_cancel_goal(current_until_goal_handle_); },
387+
until_action_client_variant);
387388
}
388389

389390
} // namespace ur_robot_driver

ur_robot_driver/test/integration_test_trajectory_until.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import sys
3232
import time
3333
import unittest
34-
import logging
3534

3635
import pytest
3736

@@ -41,7 +40,6 @@
4140

4241
from controller_manager_msgs.srv import SwitchController
4342
from ur_msgs.action import TrajectoryUntil
44-
from action_msgs.msg import GoalStatus
4543
from action_msgs.srv import CancelGoal_Response
4644
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint
4745
from builtin_interfaces.msg import Duration
@@ -64,7 +62,9 @@
6462
[("", "scaled_joint_trajectory_controller"), ("my_ur_", "passthrough_trajectory_controller")],
6563
)
6664
def generate_test_description(tf_prefix, initial_joint_controller):
67-
return generate_driver_test_description(tf_prefix=tf_prefix, initial_joint_controller=initial_joint_controller)
65+
return generate_driver_test_description(
66+
tf_prefix=tf_prefix, initial_joint_controller=initial_joint_controller
67+
)
6868

6969

7070
class RobotDriverTest(unittest.TestCase):
@@ -119,7 +119,9 @@ def test_trajectory_with_tool_contact_no_trigger_succeeds(self, tf_prefix):
119119
)
120120
for i in range(len(self.test_traj["waypts"]))
121121
]
122-
goal_handle = self._trajectory_until_interface.send_goal(trajectory=trajectory, until_type=TrajectoryUntil.Goal.TOOL_CONTACT)
122+
goal_handle = self._trajectory_until_interface.send_goal(
123+
trajectory=trajectory, until_type=TrajectoryUntil.Goal.TOOL_CONTACT
124+
)
123125
self.assertTrue(goal_handle.accepted)
124126
if goal_handle.accepted:
125127
result = self._trajectory_until_interface.get_result(
@@ -133,7 +135,7 @@ def test_trajectory_with_tool_contact_no_trigger_succeeds(self, tf_prefix):
133135
deactivate_controllers=["tool_contact_controller"],
134136
).ok
135137
)
136-
138+
137139
def test_trajectory_until_can_cancel(self, tf_prefix):
138140
self.assertTrue(
139141
self._controller_manager_interface.switch_controller(
@@ -150,7 +152,9 @@ def test_trajectory_until_can_cancel(self, tf_prefix):
150152
)
151153
for i in range(len(self.test_traj["waypts"]))
152154
]
153-
goal_handle = self._trajectory_until_interface.send_goal(trajectory=trajectory, until_type=TrajectoryUntil.Goal.TOOL_CONTACT)
155+
goal_handle = self._trajectory_until_interface.send_goal(
156+
trajectory=trajectory, until_type=TrajectoryUntil.Goal.TOOL_CONTACT
157+
)
154158
self.assertTrue(goal_handle.accepted)
155159
time.sleep(2)
156160
result = self._trajectory_until_interface.cancel_goal(goal_handle)
@@ -162,4 +166,3 @@ def test_trajectory_until_can_cancel(self, tf_prefix):
162166
deactivate_controllers=["tool_contact_controller"],
163167
).ok
164168
)
165-

0 commit comments

Comments
 (0)