Skip to content

Commit f66c885

Browse files
authored
Merge branch 'main' into update_control_toolbox_api
2 parents 76c2d02 + 71b8ad4 commit f66c885

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed

.github/workflows/coverage-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
required-ros-distributions: ${{ env.ROS_DISTRO }}
2222
use-ros2-testing: true
2323
- uses: actions/checkout@v4
24-
- uses: ros-tooling/action-ros-ci@v0.3
24+
- uses: ros-tooling/action-ros-ci@v0.4
2525
with:
2626
target-ros2-distro: ${{ env.ROS_DISTRO }}
2727
# build all packages listed in the meta package

Universal_Robots_ROS2_Driver.jazzy.repos

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repositories:
3434
realtime_tools:
3535
type: git
3636
url: https://github.com/ros-controls/realtime_tools.git
37-
version: master
37+
version: jazzy
3838
moveit2:
3939
type: git
4040
url: https://github.com/ros-planning/moveit2.git

ur_controllers/src/scaled_joint_trajectory_controller.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
128128
const auto active_goal = *rt_active_goal_.readFromRT();
129129

130130
// Check if a new external message has been received from nonRT threads
131-
auto current_external_msg = traj_external_point_ptr_->get_trajectory_msg();
132-
auto new_external_msg = traj_msg_external_point_ptr_.readFromRT();
131+
auto current_external_msg = current_trajectory_->get_trajectory_msg();
132+
auto new_external_msg = new_trajectory_msg_.readFromRT();
133133
// Discard, if a goal is pending but still not active (somewhere stuck in goal_handle_timer_)
134134
if (current_external_msg != *new_external_msg && (*(rt_has_pending_goal_.readFromRT()) && !active_goal) == false) {
135135
fill_partial_goal(*new_external_msg);
136136
sort_to_local_joint_order(*new_external_msg);
137137
// TODO(denis): Add here integration of position and velocity
138-
traj_external_point_ptr_->update(*new_external_msg);
138+
current_trajectory_->update(*new_external_msg);
139139
}
140140

141141
// TODO(anyone): can I here also use const on joint_interface since the reference_wrapper is not
@@ -166,22 +166,22 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
166166

