Add If Step Support for Conditional Mission Execution: Part 1#18
Merged
miguelgarcia merged 6 commits intomainfrom Dec 2, 2025
Merged
Add If Step Support for Conditional Mission Execution: Part 1#18miguelgarcia merged 6 commits intomainfrom
miguelgarcia merged 6 commits intomainfrom
Conversation
Member
Author
|
@b-Tomas can you review ? Thanks a lot. Feel free to check our internal board for reference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR introduces support for conditional execution in missions through the new
ifstep type. This PR is only the data types extension. The behavior will be implemented in subsequent PRs.Changes
Data Model (
inorbit_edge_executor/datatypes.py)Added
MissionStepIfclass: A new mission step type that supports conditional execution based on expression evaluationMissionStepbase classaccept()methodtargetfield for evaluating expressions on different robotsAdded
IfArgsnested class: Contains the conditional logic configurationexpression: str- The expression to evaluate (e.g.,"getValue('battery') > 50")target: Target(optional) - Target robot for expression evaluationthen: StepsList- Steps to execute when expression is true (aliased as"if"in JSON)else_: Optional[StepsList]- Steps to execute when expression is false (aliased as"else"in JSON, optional)Updated
MissionStepTypesenum: AddedIF = "if"step typeUpdated
MissionDefinition.steps: Extended the Union type to includeMissionStepIfvia a newStepsListtype aliasJSON Structure
The if step follows this structure:
{ "if": { "expression": "getValue('battery') > 50", "then": [ {"data": {"key": "value"}}, {"timeoutSecs": 10} ], "else": [ {"data": {"key": "else_value"}} ] }, "label": "Check battery level", "timeoutSecs": 30 }Testing (
tests/test_if_step.py)Added comprehensive unit tests covering:
MissionDefinitionImplementation Status
This PR implements Ticket 1 from the implementation plan (
IF_ELSE_IMPLEMENTATION_PLAN.md):Breaking Changes
None. This is a purely additive change.
Note
Introduce
MissionStepIfwiththen/elsebranches in datatypes and add corresponding unit tests; addvisit_ifstub in behavior tree.MissionStepIfwithexpression, optionaltarget,then(StepsList), and optionalelse_.MissionStepTypeswithIFand introduceStepsListtype alias.MissionDefinition.stepsto useStepsList.MissionStepIfand addNodeFromStepBuilder.visit_ifstub raisingNotImplementedError.tests/test_if_step.pycovering basic/else/target/nested cases, label/timeout, visitor acceptance, integration withMissionDefinition, multiple-steps branches, and validation.Written by Cursor Bugbot for commit 556d842. This will update automatically on new commits. Configure here.