Refactor edge action handling: use edge.action metadata instead of node-name inference #222
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Navigation actions were being inferred from node naming conventions (e.g.,
"ca"→ goal_align,"WayPoint"→ outside edge) rather than the explicitedge.actionfield already defined in topological map metadata. This was fragile, map-specific, and semantically incorrect.Changes
Core Refactor
get_goal_align_if()- Now returnsedge.actiondirectly as source of truth instead of parsing node name tokens from edge IDsget_navigation_area_from_edges()- New method using edge action metadata for area detection (row_traversal → inside polytunnel, goal_align → transition)Backward Compatibility
GOAL_ALIGN_INDEX,ROW_START_INDEX, etc.) documented with TODOsPerformance Instrumentation
[TIMING]logs to identify behavior-switch latency sources (preempt, goal cancellation, server wait)Tests
Before/After
Remaining Legacy Patterns
Agricultural-specific row operation handling (
handle_row_operation, robot harvesting status detection) still uses node-name patterns. These require domain metadata additions to topological maps and are documented for future refactoring.Original prompt
This section details on the original issue you should resolve
<issue_title>[ISSUE]: Refactor edge action handling: stop inferring actions from node names and use topological map edge metadata</issue_title>
<issue_description>### Description
Problem Statement
The current navigation/action logic infers behaviours and actions from node naming conventions, which is fragile and incorrect.
Actions such as goal alignment, row traversal, row operation, etc., are currently derived purely from string patterns in node names (e.g.
"ca","cb","WayPoint"), rather than from the explicit action definitions already present on topological map edges.This affects logic spread across the following files and needs coordinated refactoring:
edge_action_manager2.pyactions_bt.pylocalisation2.pynavigation2.pyCurrent Implementation (Issue)
In
actions_bt.py, actions are hard-coded and inferred from node name tokens:This leads to logic such as:
"ca"→ triggergoal_align"WayPoint"→ treat as outside edgeThis approach is:
Expected / Correct Behaviour
Actions must be derived from the topological map edges, not inferred from node names.
The topological map already defines explicit action metadata on each edge.
This metadata must be treated as the single source of truth.
Example (existing, correct data already available):
From this:
row_traversal)are all already explicitly defined.
The system should:
edge.actionRequired Refactor
1. Action Source of Truth
Replace all node-name-based action inference with edge metadata parsing
edge.actionmust determine:2. File-level Expectations
edge_action_manager2.pyaction,action_type, and config cleanlyactions_bt.pyRemove all logic tied to:
"ca","cb","WayPoint", index letters, etc.Map BT actions directly from
edge.actionnavigation2.pylocalisation2.pyAdditional Investigation Required
There is a noticeable long pause / wait when:
This needs investigation:
Is the delay caused by:
Identify where the blocking occurs and reduce or eliminate unnecessary waits
Acceptance Criteria
edge.actionMotivation
This change is critical to:
Notes for Copilot / PR Implementation
</issue_description>
<agent_instructions>Refactor edge action handling so behaviours are...
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.