167167
bool first_sample = false;
168168
// if sampling the first time, set the point before you sample
169-
if (!traj_external_point_ptr_->is_sampled_already()) {
169+
if (!current_trajectory_->is_sampled_already()) {
170170
first_sample = true;
171171
if (params_.open_loop_control) {
172-
traj_external_point_ptr_->set_point_before_trajectory_msg(traj_time, last_commanded_state_);
172+
current_trajectory_->set_point_before_trajectory_msg(traj_time, last_commanded_state_);
173173
} else {
174-
traj_external_point_ptr_->set_point_before_trajectory_msg(traj_time, state_current_);
174+
current_trajectory_->set_point_before_trajectory_msg(traj_time, state_current_);
175175
}
176176
}
177177

178178
// find segment for current timestamp
179179
joint_trajectory_controller::TrajectoryPointConstIter start_segment_itr, end_segment_itr;
180-
const bool valid_point = traj_external_point_ptr_->sample(traj_time, interpolation_method_, state_desired_,
181-
start_segment_itr, end_segment_itr);
180+
const bool valid_point = current_trajectory_->sample(traj_time, interpolation_method_, state_desired_,
181+
start_segment_itr, end_segment_itr);
182182

183183
if (valid_point) {
184-
const rclcpp::Time traj_start = traj_external_point_ptr_->time_from_start();
184+
const rclcpp::Time traj_start = current_trajectory_->time_from_start();
185185
// this is the time instance
186186
// - started with the first segment: when the first point will be reached (in the future)
187187
// - later: when the point of the current segment was reached
@@ -193,16 +193,16 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
193193
bool tolerance_violated_while_moving = false;
194194
bool outside_goal_tolerance = false;
195195
bool within_goal_time = true;
196-
const bool before_last_point = end_segment_itr != traj_external_point_ptr_->end();
196+
const bool before_last_point = end_segment_itr != current_trajectory_->end();
197197

198198
// have we reached the end, are not holding position, and is a timeout configured?
199199
// Check independently of other tolerances
200200
if (!before_last_point && *(rt_is_holding_.readFromRT()) == false && cmd_timeout_ > 0.0 &&
201201
time_difference > cmd_timeout_) {
202202
RCLCPP_WARN(get_node()->get_logger(), "Aborted due to command timeout");
203203

204-
traj_msg_external_point_ptr_.reset();
205-
traj_msg_external_point_ptr_.initRT(set_hold_position());
204+
new_trajectory_msg_.reset();
205+
new_trajectory_msg_.initRT(set_hold_position());
206206
}
207207

208208
// Check state/goal tolerance
@@ -291,8 +291,8 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
291291

292292
RCLCPP_WARN(get_node()->get_logger(), "Aborted due to state tolerance violation");
293293

294-
traj_msg_external_point_ptr_.reset();
295-
traj_msg_external_point_ptr_.initRT(set_hold_position());
294+
new_trajectory_msg_.reset();
295+
new_trajectory_msg_.initRT(set_hold_position());
296296
} else if (!before_last_point) { // check goal tolerance
297297
if (!outside_goal_tolerance) {
298298
auto res = std::make_shared<FollowJTrajAction::Result>();
@@ -305,8 +305,8 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
305305

306306
RCLCPP_INFO(get_node()->get_logger(), "Goal reached, success!");
307307

308-
traj_msg_external_point_ptr_.reset();
309-
traj_msg_external_point_ptr_.initRT(set_hold_position());
308+
new_trajectory_msg_.reset();
309+
new_trajectory_msg_.initRT(set_hold_position());
310310
} else if (!within_goal_time) {
311311
auto result = std::make_shared<FollowJTrajAction::Result>();
312312
result->set__error_code(FollowJTrajAction::Result::GOAL_TOLERANCE_VIOLATED);
@@ -319,21 +319,21 @@ controller_interface::return_type ScaledJointTrajectoryController::update(const
319319
RCLCPP_WARN(get_node()->get_logger(), "Aborted due goal_time_tolerance exceeding by %f seconds",
320320
time_difference);
321321

322-
traj_msg_external_point_ptr_.reset();
323-
traj_msg_external_point_ptr_.initRT(set_hold_position());
322+
new_trajectory_msg_.reset();
323+
new_trajectory_msg_.initRT(set_hold_position());
324324
}
325325
}
326326
} else if (tolerance_violated_while_moving && *(rt_has_pending_goal_.readFromRT()) == false) {
327327
// we need to ensure that there is no pending goal -> we get a race condition otherwise
328328
RCLCPP_ERROR(get_node()->get_logger(), "Holding position due to state tolerance violation");
329329

330-
traj_msg_external_point_ptr_.reset();
331-
traj_msg_external_point_ptr_.initRT(set_hold_position());
330+
new_trajectory_msg_.reset();
331+
new_trajectory_msg_.initRT(set_hold_position());
332332
} else if (!before_last_point && !within_goal_time && *(rt_has_pending_goal_.readFromRT()) == false) {
333333
RCLCPP_ERROR(get_node()->get_logger(), "Exceeded goal_time_tolerance: holding position...");
334334

335-
traj_msg_external_point_ptr_.reset();
336-
traj_msg_external_point_ptr_.initRT(set_hold_position());
335+
new_trajectory_msg_.reset();
336+
new_trajectory_msg_.initRT(set_hold_position());
337337
}
338338
// else, run another cycle while waiting for outside_goal_tolerance
339339
// to be satisfied (will stay in this state until new message arrives)

ur_robot_driver/include/ur_robot_driver/hardware_interface.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class URPositionHardwareInterface : public hardware_interface::SystemInterface
124124
hardware_interface::CallbackReturn on_configure(const rclcpp_lifecycle::State& previous_state) final;
125125
hardware_interface::CallbackReturn on_activate(const rclcpp_lifecycle::State& previous_state) final;
126126
hardware_interface::CallbackReturn on_cleanup(const rclcpp_lifecycle::State& previous_state) final;
127+
hardware_interface::CallbackReturn on_shutdown(const rclcpp_lifecycle::State& previous_state) final;
127128

128129
hardware_interface::return_type read(const rclcpp::Time& time, const rclcpp::Duration& period) final;
129130
hardware_interface::return_type write(const rclcpp::Time& time, const rclcpp::Duration& period) final;
@@ -154,6 +155,9 @@ class URPositionHardwareInterface : public hardware_interface::SystemInterface
154155
void readBitsetData(const std::unique_ptr<urcl::rtde_interface::DataPackage>& data_pkg, const std::string& var_name,
155156
std::bitset<N>& data);
156157

158+
// stop function used by on_shutdown and on_cleanup
159+
hardware_interface::CallbackReturn stop();
160+
157161
void initAsyncIO();
158162
void checkAsyncIO();
159163
void updateNonDoubleValues();

ur_robot_driver/src/hardware_interface.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ namespace ur_robot_driver
5858

5959
URPositionHardwareInterface::~URPositionHardwareInterface()
6060
{
61-
// If the controller manager is shutdown via Ctrl + C the on_deactivate methods won't be called.
62-
// We therefore need to make sure to actually deactivate the communication
63-
on_cleanup(rclcpp_lifecycle::State());
6461
}
6562

6663
hardware_interface::CallbackReturn
@@ -592,6 +589,19 @@ URPositionHardwareInterface::on_activate(const rclcpp_lifecycle::State& previous
592589

593590
hardware_interface::CallbackReturn
594591
URPositionHardwareInterface::on_cleanup(const rclcpp_lifecycle::State& previous_state)
592+
{
593+
RCLCPP_DEBUG(rclcpp::get_logger("URPositionHardwareInterface"), "on_cleanup");
594+
return stop();
595+
}
596+
597+
hardware_interface::CallbackReturn
598+
URPositionHardwareInterface::on_shutdown(const rclcpp_lifecycle::State& previous_state)
599+
{
600+
RCLCPP_DEBUG(rclcpp::get_logger("URPositionHardwareInterface"), "on_shutdown");
601+
return stop();
602+
}
603+
604+
hardware_interface::CallbackReturn URPositionHardwareInterface::stop()
595605
{
596606
RCLCPP_INFO(rclcpp::get_logger("URPositionHardwareInterface"), "Stopping ...please wait...");
597607

0 commit comments

Comments
 (0)