Skip to content

Commit 858530a

Browse files
committed
comment improvements
1 parent 96cc74b commit 858530a

3 files changed

Lines changed: 68 additions & 22 deletions

File tree

examples/trajectory_streaming.cpp

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,32 @@
5353
//
5454
// Caller contract:
5555
//
56-
// 1. Do not starve the controller. Once trajectory execution begins, the
57-
// URScript-side reader times out reads after one step time (~8 ms once
58-
// moving). A timeout while streaming is treated as a producer fault and
59-
// yields TRAJECTORY_RESULT_FAILURE via the trajectory-done callback.
60-
// The producer must keep at least one point in flight on the trajectory
61-
// socket at all times until STREAM_END has been sent.
56+
// 1. The next point must be in the OS socket buffer before the
57+
// currently-executing point's spline finishes. The URScript reader
58+
// only attempts a socket read after finishing each spline segment;
59+
// the read uses a short timeout (~8 ms on PolyScope 5, ~2 ms on
60+
// PolyScope X), and if no point is available within that window
61+
// the trajectory ends with TRAJECTORY_RESULT_FAILURE.
62+
//
63+
// The implication: the time you have between consecutive writes is
64+
// essentially the in-progress point's tmptime. Dense trajectories
65+
// (8 ms per point) demand 8 ms-paced production. Sparse trajectories
66+
// (1 s per point) give you 1 s. A single point with tmptime = 60 s
67+
// gives you a full minute to produce the next one.
68+
//
69+
// The simplest correct producer pattern is "write as fast as you
70+
// can": call writeTrajectorySplinePoint in a tight loop. The OS
71+
// send/receive buffer absorbs ~760 spline points; TCP backpressure
72+
// naturally throttles the producer when the buffer fills, blocking
73+
// writeTrajectorySplinePoint until the consumer has drained enough
74+
// to make room. No manual pacing is required. Starvation only
75+
// arises if the producer's average production rate falls below the
76+
// consumer's average consumption rate over a window longer than
77+
// what the OS buffer can absorb.
6278
//
6379
// 2. Send STREAM_END while at least one streamed point is still
64-
// unconsumed. This is implied by rule 1 but worth stating: if the
65-
// producer pauses long enough after the last spline point that the
66-
// consumer drains the buffer before STREAM_END arrives, rule 1 will
67-
// have already failed.
80+
// unconsumed. This is implied by rule 1: if the consumer drained the
81+
// buffer before STREAM_END arrived, rule 1 already failed.
6882
//
6983
// 3. Make the last streamed point a controlled-stop terminal:
7084
// qd = (0, ..., 0), qdd = (0, ..., 0). URScript's spline runner applies

include/ur_client_library/control/reverse_interface.h

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,37 @@ class ReverseInterface
124124
const RobotReceiveTimeout& robot_receive_timeout = RobotReceiveTimeout::millisec(20));
125125

126126
/*!
127-
* \brief Writes needed information to the robot to be read by the URScript program.
127+
* \brief Sends a trajectory-control message to the URScript program over the reverse socket.
128128
*
129-
* \param trajectory_action 1 if a trajectory is to be started, -1 if it should be stopped
130-
* \param point_number The number of points of the trajectory to be executed
131-
* \param robot_receive_timeout The read timeout configuration for the reverse socket running in the external
132-
* control script on the robot. If you want to make the read function blocking then use RobotReceiveTimeout::off()
133-
* function to create the RobotReceiveTimeout object
129+
* \param trajectory_action One of the values of TrajectoryControlMessage. The value selects which
130+
* trajectory-control action the URScript dispatcher takes, and dictates how \p point_number is
131+
* interpreted:
132+
* - TRAJECTORY_CANCEL (-1): Cancels the currently executing trajectory. \p point_number is unused.
133+
* - TRAJECTORY_NOOP (0): No-op; serves as a keepalive on the reverse socket while a trajectory
134+
* executes. The producer must send these (or another trajectory-control message) periodically
135+
* while waiting for trajectory completion so that the URScript dispatcher's read does not
136+
* time out and exit the external_control program. \p point_number is unused.
137+
* - TRAJECTORY_START (1): Begins a finite trajectory of declared length. \p point_number is the
138+
* total number of subsequent writeTrajectoryPoint / writeTrajectorySplinePoint / writeMotionPrimitive
139+
* calls the producer will issue on the trajectory socket. URScript reads exactly that many points
140+
* and then completes.
141+
* - TRAJECTORY_STREAM_START (2): Begins an open-ended (streaming) trajectory. The producer streams
142+
* spline points and signals end-of-stream with TRAJECTORY_STREAM_END. \p point_number is unused.
143+
* - TRAJECTORY_STREAM_END (3): Ends an open-ended streaming trajectory started by
144+
* TRAJECTORY_STREAM_START. \p point_number must equal the total number of spline points the
145+
* producer wrote on the trajectory socket since TRAJECTORY_STREAM_START.
134146
*
135-
* \returns True, if the write was performed successfully, false otherwise.
147+
* \param point_number Mode-dependent point-count argument. See the description of \p
148+
* trajectory_action for the per-mode semantics.
149+
*
150+
* \param robot_receive_timeout The read timeout configuration for the reverse socket running in the
151+
* external control script on the robot. If you want to make the read function blocking then use
152+
* RobotReceiveTimeout::off() function to create the RobotReceiveTimeout object.
153+
*
154+
* \returns True if the write was performed successfully, false otherwise.
155+
*
156+
* \see examples/trajectory_point_interface.cpp for a finite-trajectory usage example, or
157+
* examples/trajectory_streaming.cpp for an open-ended streaming trajectory example.
136158
*/
137159
bool
138160
writeTrajectoryControlMessage(const TrajectoryControlMessage trajectory_action, const int point_number = 0,

include/ur_client_library/ur/ur_driver.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,23 @@ class UrDriver
585585
/*!
586586
* \brief Writes a control message in trajectory forward mode.
587587
*
588-
* \param trajectory_action The action to be taken, such as starting a new trajectory
589-
* \param point_number The number of points of a new trajectory to be sent
590-
* \param robot_receive_timeout The read timeout configuration for the reverse socket running in the external
591-
* control script on the robot. If you want to make the read function blocking then use RobotReceiveTimeout::off()
592-
* function to create the RobotReceiveTimeout object
588+
* Selects which trajectory-control action the URScript dispatcher takes (start a finite
589+
* trajectory, begin or end an open-ended streaming trajectory, cancel, or no-op keepalive)
590+
* and, where applicable, communicates a point count. See
591+
* control::ReverseInterface::writeTrajectoryControlMessage for the per-mode semantics of
592+
* \p trajectory_action and \p point_number.
593+
*
594+
* \param trajectory_action The trajectory-control action to take.
595+
* \param point_number Mode-dependent point-count argument; see the underlying interface.
596+
* \param robot_receive_timeout The read timeout configuration for the reverse socket running in
597+
* the external control script on the robot. If you want to make the read function blocking
598+
* then use RobotReceiveTimeout::off() function to create the RobotReceiveTimeout object.
593599
*
594600
* \returns True on successful write.
601+
*
602+
* \see control::ReverseInterface::writeTrajectoryControlMessage
603+
* \see examples/trajectory_point_interface.cpp (finite trajectory)
604+
* \see examples/trajectory_streaming.cpp (open-ended streaming trajectory)
595605
*/
596606
bool
597607
writeTrajectoryControlMessage(const control::TrajectoryControlMessage trajectory_action, const int point_number = 0,

0 commit comments

Comments
 (0)