isar 1.33.8__py3-none-any.whl → 1.33.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of isar might be problematic. Click here for more details.

isar/config/settings.py CHANGED
@@ -168,7 +168,7 @@ class Settings(BaseSettings):
168
168
  UPLOAD_INSPECTIONS_ASYNC: bool = Field(default=False)
169
169
 
170
170
  # URL to storage account for Azure Blob Storage
171
- BLOB_STORAGE_ACCOUNT: str = Field(default="eqrobotdevstorage")
171
+ BLOB_STORAGE_ACCOUNT: str = Field(default="")
172
172
 
173
173
  # Name of blob container in Azure Blob Storage [slimm test]
174
174
  BLOB_CONTAINER: str = Field(default="test")
@@ -27,12 +27,13 @@ class AwaitNextMission(EventHandlerBase):
27
27
  event: Event[bool],
28
28
  ) -> Optional[Callable]:
29
29
  should_lockdown: bool = event.consume_event()
30
- if should_lockdown:
31
- events.api_requests.send_to_lockdown.response.trigger_event(
32
- LockdownResponse(lockdown_started=True)
33
- )
34
- return state_machine.request_lockdown_mission # type: ignore
35
- return None
30
+ if not should_lockdown:
31
+ return None
32
+
33
+ events.api_requests.send_to_lockdown.response.trigger_event(
34
+ LockdownResponse(lockdown_started=True)
35
+ )
36
+ return state_machine.request_lockdown_mission # type: ignore
36
37
 
