Skip to content

Commit

Permalink
Add info on robot capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
GodVenn committed Jun 9, 2022
1 parent 00a89a9 commit 237fc86
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
11 changes: 8 additions & 3 deletions src/isar/apis/schedule/scheduling_controller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from http import HTTPStatus
from queue import Empty
from typing import List, Optional
from typing import List, Optional, Tuple

import numpy as np
from alitra import Frame, Orientation, Pose, Position
Expand Down Expand Up @@ -90,11 +90,16 @@ def start_mission(
response.status_code = HTTPStatus.INTERNAL_SERVER_ERROR.value
return

robot_capable: bool = is_robot_capable_of_mission(
robot_capable: bool
missing_functions: List[str]
(robot_capable, missing_functions) = is_robot_capable_of_mission(
mission=mission, robot_capabilities=robot_settings.CAPABILITIES
)
if not robot_capable:
errorMsg = "Bad Request - Robot is not capable of performing mission"
errorMsg = (
"Bad Request - Robot is not capable of performing mission. Missing functionalities: "
+ str(missing_functions)
)
self.logger.error(errorMsg)
response.status_code = HTTPStatus.BAD_REQUEST.value
return errorMsg
Expand Down
20 changes: 11 additions & 9 deletions src/isar/mission_planner/mission_validator.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from typing import List
from typing import List, Tuple

from isar.models.mission import Mission


def is_robot_capable_of_mission(
mission: Mission, robot_capabilities: List[str]
) -> bool:
return all(
[
step.type in robot_capabilities
for task in mission.tasks
for step in task.steps
]
)
) -> Tuple[bool, List[str]]:
success: bool = True
missing_capabilities: List[str] = []
for task in mission.tasks:
for step in task.steps:
if not step.type in robot_capabilities:
success = False
missing_capabilities.append(step.type)

return success, missing_capabilities
2 changes: 1 addition & 1 deletion tests/isar/mission_planner/test_mission_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
)
def test_is_robot_capable_of_mission(mission, capabilities, expected_return) -> None:
return_value: bool = is_robot_capable_of_mission(
return_value, missing_capabilities = is_robot_capable_of_mission(
mission=mission, robot_capabilities=capabilities
)
assert return_value == expected_return

0 comments on commit 237fc86

Please sign in to comment.