1717)
1818from isar .config .settings import robot_settings
1919from isar .services .utilities .scheduling_utilities import SchedulingUtilities
20- from isar .state_machine .states_enum import States
2120from robot_interface .models .mission .mission import Mission
2221from robot_interface .models .mission .task import TASKS
2322
@@ -54,9 +53,6 @@ def start_mission(
5453 detail = error_message_no_mission_definition ,
5554 )
5655
57- state : States = self .scheduling_utilities .get_state ()
58- self .scheduling_utilities .verify_state_machine_ready_to_receive_mission (state )
59-
6056 try :
6157 mission : Mission = to_isar_mission (
6258 start_mission_definition = mission_definition
@@ -81,32 +77,12 @@ def start_mission(
8177 def return_home (self ) -> None :
8278 self .logger .info ("Received request to return home" )
8379
84- state : States = self .scheduling_utilities .get_state ()
85- self .scheduling_utilities .verify_state_machine_ready_to_receive_return_home_mission (
86- state
87- )
88-
8980 self .scheduling_utilities .return_home ()
9081
9182 @tracer .start_as_current_span ("pause_mission" )
9283 def pause_mission (self ) -> ControlMissionResponse :
9384 self .logger .info ("Received request to pause current mission" )
9485
95- state : States = self .scheduling_utilities .get_state ()
96-
97- if state not in [
98- States .Monitor ,
99- States .ReturningHome ,
100- ]:
101- error_message = (
102- f"Conflict - Pause command received in invalid state - State: { state } "
103- )
104- self .logger .warning (error_message )
105- raise HTTPException (
106- status_code = HTTPStatus .CONFLICT ,
107- detail = error_message ,
108- )
109-
11086 pause_mission_response : ControlMissionResponse = (
11187 self .scheduling_utilities .pause_mission ()
11288 )
@@ -116,15 +92,6 @@ def pause_mission(self) -> ControlMissionResponse:
11692 def resume_mission (self ) -> ControlMissionResponse :
11793 self .logger .info ("Received request to resume current mission" )
11894
119- state : States = self .scheduling_utilities .get_state ()
120-
121- if state not in [States .Paused , States .ReturnHomePaused ]:
122- error_message = (
123- f"Conflict - Resume command received in invalid state - State: { state } "
124- )
125- self .logger .warning (error_message )
126- raise HTTPException (status_code = HTTPStatus .CONFLICT , detail = error_message )
127-
12895 resume_mission_response : ControlMissionResponse = (
12996 self .scheduling_utilities .resume_mission ()
13097 )
@@ -143,25 +110,6 @@ def stop_mission(
143110
144111 self .logger .info ("Received request to stop current mission" )
145112
146- state : States = self .scheduling_utilities .get_state ()
147-
148- if (
149- state == States .UnknownStatus
150- or state == States .Stopping
151- or state == States .Offline
152- or state == States .Home
153- or state == States .ReturningHome
154- or state == States .GoingToLockdown
155- or state == States .GoingToRecharging
156- or state == States .Recharging
157- or state == States .Maintenance
158- ):
159- error_message = (
160- f"Conflict - Stop command received in invalid state - State: { state } "
161- )
162- self .logger .warning (error_message )
163- raise HTTPException (status_code = HTTPStatus .CONFLICT , detail = error_message )
164-
165113 stop_mission_response : ControlMissionResponse = (
166114 self .scheduling_utilities .stop_mission (
167115 mission_id .mission_id if mission_id .mission_id else ""
@@ -173,84 +121,34 @@ def stop_mission(
173121 def release_intervention_needed (self ) -> None :
174122 self .logger .info ("Received request to release intervention needed state" )
175123
176- state : States = self .scheduling_utilities .get_state ()
177-
178- if state != States .InterventionNeeded :
179- error_message = f"Conflict - Release intervention needed command received in invalid state - State: { state } "
180- self .logger .warning (error_message )
181- raise HTTPException (
182- status_code = HTTPStatus .CONFLICT ,
183- detail = error_message ,
184- )
185-
186124 self .scheduling_utilities .release_intervention_needed ()
187125 self .logger .info ("Released intervention needed state successfully" )
188126
189127 @tracer .start_as_current_span ("lockdown" )
190128 def lockdown (self ) -> None :
191129 self .logger .info ("Received request to lockdown robot" )
192130
193- state : States = self .scheduling_utilities .get_state ()
194-
195- if state == States .Lockdown :
196- error_message = "Conflict - Lockdown command received in lockdown state"
197- self .logger .warning (error_message )
198- raise HTTPException (
199- status_code = HTTPStatus .CONFLICT ,
200- detail = error_message ,
201- )
202-
203131 self .scheduling_utilities .lock_down_robot ()
204132 self .logger .info ("Lockdown started successfully" )
205133
206134 @tracer .start_as_current_span ("release_lockdown" )
207135 def release_lockdown (self ) -> None :
208136 self .logger .info ("Received request to release robot lockdown" )
209137
210- state : States = self .scheduling_utilities .get_state ()
211-
212- if state != States .Lockdown :
213- error_message = f"Conflict - Release lockdown command received in invalid state - State: { state } "
214- self .logger .warning (error_message )
215- raise HTTPException (
216- status_code = HTTPStatus .CONFLICT ,
217- detail = error_message ,
218- )
219-
220138 self .scheduling_utilities .release_robot_lockdown ()
221139 self .logger .info ("Released lockdown successfully" )
222140
223141 @tracer .start_as_current_span ("maintenance_mode" )
224142 def set_maintenance_mode (self ) -> None :
225143 self .logger .info ("Received request to set maintenance_mode" )
226144
227- state : States = self .scheduling_utilities .get_state ()
228-
229- if state == States .Maintenance or state == States .StoppingDueToMaintenance :
230- message = f"Conflict - Call to set maintenance mode was given while in state { state } ."
231- self .logger .info (message )
232- raise HTTPException (
233- status_code = HTTPStatus .CONFLICT ,
234- detail = message ,
235- )
236-
237145 self .scheduling_utilities .set_maintenance_mode ()
238146 self .logger .info ("Maintenance mode has been set" )
239147
240148 @tracer .start_as_current_span ("release_maintenance_mode" )
241149 def release_maintenance_mode (self ) -> None :
242150 self .logger .info ("Received request to release robot from maintenance mode" )
243151
244- state : States = self .scheduling_utilities .get_state ()
245-
246- if state != States .Maintenance :
247- message = f"Conflict - Release maintenance mode command received in invalid state - State: { state } "
248- self .logger .info (message )
249- raise HTTPException (
250- status_code = HTTPStatus .CONFLICT ,
251- detail = message ,
252- )
253-
254152 self .scheduling_utilities .release_maintenance_mode ()
255153 self .logger .info ("Maintenance mode successfully released" )
256154
0 commit comments