Skip to content

Commit f70970d

Browse files
committed
cancels for streams should carry the final primitive count as well
1 parent 4413110 commit f70970d

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

include/ur_client_library/control/reverse_interface.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ class ReverseInterface
129129
* \param trajectory_action One of the values of TrajectoryControlMessage. The value selects which
130130
* trajectory-control action the URScript dispatcher takes, and dictates how \p point_number is
131131
* interpreted:
132-
* - TRAJECTORY_CANCEL (-1): Cancels the currently executing trajectory. \p point_number is unused.
132+
* - TRAJECTORY_CANCEL (-1): Cancels the currently executing trajectory. If the trajectory was started
133+
* with TRAJECTORY_START then \p point_number is unused. For streaming trajectories, \p point_number
134+
* must equal the total number of motion primitives the producer wrote on the trajectory socket
135+
* since TRAJECTORY_STREAM_START.
133136
* - TRAJECTORY_NOOP (0): No-op; serves as a keepalive on the reverse socket while a trajectory
134137
* executes. The producer must send these (or another trajectory-control message) periodically
135138
* while waiting for trajectory completion so that the URScript dispatcher's read does not

resources/external_control.urscript

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,11 @@ while control_mode > MODE_STOPPED:
12011201
wait_for_trajectory_cleanup()
12021202
# The streaming session, if any, has been forcibly ended; clear
12031203
# the flag so a subsequent stray STREAM_END is a no-op.
1204-
trajectory_streaming = False
1204+
if trajectory_streaming:
1205+
# In streaming mode, a cancel should come with the total count, just like a STREAM_END.
1206+
trajectory_points_left = params_mult[3] - (STREAMING_SENTINEL - trajectory_points_left)
1207+
trajectory_streaming = False
1208+
end
12051209
socket_send_int(TRAJECTORY_RESULT_CANCELED, "trajectory_socket")
12061210
end
12071211
elif control_mode == MODE_SPEEDL:

tests/test_trajectory_streaming.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ TEST_F(TrajectoryStreamingTest, stream_cancel_yields_canceled)
227227
std::this_thread::sleep_for(std::chrono::milliseconds(50));
228228

229229
ASSERT_TRUE(g_my_robot->getUrDriver()->writeTrajectoryControlMessage(
230-
control::TrajectoryControlMessage::TRAJECTORY_CANCEL));
230+
control::TrajectoryControlMessage::TRAJECTORY_CANCEL, 100));
231231

232232
EXPECT_EQ(control::TrajectoryResult::TRAJECTORY_RESULT_CANCELED,
233233
waitForTrajectoryResultPumpingNoops(std::chrono::seconds(5)));

0 commit comments

Comments
 (0)