diff --git a/src/isar_exr/api/energy_robotics_api.py b/src/isar_exr/api/energy_robotics_api.py index fcb20af..9cdd15c 100644 --- a/src/isar_exr/api/energy_robotics_api.py +++ b/src/isar_exr/api/energy_robotics_api.py @@ -593,7 +593,13 @@ def get_battery_level(self, exr_robot_id: str) -> Optional[float]: error_description=message, ) - if not result["currentRobotStatus"]["isConnected"]: + if result["currentRobotStatus"]["isConnected"] == None: + return None + + if ( + result["currentRobotStatus"]["batteryStatus"] == None + or result["currentRobotStatus"]["batteryStatus"]["percentage"] == None + ): return None battery_level: float = result["currentRobotStatus"]["batteryStatus"][ diff --git a/src/isar_exr/api/graphql_client.py b/src/isar_exr/api/graphql_client.py index 7c31f63..5152105 100644 --- a/src/isar_exr/api/graphql_client.py +++ b/src/isar_exr/api/graphql_client.py @@ -58,7 +58,7 @@ def _initialize_session(self) -> None: schema: GraphQLSchema = build_ast_schema(self.document) transport: HTTPXTransport = HTTPXTransport( - url=settings.ROBOT_API_URL, headers=auth_header + url=settings.ROBOT_API_URL, headers=auth_header, timeout=30 ) self.client: Client = Client(transport=transport, schema=schema) # type: ignore self.schema: DSLSchema = DSLSchema(self.client.schema) @@ -104,7 +104,7 @@ def query( self.logger.error("The connection to the GraphQL endpoint is closed") raise except TransportServerError as e: - if e.code == 302: + if e.code == 302 or e.code == 401: if self._reauthenticated: self.logger.error( "Transport server error - Error in Energy Robotics server even after reauthentication" diff --git a/src/isar_exr/robotinterface.py b/src/isar_exr/robotinterface.py index 9489b13..c87a39c 100644 --- a/src/isar_exr/robotinterface.py +++ b/src/isar_exr/robotinterface.py @@ -115,7 +115,9 @@ def update_site_with_tasks( robot_pose: Pose = step.pose if isinstance(step, InspectionStep): is_possible_return_to_home_mission = False - customer_tag: str = task.tag_id + "|" + str(robot_pose) + customer_tag: str = ( + task.tag_id + "|" + str(robot_pose) + "|" + str(step.target) + ) existing_poi_id = ( self.api.get_point_of_interest_by_customer_tag( customer_tag=customer_tag, @@ -241,7 +243,7 @@ def step_status(self) -> StepStatus: step_status: StepStatus = ExrStepStatus(mission_status).to_step_status() except NoMissionRunningException: # This is a temporary solution until we have mission status by mission id - return MissionStatus.Successful + return StepStatus.Successful except Exception as e: message: str = "Could not get status of running mission\n" self.logger.error(message)