37
38
  event_handlers: List[EventHandlerMapping] = [
38
39
  EventHandlerMapping(
@@ -32,18 +32,19 @@ class GoingToLockdown(EventHandlerBase):
32
32
  event: Event[Optional[ErrorMessage]],
33
33
  ) -> Optional[Callable]:
34
34
  mission_failed: Optional[ErrorMessage] = event.consume_event()
35
- if mission_failed is not None:
36
- state_machine.logger.warning(
37
- f"Failed to initiate mission "
38
- f"{str(state_machine.current_mission.id)[:8]} because: "
39
- f"{mission_failed.error_description}"
40
- )
41
- state_machine.current_mission.error_message = ErrorMessage(
42
- error_reason=mission_failed.error_reason,
43
- error_description=mission_failed.error_description,
44
- )
45
- return state_machine.lockdown_mission_failed # type: ignore
46
- return None
35
+ if mission_failed is None:
36
+ return None
37
+
38
+ state_machine.logger.warning(
39
+ f"Failed to initiate mission "
40
+ f"{str(state_machine.current_mission.id)[:8]} because: "
41
+ f"{mission_failed.error_description}"
42
+ )
43
+ state_machine.current_mission.error_message = ErrorMessage(
44
+ error_reason=mission_failed.error_reason,
45
+ error_description=mission_failed.error_description,
46
+ )
47
+ return state_machine.lockdown_mission_failed # type: ignore
47
48
 
48
49
  event_handlers: List[EventHandlerMapping] = [
49
50
  EventHandlerMapping(
@@ -22,12 +22,13 @@ class Home(EventHandlerBase):
22
22
 
23
23
  def _send_to_lockdown_event_handler(event: Event[bool]):
24
24
  should_send_robot_home: bool = event.consume_event()
25
- if should_send_robot_home:
26
- events.api_requests.send_to_lockdown.response.trigger_event(
27
- LockdownResponse(lockdown_started=True)
28
- )
29
- return state_machine.reached_lockdown # type: ignore
30
- return None
25
+ if not should_send_robot_home:
26
+ return None
27
+
28
+ events.api_requests.send_to_lockdown.response.trigger_event(
29
+ LockdownResponse(lockdown_started=True)
30
+ )
31
+ return state_machine.reached_lockdown # type: ignore
31
32
 
32
33
  def _robot_status_event_handler(
33
34
  state_machine: "StateMachine",
@@ -17,12 +17,13 @@ class InterventionNeeded(EventHandlerBase):
17
17
  def release_intervention_needed_handler(
18
18
  event: Event[bool],
19
19
  ) -> Optional[Callable]:
20
- if event.consume_event():
21
- state_machine.events.api_requests.release_intervention_needed.response.trigger_event(
22
- True
23
- )
24
- return state_machine.release_intervention_needed # type: ignore
25
- return None
20
+ if not event.consume_event():
21
+ return None
22
+
23
+ state_machine.events.api_requests.release_intervention_needed.response.trigger_event(
24
+ True
25
+ )
26
+ return state_machine.release_intervention_needed # type: ignore
26
27
 
27
28
  event_handlers: List[EventHandlerMapping] = [
28
29
  EventHandlerMapping(
@@ -14,13 +14,14 @@ class Lockdown(EventHandlerBase):
14
14
 
15
15
  def _release_from_lockdown_handler(event: Event[bool]):
16
16
  should_release_from_lockdown: bool = event.consume_event()
17
- if should_release_from_lockdown:
18
- events.api_requests.release_from_lockdown.response.trigger_event(True)
19
- if state_machine.battery_level_is_above_mission_start_threshold():
20
- return state_machine.release_from_lockdown # type: ignore
21
- else:
22
- return state_machine.starting_recharging # type: ignore
23
- return None
17
+ if not should_release_from_lockdown:
18
+ return None
19
+
20
+ events.api_requests.release_from_lockdown.response.trigger_event(True)
21
+ if state_machine.battery_level_is_above_mission_start_threshold():
22
+ return state_machine.release_from_lockdown # type: ignore
23
+ else:
24
+ return state_machine.starting_recharging # type: ignore
24
25
 
25
26
  event_handlers: List[EventHandlerMapping] = [
26
27
  EventHandlerMapping(
@@ -27,9 +27,10 @@ class Monitor(EventHandlerBase):
27
27
  shared_state = state_machine.shared_state
28
28
 
29
29
  def _pause_mission_event_handler(event: Event[bool]) -> Optional[Callable]:
30
- if event.consume_event():
31
- return state_machine.pause # type: ignore
32
- return None
30
+ if not event.consume_event():
31
+ return None
32
+
33
+ return state_machine.pause # type: ignore
33
34
 
34
35
  def _handle_task_completed(task_status: TaskStatus):
35
36
  if state_machine.should_upload_inspections():
@@ -44,35 +45,38 @@ class Monitor(EventHandlerBase):
44
45
  )
45
46
 
46
47
  state_machine.iterate_current_task()
47
- if state_machine.current_task is None:
48
- return state_machine.mission_finished # type: ignore
49
- return None
48
+ if state_machine.current_task is not None:
49
+ return None
50
+
51
+ return state_machine.mission_finished # type: ignore
50
52
 
51
53
  def _robot_battery_level_updated_handler(
52
54
  event: Event[float],
53
55
  ) -> Optional[Callable]:
54
56
  battery_level: float = event.check()
55
- if battery_level < settings.ROBOT_MISSION_BATTERY_START_THRESHOLD:
56
- state_machine.publish_mission_aborted(
57
- "Robot battery too low to continue mission", True
58
- )
59
- state_machine._finalize()
60
- state_machine.logger.warning(
61
- "Cancelling current mission due to low battery"
62
- )
63
- return state_machine.stop # type: ignore
64
- return None
57
+ if battery_level >= settings.ROBOT_MISSION_BATTERY_START_THRESHOLD:
58
+ return None
59
+
60
+ state_machine.publish_mission_aborted(
61
+ "Robot battery too low to continue mission", True
62
+ )
63
+ state_machine._finalize()
64
+ state_machine.logger.warning(
65
+ "Cancelling current mission due to low battery"
66
+ )
67
+ return state_machine.stop # type: ignore
65
68
 
66
69
  def _send_to_lockdown_event_handler(
67
70
  event: Event[bool],
68
71
  ) -> Optional[Callable]:
69
72
  should_lockdown: bool = event.consume_event()
70
- if should_lockdown:
71
- state_machine.logger.warning(
72
- "Cancelling current mission due to robot going to lockdown"
73
- )
74
- return state_machine.stop_go_to_lockdown # type: ignore
75
- return None
73
+ if not should_lockdown:
74
+ return None
75
+
76
+ state_machine.logger.warning(
77
+ "Cancelling current mission due to robot going to lockdown"
78
+ )
79
+ return state_machine.stop_go_to_lockdown # type: ignore
76
80
 
77
81
  event_handlers: List[EventHandlerMapping] = [
78
82
  EventHandlerMapping(
@@ -19,28 +19,30 @@ class Paused(EventHandlerBase):
19
19
  event: Event[float],
20
20
  ) -> Optional[Callable]:
21
21
  battery_level: float = event.check()
22
- if battery_level < settings.ROBOT_MISSION_BATTERY_START_THRESHOLD:
23
- state_machine.publish_mission_aborted(
24
- "Robot battery too low to continue mission", True
25
- )
26
- state_machine._finalize()
27
- state_machine.logger.warning(
28
- "Cancelling current mission due to low battery"
29
- )
30
- return state_machine.stop # type: ignore
31
- return None
22
+ if battery_level >= settings.ROBOT_MISSION_BATTERY_START_THRESHOLD:
23
+ return None
24
+
25
+ state_machine.publish_mission_aborted(
26
+ "Robot battery too low to continue mission", True
27
+ )
28
+ state_machine._finalize()
29
+ state_machine.logger.warning(
30
+ "Cancelling current mission due to low battery"
31
+ )
32
+ return state_machine.stop # type: ignore
32
33
 
33
34
  def _send_to_lockdown_event_handler(
34
35
  event: Event[bool],
35
36
  ) -> Optional[Callable]:
36
37
  should_lockdown: bool = event.consume_event()
37
- if should_lockdown:
38
- state_machine._finalize()
39
- state_machine.logger.warning(
40
- "Cancelling current mission due to robot going to lockdown"
41
- )
42
- return state_machine.stop_go_to_lockdown # type: ignore
43
- return None
38
+ if not should_lockdown:
39
+ return None
40
+
41
+ state_machine._finalize()
42
+ state_machine.logger.warning(
43
+ "Cancelling current mission due to robot going to lockdown"
44
+ )
45
+ return state_machine.stop_go_to_lockdown # type: ignore
44
46
 
45
47
  event_handlers: List[EventHandlerMapping] = [
46
48
  EventHandlerMapping(
@@ -31,29 +31,30 @@ class Pausing(EventHandlerBase):
31
31
  state_machine.publish_mission_status()
32
32
  state_machine.send_task_status()
33
33
 
34
- if error_message is not None:
35
- return state_machine.mission_pausing_failed # type: ignore
36
- return None
34
+ if error_message is None:
35
+ return None
36
+
37
+ return state_machine.mission_pausing_failed # type: ignore
37
38
 
38
39
  def _successful_pause_event_handler(event: Event[bool]) -> Optional[Callable]:
39
- if event.consume_event():
40
+ if not event.consume_event():
41
+ return None
40
42
 
41
- state_machine.current_mission.status = MissionStatus.Paused
42
- state_machine.current_task.status = TaskStatus.Paused
43
+ state_machine.current_mission.status = MissionStatus.Paused
44
+ state_machine.current_task.status = TaskStatus.Paused
43
45
 
44
- paused_mission_response: ControlMissionResponse = (
45
- state_machine._make_control_mission_response()
46
- )
46
+ paused_mission_response: ControlMissionResponse = (
47
+ state_machine._make_control_mission_response()
48
+ )
47
49
 
48
- state_machine.events.api_requests.pause_mission.response.trigger_event(
49
- paused_mission_response
50
- )
50
+ state_machine.events.api_requests.pause_mission.response.trigger_event(
51
+ paused_mission_response
52
+ )
51
53
 
52
- state_machine.publish_mission_status()
53
- state_machine.send_task_status()
54
+ state_machine.publish_mission_status()
55
+ state_machine.send_task_status()
54
56
 
55
- return state_machine.mission_paused # type:ignore
56
- return None
57
+ return state_machine.mission_paused # type:ignore
57
58
 
58
59
  event_handlers: List[EventHandlerMapping] = [
59
60
  EventHandlerMapping(
@@ -31,29 +31,30 @@ class PausingReturnHome(EventHandlerBase):
31
31
  state_machine.publish_mission_status()
32
32
  state_machine.send_task_status()
33
33
 
34
- if error_message is not None:
35
- return state_machine.return_home_mission_pausing_failed # type: ignore
36
- return None
34
+ if error_message is None:
35
+ return None
36
+
37
+ return state_machine.return_home_mission_pausing_failed # type: ignore
37
38
 
38
39
  def _successful_pause_event_handler(event: Event[bool]) -> Optional[Callable]:
39
- if event.consume_event():
40
+ if not event.consume_event():
41
+ return None
40
42
 
41
- state_machine.current_mission.status = MissionStatus.Paused
42
- state_machine.current_task.status = TaskStatus.Paused
43
+ state_machine.current_mission.status = MissionStatus.Paused
44
+ state_machine.current_task.status = TaskStatus.Paused
43
45
 
44
- paused_mission_response: ControlMissionResponse = (
45
- state_machine._make_control_mission_response()
46
- )
46
+ paused_mission_response: ControlMissionResponse = (
47
+ state_machine._make_control_mission_response()
48
+ )
47
49
 
48
- state_machine.events.api_requests.pause_mission.response.trigger_event(
49
- paused_mission_response
50
- )
50
+ state_machine.events.api_requests.pause_mission.response.trigger_event(
51
+ paused_mission_response
52
+ )
51
53
 
52
- state_machine.publish_mission_status()
53
- state_machine.send_task_status()
54
+ state_machine.publish_mission_status()
55
+ state_machine.send_task_status()
54
56
 
55
- return state_machine.return_home_mission_paused # type: ignore
56
- return None
57
+ return state_machine.return_home_mission_paused # type: ignore
57
58
 
58
59
  event_handlers: List[EventHandlerMapping] = [
59
60
  EventHandlerMapping(
@@ -1,4 +1,4 @@
1
- from typing import TYPE_CHECKING, List
1
+ from typing import TYPE_CHECKING, List, Optional
2
2
 
3
3
  from isar.apis.models.models import LockdownResponse
4
4
  from isar.config.settings import settings
@@ -18,23 +18,29 @@ class Recharging(EventHandlerBase):
18
18
 
19
19
  def robot_battery_level_updated_handler(event: Event[float]):
20
20
  battery_level: float = event.check()
21
- if battery_level >= settings.ROBOT_BATTERY_RECHARGE_THRESHOLD:
22
- return state_machine.robot_recharged # type: ignore
23
- return None
21
+ if battery_level < settings.ROBOT_BATTERY_RECHARGE_THRESHOLD:
22
+ return None
23
+
24
+ return state_machine.robot_recharged # type: ignore
24
25
 
25
26
  def robot_offline_handler(event: Event[RobotStatus]):
26
- robot_status: RobotStatus = event.check()
27
+ robot_status: Optional[RobotStatus] = event.check()
28
+
29
+ if robot_status is None:
30
+ return None
31
+
27
32
  if robot_status == RobotStatus.Offline:
28
33
  return state_machine.robot_went_offline # type: ignore
29
34
 
30
35
  def _send_to_lockdown_event_handler(event: Event[bool]):
31
36
  should_lockdown: bool = event.consume_event()
32
- if should_lockdown:
33
- events.api_requests.send_to_lockdown.response.trigger_event(
34
- LockdownResponse(lockdown_started=True)
35
- )
36
- return state_machine.reached_lockdown # type: ignore
37
- return None
37
+ if not should_lockdown:
38
+ return None
39
+
40
+ events.api_requests.send_to_lockdown.response.trigger_event(
41
+ LockdownResponse(lockdown_started=True)
42
+ )
43
+ return state_machine.reached_lockdown # type: ignore
38
44
 
39
45
  event_handlers: List[EventHandlerMapping] = [
40
46
  EventHandlerMapping(
@@ -20,38 +20,42 @@ class ReturnHomePaused(EventHandlerBase):
20
20
  event: Event[float],
21
21
  ) -> Optional[Callable]:
22
22
  battery_level: float = event.check()
23
- if battery_level < settings.ROBOT_MISSION_BATTERY_START_THRESHOLD:
24
- return state_machine.resume # type: ignore
25
- return None
23
+
24
+ if battery_level >= settings.ROBOT_MISSION_BATTERY_START_THRESHOLD:
25
+ return None
26
+
27
+ return state_machine.resume # type: ignore
26
28
 
27
29
  def _start_mission_event_handler(
28
30
  event: Event[Mission],
29
31
  ) -> Optional[Callable]:
30
- if event.has_event():
31
- if not state_machine.battery_level_is_above_mission_start_threshold():
32
- state_machine.events.api_requests.start_mission.request.consume_event()
33
- response = MissionStartResponse(
34
- mission_id=None,
35
- mission_started=False,
36
- mission_not_started_reason="Robot battery too low",
37
- )
38
- state_machine.events.api_requests.start_mission.response.trigger_event(
39
- response
40
- )
41
- return None
42
- return state_machine.stop_return_home # type: ignore
43
- return None
32
+ if not event.has_event():
33
+ return None
34
+
35
+ if not state_machine.battery_level_is_above_mission_start_threshold():
36
+ state_machine.events.api_requests.start_mission.request.consume_event()
37
+ response = MissionStartResponse(
38
+ mission_id=None,
39
+ mission_started=False,
40
+ mission_not_started_reason="Robot battery too low",
41
+ )
42
+ state_machine.events.api_requests.start_mission.response.trigger_event(
43
+ response
44
+ )
45
+ return None
46
+ return state_machine.stop_return_home # type: ignore
44
47
 
45
48
  def _send_to_lockdown_event_handler(
46
49
  event: Event[bool],
47
50
  ) -> Optional[Callable]:
48
51
  should_lockdown: bool = event.consume_event()
49
- if should_lockdown:
50
- events.api_requests.send_to_lockdown.response.trigger_event(
51
- LockdownResponse(lockdown_started=True)
52
- )
53
- return state_machine.resume_lockdown # type: ignore
54
- return None
52
+ if not should_lockdown:
53
+ return None
54
+
55
+ events.api_requests.send_to_lockdown.response.trigger_event(
56
+ LockdownResponse(lockdown_started=True)
57
+ )
58
+ return state_machine.resume_lockdown # type: ignore
55
59
 
56
60
  event_handlers: List[EventHandlerMapping] = [
57
61
  EventHandlerMapping(
@@ -24,9 +24,10 @@ class ReturningHome(EventHandlerBase):
24
24
  events = state_machine.events
25
25
 
26
26
  def _pause_mission_event_handler(event: Event[bool]) -> Optional[Callable]:
27
- if event.consume_event():
28
- return state_machine.pause_return_home # type: ignore
29
- return None
27
+ if not event.consume_event():
28
+ return None
29
+
30
+ return state_machine.pause_return_home # type: ignore
30
31
 
31
32
  def _handle_task_completed(status: TaskStatus):
32
33
  if status != TaskStatus.Successful:
@@ -45,31 +46,34 @@ class ReturningHome(EventHandlerBase):
45
46
  def _start_mission_event_handler(
46
47
  event: Event[Mission],
47
48
  ) -> Optional[Callable]:
48
- if event.has_event():
49
- if not state_machine.battery_level_is_above_mission_start_threshold():
50
- state_machine.events.api_requests.start_mission.request.consume_event()
51
- response = MissionStartResponse(
52
- mission_id=None,
53
- mission_started=False,
54
- mission_not_started_reason="Robot battery too low",
55
- )
56
- state_machine.events.api_requests.start_mission.response.trigger_event(
57
- response
58
- )
59
- return None
60
- return state_machine.stop_return_home # type: ignore
61
- return None
49
+ if not event.has_event():
50
+ return None
51
+
52
+ if not state_machine.battery_level_is_above_mission_start_threshold():
53
+ state_machine.events.api_requests.start_mission.request.consume_event()
54
+ response = MissionStartResponse(
55
+ mission_id=None,
56
+ mission_started=False,
57
+ mission_not_started_reason="Robot battery too low",
58
+ )
59
+ state_machine.events.api_requests.start_mission.response.trigger_event(
60
+ response
61
+ )
62
+ return None
63
+
64
+ return state_machine.stop_return_home # type: ignore
62
65
 
63
66
  def _send_to_lockdown_event_handler(
64
67
  event: Event[bool],
65
68
  ) -> Optional[Callable]:
66
69
  should_lockdown: bool = event.consume_event()
67
- if should_lockdown:
68
- events.api_requests.send_to_lockdown.response.trigger_event(
69
- LockdownResponse(lockdown_started=True)
70
- )
71
- return state_machine.go_to_lockdown # type: ignore
72
- return None
70
+ if not should_lockdown:
71
+ return None
72
+
73
+ events.api_requests.send_to_lockdown.response.trigger_event(
74
+ LockdownResponse(lockdown_started=True)
75
+ )
76
+ return state_machine.go_to_lockdown # type: ignore
73
77
 
74
78
  event_handlers: List[EventHandlerMapping] = [
75
79
  EventHandlerMapping(
@@ -45,17 +45,19 @@ class Stopping(EventHandlerBase):
45
45
  event: Event[ErrorMessage],
46
46
  ) -> Optional[Callable]:
47
47
  error_message: Optional[ErrorMessage] = event.consume_event()
48
- if error_message is not None:
49
- return state_machine.mission_stopping_failed # type: ignore
50
- return None
48
+ if error_message is None:
49
+ return None
50
+
51
+ return state_machine.mission_stopping_failed # type: ignore
51
52
 
52
53
  def _successful_stop_event_handler(event: Event[bool]) -> Optional[Callable]:
53
- if event.consume_event():
54
- _stop_mission_cleanup()
55
- if not state_machine.battery_level_is_above_mission_start_threshold():
56
- return state_machine.request_return_home # type: ignore
57
- return state_machine.mission_stopped # type: ignore
58
- return None
54
+ if not event.consume_event():
55
+ return None
56
+
57
+ _stop_mission_cleanup()
58
+ if not state_machine.battery_level_is_above_mission_start_threshold():
59
+ return state_machine.request_return_home # type: ignore
60
+ return state_machine.mission_stopped # type: ignore
59
61
 
60
62
  event_handlers: List[EventHandlerMapping] = [
61
63
  EventHandlerMapping(
@@ -38,27 +38,27 @@ class StoppingGoToLockdown(EventHandlerBase):
38
38
  event: Event[ErrorMessage],
39
39
  ) -> Optional[Callable]:
40
40
  error_message: Optional[ErrorMessage] = event.consume_event()
41
- if error_message is not None:
42
- events.api_requests.send_to_lockdown.response.trigger_event(
43
- LockdownResponse(
44
- lockdown_started=False,
45
- failure_reason="Failed to stop ongoing mission",
46
- )
41
+ if error_message is None:
42
+ return None
43
+
44
+ events.api_requests.send_to_lockdown.response.trigger_event(
45
+ LockdownResponse(
46
+ lockdown_started=False,
47
+ failure_reason="Failed to stop ongoing mission",
47
48
  )
48
- return state_machine.mission_stopping_failed # type: ignore
49
- return None
49
+ )
50
+ return state_machine.mission_stopping_failed # type: ignore
50
51
 
51
52
  def _successful_stop_event_handler(event: Event[bool]) -> Optional[Callable]:
52
- if event.consume_event():
53
- state_machine.publish_mission_aborted(
54
- "Robot being sent to lockdown", True
55
- )
56
- _stop_mission_cleanup()
57
- events.api_requests.send_to_lockdown.response.trigger_event(
58
- LockdownResponse(lockdown_started=True)
59
- )
60
- return state_machine.request_lockdown_mission # type: ignore
61
- return None
53
+ if not event.consume_event():
54
+ return None
55
+
56
+ state_machine.publish_mission_aborted("Robot being sent to lockdown", True)
57
+ _stop_mission_cleanup()
58
+ events.api_requests.send_to_lockdown.response.trigger_event(
59
+ LockdownResponse(lockdown_started=True)
60
+ )
61
+ return state_machine.request_lockdown_mission # type: ignore
62
62
 
63
63
  event_handlers: List[EventHandlerMapping] = [
64
64
  EventHandlerMapping(
@@ -21,38 +21,40 @@ class StoppingReturnHome(EventHandlerBase):
21
21
  event: Event[ErrorMessage],
22
22
  ) -> Optional[Callable]:
23
23
  error_message: Optional[ErrorMessage] = event.consume_event()
24
- if error_message is not None:
25
- logger.warning(error_message.error_description)
26
- mission: Mission = (
27
- state_machine.events.api_requests.start_mission.request.consume_event()
28
- )
29
- state_machine.events.api_requests.start_mission.response.trigger_event(
30
- MissionStartResponse(
31
- mission_id=mission.id,
32
- mission_started=False,
33
- mission_not_started_reason="Failed to cancel return home mission",
34
- )
24
+ if error_message is None:
25
+ return None
26
+
27
+ logger.warning(error_message.error_description)
28
+ mission: Mission = (
29
+ state_machine.events.api_requests.start_mission.request.consume_event()
30
+ )
31
+ state_machine.events.api_requests.start_mission.response.trigger_event(
32
+ MissionStartResponse(
33
+ mission_id=mission.id,
34
+ mission_started=False,
35
+ mission_not_started_reason="Failed to cancel return home mission",
35
36
  )
36
- return state_machine.return_home_mission_stopping_failed # type: ignore
37
- return None
37
+ )
38
+ return state_machine.return_home_mission_stopping_failed # type: ignore
38
39
 
39
40
  def _successful_stop_event_handler(event: Event[bool]) -> Optional[Callable]:
40
- if event.consume_event():
41
- mission: Mission = (
42
- state_machine.events.api_requests.start_mission.request.consume_event()
43
- )
41
+ if not event.consume_event():
42
+ return None
44
43
 
45
- state_machine.reset_state_machine()
44
+ mission: Mission = (
45
+ state_machine.events.api_requests.start_mission.request.consume_event()
46
+ )
46
47
 
47
- if mission:
48
- state_machine.start_mission(mission=mission)
49
- return state_machine.request_mission_start # type: ignore
48
+ state_machine.reset_state_machine()
50
49
 
51
- state_machine.logger.error(
52
- "Stopped return home without a new mission to start"
53
- )
54
- return state_machine.request_return_home # type: ignore
55
- return None
50
+ if mission:
51
+ state_machine.start_mission(mission=mission)
52
+ return state_machine.request_mission_start # type: ignore
53
+
54
+ state_machine.logger.error(
55
+ "Stopped return home without a new mission to start"
56
+ )
57
+ return state_machine.request_return_home # type: ignore
56
58
 
57
59
  event_handlers: List[EventHandlerMapping] = [
58
60
  EventHandlerMapping(
@@ -18,15 +18,18 @@ class UnknownStatus(EventHandlerBase):
18
18
  def _robot_status_event_handler(
19
19
  event: Event[RobotStatus],
20
20
  ) -> Optional[Callable]:
21
- robot_status: RobotStatus = event.check()
22
- if (
21
+ robot_status: Optional[RobotStatus] = event.check()
22
+ if robot_status is None:
23
+ return None
24
+ if not (
23
25
  robot_status == RobotStatus.Home
24
26
  or robot_status == RobotStatus.Offline
25
27
  or robot_status == RobotStatus.BlockedProtectiveStop
26
28
  or robot_status == RobotStatus.Available
27
29
  ):
28
- return state_machine.robot_status_changed # type: ignore
29
- return None
30
+ return None
31
+
32
+ return state_machine.robot_status_changed # type: ignore
30
33
 
31
34
  event_handlers: List[EventHandlerMapping] = [
32
35
  EventHandlerMapping(
@@ -16,28 +16,30 @@ def start_mission_event_handler(
16
16
  response: Event[MissionStartResponse],
17
17
  ) -> Optional[Callable]:
18
18
  mission: Optional[Mission] = event.consume_event()
19
- if mission:
20
- if not state_machine.battery_level_is_above_mission_start_threshold():
21
- response.trigger_event(
22
- MissionStartResponse(
23
- mission_id=mission.id,
24
- mission_started=False,
25
- mission_not_started_reason="Robot battery too low",
26
- )
19
+ if not mission:
20
+ return None
21
+
22
+ if not state_machine.battery_level_is_above_mission_start_threshold():
23
+ response.trigger_event(
24
+ MissionStartResponse(
25
+ mission_id=mission.id,
26
+ mission_started=False,
27
+ mission_not_started_reason="Robot battery too low",
27
28
  )
28
- return None
29
- state_machine.start_mission(mission=mission)
30
- return state_machine.request_mission_start # type: ignore
31
- return None
29
+ )
30
+ return None
31
+ state_machine.start_mission(mission=mission)
32
+ return state_machine.request_mission_start # type: ignore
32
33
 
33
34
 
34
35
  def return_home_event_handler(
35
36
  state_machine: "StateMachine", event: Event[bool]
36
37
  ) -> Optional[Callable]:
37
- if event.consume_event():
38
- state_machine.events.api_requests.return_home.response.trigger_event(True)
39
- return state_machine.request_return_home # type: ignore
40
- return None
38
+ if not event.consume_event():
39
+ return None
40
+
41
+ state_machine.events.api_requests.return_home.response.trigger_event(True)
42
+ return state_machine.request_return_home # type: ignore
41
43
 
42
44
 
43
45
  def robot_status_event_handler(
@@ -48,6 +50,7 @@ def robot_status_event_handler(
48
50
  ) -> Optional[Callable]:
49
51
  if not status_changed_event.consume_event():
50
52
  return None
53
+
51
54
  robot_status: Optional[RobotStatus] = status_event.check()
52
55
  if robot_status != expected_status:
53
56
  return state_machine.robot_status_changed # type: ignore
@@ -58,29 +61,33 @@ def stop_mission_event_handler(
58
61
  state_machine: "StateMachine", event: Event[str]
59
62
  ) -> Optional[Callable]:
60
63
  mission_id: str = event.consume_event()
61
- if mission_id is not None:
62
- if state_machine.current_mission.id == mission_id or mission_id == "":
63
- return state_machine.stop # type: ignore
64
- else:
65
- state_machine.events.api_requests.stop_mission.response.trigger_event(
66
- ControlMissionResponse(
67
- mission_id=mission_id,
68
- mission_status=state_machine.current_mission.status,
69
- mission_not_found=True,
70
- task_id=state_machine.current_task.id,
71
- task_status=state_machine.current_task.status,
72
- )
64
+ if mission_id is None:
65
+ return None
66
+
67
+ if state_machine.current_mission.id == mission_id or mission_id == "":
68
+ return state_machine.stop # type: ignore
69
+ else:
70
+ state_machine.events.api_requests.stop_mission.response.trigger_event(
71
+ ControlMissionResponse(
72
+ mission_id=mission_id,
73
+ mission_status=state_machine.current_mission.status,
74
+ mission_not_found=True,
75
+ task_id=state_machine.current_task.id,
76
+ task_status=state_machine.current_task.status,
73
77
  )
74
- return None
78
+ )
79
+ return None
75
80
 
76
81
 
77
82
  def mission_started_event_handler(
78
83
  state_machine: "StateMachine",
79
84
  event: Event[bool],
80
85
  ) -> Optional[Callable]:
81
- if event.consume_event():
82
- state_machine.logger.info("Received confirmation that mission has started")
83
- state_machine.mission_ongoing = True
86
+ if not event.consume_event():
87
+ return None
88
+
89
+ state_machine.logger.info("Received confirmation that mission has started")
90
+ state_machine.mission_ongoing = True
84
91
  return None
85
92
 
86
93
 
@@ -89,18 +96,19 @@ def mission_failed_event_handler(
89
96
  event: Event[Optional[ErrorMessage]],
90
97
  ) -> Optional[Callable]:
91
98
  mission_failed: Optional[ErrorMessage] = event.consume_event()
92
- if mission_failed is not None:
93
- state_machine.logger.warning(
94
- f"Failed to initiate mission "
95
- f"{str(state_machine.current_mission.id)[:8]} because: "
96
- f"{mission_failed.error_description}"
97
- )
98
- state_machine.current_mission.error_message = ErrorMessage(
99
- error_reason=mission_failed.error_reason,
100
- error_description=mission_failed.error_description,
101
- )
102
- return state_machine.mission_failed_to_start # type: ignore
103
- return None
99
+ if mission_failed is None:
100
+ return None
101
+
102
+ state_machine.logger.warning(
103
+ f"Failed to initiate mission "
104
+ f"{str(state_machine.current_mission.id)[:8]} because: "
105
+ f"{mission_failed.error_description}"
106
+ )
107
+ state_machine.current_mission.error_message = ErrorMessage(
108
+ error_reason=mission_failed.error_reason,
109
+ error_description=mission_failed.error_description,
110
+ )
111
+ return state_machine.mission_failed_to_start # type: ignore
104
112
 
105
113
 
106
114
  def task_status_failed_event_handler(
@@ -173,9 +181,10 @@ def _handle_new_task_status(
173
181
 
174
182
  state_machine.current_task.status = status
175
183
 
176
- if state_machine.current_task.is_finished():
177
- state_machine.report_task_status(state_machine.current_task)
178
- state_machine.publish_task_status(task=state_machine.current_task)
184
+ if not state_machine.current_task.is_finished():
185
+ return None
179
186
 
180
- return handle_task_completed(status)
181
- return None
187
+ state_machine.report_task_status(state_machine.current_task)
188
+ state_machine.publish_task_status(task=state_machine.current_task)
189
+
190
+ return handle_task_completed(status)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: isar
3
- Version: 1.33.8
3
+ Version: 1.33.9
4
4
  Summary: Integration and Supervisory control of Autonomous Robots
5
5
  Author-email: Equinor ASA <fg_robots_dev@equinor.com>
6
6
  License: Eclipse Public License version 2.0
@@ -480,6 +480,7 @@ Enabling API authentication also requires the same environment variables. The re
480
480
  AZURE_CLIENT_ID
481
481
  AZURE_TENANT_ID
482
482
  AZURE_CLIENT_SECRET
483
+ ISAR_BLOB_STORAGE_ACCOUNT
483
484
  ```
484
485
 
485
486
  ## MQTT communication
@@ -16,7 +16,7 @@ isar/config/configuration_error.py,sha256=rO6WOhafX6xvVib8WxV-eY483Z0PpN-9PxGsq5
16
16
  isar/config/log.py,sha256=f_mLLz5RSa0kZkdpi1m0iMdwwDc4RQp12mnT6gu2exE,1303
17
17
  isar/config/logging.conf,sha256=a7ZBvZkrMDaPU3eRGAjL_eZz6hZsa6BaRJOfx8mbnnM,629
18
18
  isar/config/open_telemetry.py,sha256=Lgu0lbRQA-zz6ZDoBKKk0whQex5w18jl1wjqWzHUGdg,3634
19
- isar/config/settings.py,sha256=XMPU4d1V6FspjvMmto5TFmC8Slt8Nrpmn9n_tsyPTYk,14423
19
+ isar/config/settings.py,sha256=Bw1OUDo4DJLKk2rt2sP7okw3fW56CHrmWN9w1Hd0t9o,14406
20
20
  isar/config/certs/ca-cert.pem,sha256=qoNljfad_qcMxhXJIUMLd7nT-Qwf_d4dYSdoOFEOE8I,2179
21
21
  isar/config/keyvault/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  isar/config/keyvault/keyvault_error.py,sha256=zvPCsZLjboxsxthYkxpRERCTFxYV8R5WmACewAUQLwk,41
@@ -68,24 +68,24 @@ isar/state_machine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
68
68
  isar/state_machine/state_machine.py,sha256=lF25XC6vpNO8Mj3DWnmfPBKjS1atl7GdtGbBs2TkaUs,19887
69
69
  isar/state_machine/states_enum.py,sha256=EzqLHsNbR7KBMIY5Fa_CDaHm9v6g8UFzq9DJs4x0OU8,746
70
70
  isar/state_machine/states/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
- isar/state_machine/states/await_next_mission.py,sha256=3_KrK7nWu1Dm-VA3Rt1gwVsUbn9WuB7MoqLCfobGJSM,2749
71
+ isar/state_machine/states/await_next_mission.py,sha256=H1QN62S6iUYzLgyzK8UVG-0PEWGiCDdsIOjWC7BWD_Q,2742
72
72
  isar/state_machine/states/blocked_protective_stop.py,sha256=HJr_jH8OdHMuX8zhjlF5jtNAfMCxkA1X7nOGmkAz-RY,1263
73
- isar/state_machine/states/going_to_lockdown.py,sha256=RLMOH2lXiT3hQhfUtbBVAUfwKUd33yxbjq4uZDZ_Tkc,3388
74
- isar/state_machine/states/home.py,sha256=mCwXSb9LygNpY4qaKEkEYC3nP-6HdsSGmEyjsENumgM,3396
75
- isar/state_machine/states/intervention_needed.py,sha256=A0QYz1vD1tDKAealihXDuoGuMLtXrRfn_AwFoaUhT_Q,1640
76
- isar/state_machine/states/lockdown.py,sha256=mWjhjtky5GbW6BLjsi2TsS0LXI-yq7l29FaqZ2TbTek,1375
77
- isar/state_machine/states/monitor.py,sha256=wmiJrbKntnNw9ExS6-VdJJuW2Q3Jzl9DozmZmEXJ0Cw,5285
73
+ isar/state_machine/states/going_to_lockdown.py,sha256=q5C5MCRZxfSRJad2sntwIhvx_jsjm47Q6_4uN4kRQNI,3349
74
+ isar/state_machine/states/home.py,sha256=pAAQrVHjbtOsVz0R_Z2CBQewearLoqGoCkGz2R62pT0,3389
75
+ isar/state_machine/states/intervention_needed.py,sha256=nv7054e9gBJQ4-Mshs8cczqnD0IN-N-_5qvUR-cNcUM,1633
76
+ isar/state_machine/states/lockdown.py,sha256=ZFw9XMDENECuH3lh89RKeU_3CTzW0ZBvqCKptFJG5xo,1364
77
+ isar/state_machine/states/monitor.py,sha256=AbH6C_YJWlUvXVDtAgk3qQQkuuxga33-HD5hYpktQS0,5262
78
78
  isar/state_machine/states/offline.py,sha256=k1UdcRWLd6lJiL5cnpHKBkvMY4xZMt_x7XIauy-Rgww,1219
79
- isar/state_machine/states/paused.py,sha256=1ADoTJ3b137k7dmZYxeyGVhyrRF8qotxoV1NaWCbBUk,2870
80
- isar/state_machine/states/pausing.py,sha256=r0GywI1-JDOJLZEnxhnq_yFKza37eL45qHP0ir8SBsY,2762
81
- isar/state_machine/states/pausing_return_home.py,sha256=USyBLWpJqrsJ2hsdyW6i-gvEsog2l7OMJLdgIj-hq0Y,2808
82
- isar/state_machine/states/recharging.py,sha256=6zRppneGXetMaZVvhqCPcSoQyz08tftNhWHYxLCRGc8,2367
83
- isar/state_machine/states/return_home_paused.py,sha256=eBBFFbkLVfY_5yP2kPZnHHwxcwOcHKAxjkQTMat55HU,3398
84
- isar/state_machine/states/returning_home.py,sha256=47M760nPt1dh1P0C0PmfVLrjsZaWz_pGizuBbWZ0OeI,5211
85
- isar/state_machine/states/stopping.py,sha256=h0x94hVoIUJyml3WMrbJlbxG2dzMCeOL1rJoNCQfzGQ,3057
86
- isar/state_machine/states/stopping_go_to_lockdown.py,sha256=npbz0aFbbCpsEbmBYc8wE9DZXztkLkRB-OD7tslbE0c,3166
87
- isar/state_machine/states/stopping_return_home.py,sha256=ub952Ulas3a0lsV_dI4liBiInADo3zaPAGod2bPe_18,2985
88
- isar/state_machine/states/unknown_status.py,sha256=Y-g9cgme5zriyZ6YUzFRYhOvv9ZylCSwfaY8MJ7xEJ0,1791
79
+ isar/state_machine/states/paused.py,sha256=T1R66rcVPevDQSzYAHnAicSSJ0LvPuGWz8fD-mX_jzo,2833
80
+ isar/state_machine/states/pausing.py,sha256=uO6SpV8A2Rrx3P4r8TvBOH1Z9RxA8FvP5RBdEFXKybI,2723
81
+ isar/state_machine/states/pausing_return_home.py,sha256=6sKpLswUQl64bZGl3wX_A0d6z9MYsF511AUSDyWpkho,2769
82
+ isar/state_machine/states/recharging.py,sha256=TSCZuWhDKBW47peeP73k7aBD4_SEMOOdD1GgOdAq6lk,2447
83
+ isar/state_machine/states/return_home_paused.py,sha256=rr5iy8u6zaTMZAGtlf1HlroVShjytxKjE6t-wGym8nU,3355
84
+ isar/state_machine/states/returning_home.py,sha256=8TaEgOHWbxZKJ0XJhQVP5ljrAJ3hinVpHAEunsRi2vU,5171
85
+ isar/state_machine/states/stopping.py,sha256=6ahiz1LowqOJFCamcdFEwVvd2vnDZe60nwVoiV8Lnx0,3047
86
+ isar/state_machine/states/stopping_go_to_lockdown.py,sha256=Xuow75GFwXOH15CUQIsBrJj01bxX3YQq7xQh0zfpClo,3086
87
+ isar/state_machine/states/stopping_return_home.py,sha256=YtLa-XE7J_bU-GOj_GjWek7e2fKKn2JDQHoxjDx9nGo,2903
88
+ isar/state_machine/states/unknown_status.py,sha256=Vu07Sk90zFVInf3XdzFl5IaYrdrYaGO7Na7qAOGwjIk,1871
89
89
  isar/state_machine/transitions/mission.py,sha256=lwXdC5Jn19gO-wrSaZp3_77mLnvj-CaBYZk61U-qgoo,8211
90
90
  isar/state_machine/transitions/return_home.py,sha256=ho4Nae-C5BaxVFciFL546EuoMSDIWLqT58E8bNraW4o,6749
91
91
  isar/state_machine/transitions/robot_status.py,sha256=qJMurCpuficOiXs9us4lZJ5p_kOFSwKxJigiXfB1OS8,2430
@@ -98,14 +98,14 @@ isar/state_machine/transitions/functions/robot_status.py,sha256=bA8G5WtY7TA88MKp
98
98
  isar/state_machine/transitions/functions/start_mission.py,sha256=tIpZzYXCoeC6ZWj18UB4DiZuICpxfzFUK23wfunad7Q,2864
99
99
  isar/state_machine/transitions/functions/stop.py,sha256=4idsNh7v6CRJivD36oKnVmdKlP7mSugTLCh9n12R1-U,2114
100
100
  isar/state_machine/transitions/functions/utils.py,sha256=Wa72Ocq4QT1E6qkpEJZQ3h5o33pGvx7Tlkt2JZ2Grbk,314
101
- isar/state_machine/utils/common_event_handlers.py,sha256=LqXPB4qojzz0LqKF14g4pUd0HYBqZiCV83I4UMgy9DY,6450
101
+ isar/state_machine/utils/common_event_handlers.py,sha256=Wbka89VCkRjLkeO_lM-tduPF9JQ1Pf8ItrYSEa-0Shg,6365
102
102
  isar/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
103
103
  isar/storage/blob_storage.py,sha256=d44z3XpZDUbiKwN8Av2gytTJxnefMXrp5VhiGm4PWxU,3703
104
104
  isar/storage/local_storage.py,sha256=Rn-iiiz9DI7PzIhevOMshPIaqzJaqBXeVJMQRhVSl2M,2191
105
105
  isar/storage/storage_interface.py,sha256=x-imVeQTdL6dCaTaPTHpXwCR6N4e27WxK_Vpumg0x-Y,1230
106
106
  isar/storage/uploader.py,sha256=0BBrxyZGGRkNxGeZeoREucegs4yKUow2523oLEie07o,10841
107
107
  isar/storage/utilities.py,sha256=oLH0Rp7UtrQQdilfITnmXO1Z0ExdeDhBImYHid55vBA,3449
108
- isar-1.33.8.dist-info/licenses/LICENSE,sha256=3fc2-ebLwHWwzfQbulGNRdcNob3SBQeCfEVUDYxsuqw,14058
108
+ isar-1.33.9.dist-info/licenses/LICENSE,sha256=3fc2-ebLwHWwzfQbulGNRdcNob3SBQeCfEVUDYxsuqw,14058
109
109
  robot_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
110
110
  robot_interface/robot_interface.py,sha256=A6t19lcNU_6AfkYKY5DaF0sheym_SZEAawbfaj36Kjk,8997
111
111
  robot_interface/test_robot_interface.py,sha256=FV1urn7SbsMyWBIcTKjsBwAG4IsXeZ6pLHE0mA9EGGs,692
@@ -129,8 +129,8 @@ robot_interface/telemetry/payloads.py,sha256=A0SWiG609k6o6-Y3vhDWE6an2-_m7D_ND85
129
129
  robot_interface/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
130
130
  robot_interface/utilities/json_service.py,sha256=9N1zijW7K4d3WFR2autpaS8U9o1ibymiOX-6stTKCyk,1243
131
131
  robot_interface/utilities/uuid_string_factory.py,sha256=_NQIbBQ56w0qqO0MUDP6aPpHbxW7ATRhK8HnQiBSLkc,76
132
- isar-1.33.8.dist-info/METADATA,sha256=0a9aP_euTxYn_zJaBBvt1LXK8w92gQU2GOLmDr0PJ-Y,31190
133
- isar-1.33.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
134
- isar-1.33.8.dist-info/entry_points.txt,sha256=TFam7uNNw7J0iiDYzsH2gfG0u1eV1wh3JTw_HkhgKLk,49
135
- isar-1.33.8.dist-info/top_level.txt,sha256=UwIML2RtuQKCyJJkatcSnyp6-ldDjboB9k9JgKipO-U,21
136
- isar-1.33.8.dist-info/RECORD,,
132
+ isar-1.33.9.dist-info/METADATA,sha256=uu6Ab1WekJ79wzhxEhXbiaD62BVjAwHIzY1QlrKBC2o,31216
133
+ isar-1.33.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
134
+ isar-1.33.9.dist-info/entry_points.txt,sha256=TFam7uNNw7J0iiDYzsH2gfG0u1eV1wh3JTw_HkhgKLk,49
135
+ isar-1.33.9.dist-info/top_level.txt,sha256=UwIML2RtuQKCyJJkatcSnyp6-ldDjboB9k9JgKipO-U,21
136
+ isar-1.33.9.dist-info/RECORD,,
File without changes