5454from intrinsic .solutions import provided
5555from intrinsic .solutions import simulation as simulation_mod
5656from intrinsic .solutions import utils
57+ from intrinsic .solutions import worlds # pylint: disable=line-too-long
5758from intrinsic .solutions .internal import actions
5859from intrinsic .solutions .internal import blackboard as blackboard_internal
5960from intrinsic .util .grpc import error_handling
@@ -691,6 +692,9 @@ def run_async(
691692 simulation_mode : Optional ["Executive.SimulationMode" ] = None ,
692693 embed_skill_traces : bool = False ,
693694
695+ start_from_world_state : worlds .EditWorldId | None = None ,
696+
697+
694698 keep_blackboard : bool = False ,
695699
696700 ):
@@ -727,6 +731,21 @@ def run_async(
727731 to these nodes and run from there. Only one of recover_from_nodes or
728732 start_node can be set.
729733
734+
735+ start_from_world_state: Optional parameter to specify what starting world
736+ state to run the operation from. If an EditWorldId is set, the execute
737+ belief world and simulation world will be reset to the specified world
738+ before running the operation. Otherwise, the operation will be run in
739+ the current world state as-is.
740+
741+ Specifying `worlds.EditWorldId.INITIAL` resets the world state to the
742+ state of the Initial editing world before running the operation.
743+
744+ Specifying `worlds.EditWorldId.BELIEF` keeps the execute belief world in
745+ its current state, but the simulation world state is first reset to
746+ match the execute world.
747+
748+
730749 Raises:
731750 solutions_errors.UnavailableError: On executive service not reachable.
732751 grpc.RpcError: On any other gRPC error.
@@ -744,6 +763,7 @@ def run_async(
744763
745764 simulation_mode = simulation_mode ,
746765 embed_skill_traces = embed_skill_traces ,
766+ start_from_world_state = start_from_world_state , # pylint: disable=line-too-long
747767
748768 keep_blackboard = keep_blackboard ,
749769
@@ -765,6 +785,9 @@ def run(
765785 simulation_mode : Optional ["Executive.SimulationMode" ] = None ,
766786 embed_skill_traces : bool = False ,
767787
788+ start_from_world_state : worlds .EditWorldId | None = None ,
789+
790+
768791 keep_blackboard : bool = False ,
769792
770793 ):
@@ -804,6 +827,21 @@ def run(
804827 to these nodes and run from there. Only one of recover_from_nodes or
805828 start_node can be set.
806829
830+
831+ start_from_world_state: Optional parameter to specify what starting world
832+ state to run the operation from. If an EditWorldId is set, the execute
833+ belief world and simulation world will be reset to the specified world
834+ before running the operation. Otherwise, the operation will be run in
835+ the current world state as-is.
836+
837+ Specifying `worlds.EditWorldId.INITIAL` resets the world state to the
838+ state of the Initial editing world before running the operation.
839+
840+ Specifying `worlds.EditWorldId.BELIEF` keeps the execute belief world in
841+ its current state, but the simulation world state is first reset to
842+ match the execute world.
843+
844+
807845 Raises:
808846 ExecutionFailedError: On unexpected state of the executive during plan
809847 execution.
@@ -827,6 +865,7 @@ def run(
827865
828866 simulation_mode = simulation_mode ,
829867 embed_skill_traces = embed_skill_traces ,
868+ start_from_world_state = start_from_world_state , # pylint: disable=line-too-long
830869
831870 keep_blackboard = keep_blackboard ,
832871
@@ -869,6 +908,7 @@ def _run(
869908
870909 recover_from_nodes : list [bt .NodeInTreeType ] | None ,
871910
911+ start_from_world_state : worlds .EditWorldId | None , # pylint: disable=line-too-long
872912
873913 keep_blackboard : bool = False ,
874914
@@ -903,14 +943,29 @@ def _run(
903943 to these nodes and run from there. Only one of recover_from_nodes or
904944 start_node can be set.
905945
946+
947+ start_from_world_state: Optional parameter to specify what starting world
948+ state to run the operation from. If an EditWorldId is set, the execute
949+ belief world and simulation world will be reset to the specified world
950+ before running the operation. Otherwise, the operation will be run in
951+ the current world state as-is.
952+
953+ Specifying `worlds.EditWorldId.INITIAL` resets the world state to the
954+ state of the Initial editing world before running the operation.
955+
956+ Specifying `worlds.EditWorldId.BELIEF` keeps the execute belief world in
957+ its current state, but the simulation world state is first reset to
958+ match the execute world.
959+
960+
906961 Raises:
907962 ExecutionFailedError: On unexpected state of the executive during plan
908963 execution.
909964 solutions_errors.UnavailableError: On executive service not reachable.
910965 grpc.RpcError: On any other gRPC error.
911966 OperationNotFoundError: if no operation is currently active.
912967 """
913- self . _reset_simulation_if_needed ( silence_outputs )
968+
914969
915970
916971 if recover_from_nodes and start_node is not None :
@@ -950,6 +1005,7 @@ def _run(
9501005 embed_skill_traces = embed_skill_traces ,
9511006 parameters = None ,
9521007 resources = None ,
1008+ start_from_world_state = start_from_world_state , # pylint: disable=line-too-long
9531009 )
9541010 return
9551011
@@ -999,6 +1055,7 @@ def get_node_identifier_for_node_in_tree(
9991055 simulation_mode = simulation_mode ,
10001056 embed_skill_traces = embed_skill_traces ,
10011057 silence_outputs = silence_outputs ,
1058+ start_from_world_state = start_from_world_state , # pylint: disable=line-too-long
10021059 )
10031060
10041061 # pylint: enable=g-doc-args
@@ -1131,6 +1188,7 @@ def start(
11311188
11321189 simulation_mode : Optional ["Executive.SimulationMode" ] = None ,
11331190 embed_skill_traces : bool = False ,
1191+ start_from_world_state : worlds .EditWorldId | None = None , # pylint: disable=line-too-long
11341192 ) -> None :
11351193 """Starts the currently loaded plan.
11361194
@@ -1155,6 +1213,21 @@ def start(
11551213 recover_from_nodes: List of nodes to recover from. Execution will forward
11561214 to these nodes and run from there.
11571215
1216+
1217+ start_from_world_state: Optional parameter to specify what starting world
1218+ state to start the operation from. If an EditWorldId is set, the execute
1219+ belief world and simulation world will be reset to the specified world
1220+ before starting the operation. Otherwise, the operation will be started
1221+ in the current world state as-is.
1222+
1223+ Specifying `worlds.EditWorldId.INITIAL` resets the world state to the
1224+ state of the Initial editing world before starting the operation.
1225+
1226+ Specifying `worlds.EditWorldId.BELIEF` keeps the execute belief world in
1227+ its current state, but the simulation world state is first reset to
1228+ match the execute world.
1229+
1230+
11581231 Raises:
11591232 solutions_errors.UnavailableError: On executive service not reachable.
11601233 grpc.RpcError: On any other gRPC error.
@@ -1190,6 +1263,7 @@ def start(
11901263
11911264 simulation_mode = simulation_mode ,
11921265 embed_skill_traces = embed_skill_traces ,
1266+ start_from_world_state = start_from_world_state , # pylint: disable=line-too-long
11931267 )
11941268
11951269 if blocking :
@@ -1453,6 +1527,7 @@ def _start_with_retry(
14531527
14541528 simulation_mode : Optional ["Executive.SimulationMode" ] = None ,
14551529 embed_skill_traces : bool = False ,
1530+ start_from_world_state : worlds .EditWorldId | None = None , # pylint: disable=line-too-long
14561531 ) -> None :
14571532 """Starts the executive and handles errors."""
14581533 if self ._operation is None :
@@ -1492,6 +1567,10 @@ def _start_with_retry(
14921567 if resources is not None :
14931568 for reference , handle in resources .items ():
14941569 request .resources [reference ] = handle
1570+
1571+ if start_from_world_state is not None :
1572+ request .scene_id = start_from_world_state
1573+
14951574 self ._operation .update_from_proto (self ._stub .StartOperation (request ))
14961575
14971576 @error_handling .retry_on_grpc_unavailable
0 commit comments