Skip to content

Commit

Permalink
Reword increment steps to iterate steps
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Jul 18, 2024
1 parent 5a1c889 commit 7b9c6e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/isar/state_machine/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _resume(self) -> None:
self.queues.resume_mission.output.put(resume_mission_response)

self.current_task.reset_task()
self.increment_current_step()
self.iterate_current_step()

self.robot.resume()

Expand Down Expand Up @@ -337,12 +337,12 @@ def _mission_started(self) -> None:
else:
self.current_task.status = TaskStatus.InProgress
self.publish_task_status(task=self.current_task)
self.increment_current_step()
self.iterate_current_step()

def _step_finished(self) -> None:
self.publish_step_status(step=self.current_step)
self.increment_current_task()
self.increment_current_step()
self.iterate_current_task()
self.iterate_current_step()

def _full_mission_finished(self) -> None:
self.current_task = None
Expand Down Expand Up @@ -379,8 +379,8 @@ def _initiate_infeasible(self) -> None:
if self.stepwise_mission:
self.current_step.status = StepStatus.Failed
self.publish_step_status(step=self.current_step)
self.increment_current_task()
self.increment_current_step()
self.iterate_current_task()
self.iterate_current_step()

def _mission_stopped(self) -> None:
self.current_mission.status = MissionStatus.Cancelled
Expand Down Expand Up @@ -427,7 +427,7 @@ def begin(self):
"""
self.to_idle()

def increment_current_task(self):
def iterate_current_task(self):
if self.current_task.is_finished():
try:
self.current_task = self.task_selector.next_task()
Expand All @@ -437,7 +437,7 @@ def increment_current_task(self):
# Indicates that all tasks are finished
self.current_task = None

def increment_current_step(self):
def iterate_current_step(self):
if self.current_task != None:
self.current_step = self.current_task.next_step()

Expand Down
12 changes: 5 additions & 7 deletions src/isar/state_machine/states/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def _run(self) -> None:
break

if self.state_machine.current_task == None:
self.state_machine.increment_current_task()
self.state_machine.iterate_current_task()
if self.state_machine.current_step == None:
self.state_machine.increment_current_step()
self.state_machine.iterate_current_step()

self.state_machine.current_step.status = status

Expand All @@ -133,16 +133,14 @@ def _run(self) -> None:
if self._is_step_finished(self.state_machine.current_step):
self._report_step_status(self.state_machine.current_step)



if self.state_machine.current_task.is_finished():
# Report and update finished task
self.state_machine.current_task.update_task_status() # Uses the updated step status to set the task status
self.state_machine.publish_task_status(
task=self.state_machine.current_task
)

self.state_machine.increment_current_task()
self.state_machine.iterate_current_task()

if self.state_machine.current_task == None:
transition = self.state_machine.full_mission_finished # type: ignore
Expand All @@ -153,8 +151,8 @@ def _run(self) -> None:
self.state_machine.publish_task_status(
task=self.state_machine.current_task
)
self.state_machine.increment_current_step()

self.state_machine.iterate_current_step()

else: # If not all steps are done
self.state_machine.current_task.status = TaskStatus.InProgress
Expand Down

0 comments on commit 7b9c6e7

Please sign in to comment.