Skip to content

fix(protective_stop_node): stop if any paired remote is pressed or lost - #211

Draft
iliabaranov wants to merge 1 commit into
mainfrom
iliabaranov/pstop-combine-remotes
Draft

iliabaranov wants to merge 1 commit into
mainfrom
iliabaranov/pstop-combine-remotes

Conversation

@iliabaranov

Copy link
Copy Markdown
Contributor

Fixes #210.

Why

With two paired remotes (for example the operator's Polyglot P-stop panel and a safety person's), only the remote
paired last could stop the robot:

  • process_heartbeat() overwrote stop with each remote's state in turn, so a press on any other remote was ignored,
    and so was another remote missing its heartbeat.
  • When max_pstop_count was reached, activation deleted the oldest remote even while it was active. Its presses were
    then ignored as coming from an unknown source. Polyglot makes a new uuid every session, so this happens after a few
    page reloads. The pruning also ran before the "Already activated" check, so a repeated activation could drop a
    different remote.

This node ships in polymath_core v14.0 as pstop-legacy, the service Polyglot's P-stop panel pairs with.

What changed

  • process_heartbeat(): the heartbeat's stop is the OR over every non-deactivated remote. Any pressed remote, or
    any remote that missed its heartbeat, stops the robot. With no remotes, the behaviour is unchanged (stop when user
    monitored, run when not).
  • Activation: the "Already activated" check runs first. When the list is full, only deactivated remotes are pruned,
    oldest first. A remote re-activating reuses its own entry. If every entry is active or unstable, activation is
    refused with Max pstop count of N reached and every remote is active. Retry once a remote is deactivated.
    Polyglot shows a refused activation as a connection error.
  • max_pstop_count description documents this.

Behaviour that stays the same: a remote silent longer than deactivation_timeout is deactivated and no longer counts.

Tests

  • New test/multiple_remotes.test.py (own ROS_DOMAIN_ID 79), two paired remotes:
    • both released: every heartbeat is stop: false;
    • A pressed, B released, then the other way round: every heartbeat is stop: true;
    • A silent, B released, then the other way round: every heartbeat is stop: true;
    • full list: a fourth activation is refused, a repeated activation is refused without pruning, all three remotes stay
      registered and the oldest still stops the robot; after one is deactivated, a new remote takes its slot and the
      active ones stay.
  • test_max_connections now checks the refusal and the pruning of deactivated remotes (it used to deactivate random
    uuids that were never activated). test_err_for_multiple_activations deactivates its remote, because a silent
    active remote now holds the stop and a slot for deactivation_timeout.

Run in the polymath_core v14.0 image (toborlife_ai:jazzy-a13dbf62) with --network none:
colcon build/test --packages-select protective_stop_node.

  • Before the fix: 4 of the new or changed tests fail (pressed, silent, full list, test_max_connections); "both
    released" passes.
  • After the fix: 20 tests, 0 failures, three runs in a row.

The new tests space out each remote's messages within a heartbeat period, because the node's /protective_stop
subscription has queue depth 1 and drops a message that arrives right behind another.

process_heartbeat overwrote the stop flag with each active remote's state, so
with two paired remotes only the last one in the registry decided: a press on
the other was ignored, and a missed heartbeat on the other was overwritten by
the last remote's released state. The stop is now the OR over every
non-deactivated remote.

When the registry was full, activation pruned the oldest remote even if it was
still active, which silently dropped its stop (its later messages were ignored
as coming from an unknown source). It also pruned before rejecting a repeated
activation from an already active remote. Now only deactivated remotes are
pruned, and activation is refused while every registered remote is active.

Adds multiple_remotes.test.py (any pressed remote stops, any silent remote
stops, both released runs, full registry) and updates test_max_connections.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy protective stop node: with two paired remotes, only one of them can stop the robot

1 participant