Skip to content

Clean recovery from starving the arm during streaming is currently not possible #550

Description

@acmorrow

Affected Client Library version(s)

2.14.0 2.14.1

What combination of platform is the Client Library running on.

Mac

How did you install the Client Library

Build the library from source

Which robot platform is the library connected to.

URSim in docker

Robot SW / URSim version(s)

master

How are you using the Client Library

Headless without using the teach pendant

Issue details

Summary

With external_control.urscript, If a streaming client fails to meet its obligation to keep the arm fed with points and allows the arm to "run off the end of the stream", the script is left in a state that makes safe recovery impossible. There is not a clear workaround at this time.

Issue details

The contract for streaming is that the client will end the stream with a point count, so that external_control.urscript knows how many more points to read off the socket. That works well, both for normal stream termination and for client-initiated cancellation. However, if the client fails to meet its obligation to keep the arm fed with points, the trajectory will report failure. But without a terminal message from the client containing the total point count, the external_control.urscript script can't know how many points may be sitting in the buffer that it should drain. Nor can it guess, or rely on a timeout, since the client may already be sending points for some future trajectory.

Steps to Reproduce

Run the arm off the end of a trajectory. I have written a number of unit tests which I can share on a branch that make the problem clear.

Expected Behavior

After a trajectory failure, the script should be able to safely drain any points already in the socket buffer.

Actual Behavior

The points remain in the buffer, and dangerously become part of the next trajectory.

Workaround Suggestion

I do not currently have a workaround suggestion. The most obvious approach would be to ask streaming clients to follow up a trajectory failure with an explicit STREAM_END or CANCEL containing a total point count. But that has some problems, in that it is likely to trigger a second "completion" on the same trajectory: confusing for both the script and the client. That could probably be suppressed in the external_control.urscript logic, but now things are starting to get a little messy. Another possibility would be to require streaming clients to attach an ID to each streamed trajectory point, which would allow the arm side script to drain points with matching ids, but this is imperfect as once you have read the first non-matching point you've already done the wrong thing. Another option would be to introduce a requirement on clients that when they get failure during a stream, they must drop and reconnect, but that's harsh and graceless.

Basically, I'd like to use this issue to talk through the issues. I have some unit tests that demonstrate the problem, please let me know if you would like me to publish them to a branch.

Finally, while investigating this issue, it looks like there may be some concurrency issues related to the trajectory point count between the trajectory thread and the main thread, which should probably be resolved at the same time. I can share more details on that, or we can wait until we have an agreed path forward on recovery from failure and then investigate the concurrency issue.

Relevant log output

Accept Public visibility

  • I agree to make this context public

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions