From ceef7e7c72186f506d2a0be11ebfa954ee0f40c0 Mon Sep 17 00:00:00 2001 From: Julien Perrochet Date: Thu, 14 Nov 2024 16:47:28 +0100 Subject: [PATCH] comments --- .../astm/netrid/display_data_evaluator.py | 98 ++++++------------- 1 file changed, 31 insertions(+), 67 deletions(-) diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py b/monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py index dd220c46f8..4dbd043eee 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py @@ -1093,76 +1093,40 @@ def _evaluate_normal_sp_observation( details=f"Timestamp accuracy in Service Provider {mapping.injected_flight.uss_participant_id}'s response for flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} with telemetry index {mapping.telemetry_index} is {mapping.observed_flight.timestamp_accuracy} which is not equal to the injected value of {injected_telemetry.timestamp_accuracy}", ) - # height is an optional field. Evaluate only if present: - if "height" in observed_position: - with self._test_scenario.check("Service Provider height") as check: - if injected_position.height is not None: - # Injected data specifies a height, let's compare: - if ( - injected_position.height.reference.value - == observed_position.height.reference.value - ): - # if the reported height has the same type, compare values - if ( - abs( - injected_position.height.distance - - observed_position.height.distance - ) - > HEIGHT_PRECISION_M - ): - check.record_failed( - "Height reported by Service Provider does not match injected height", - details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had telemetry index {mapping.telemetry_index} at {injected_telemetry.timestamp} with height={injected_position.height.distance} {injected_position.height.reference.value}, but Service Provider reported height={observed_position.height.distance} {observed_position.height.reference.value} at {mapping.observed_flight.query.query.request.initiated_at}", - ) - # If the reported height has a different type, we will check for absurd values below - + if injected_position.height is not None: + # We injected a height so expect to observe one + if "height" not in observed_position: + check.record_failed( + "Injected height but none was returned in Service Provider response", + ) + else: if ( - injected_position.height is None - or injected_position.height.reference.value + injected_position.height.reference.value != observed_position.height.reference.value ): - # If the injected data does not specify a height or specifies a different type than the observed one, - # we only check for absurd values - if ( - observed_position.height.reference.value - == RIDHeightReference.GroundLevel - ): - if observed_position.height.distance > MAX_HEIGHT_M: - check.record_failed( - "Height above ground reported by Service Provider is unreasonably high and may indicate a bug", - details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had telemetry index {mapping.telemetry_index} at {injected_telemetry.timestamp} with height={injected_position.height.distance} {injected_position.height.reference.value}, which exceeds the maximum of {MAX_HEIGHT_M} at {mapping.observed_flight.query.query.request.initiated_at}", - ) - # Note: for v22a, -1000 is a special value indicating Invalid, No Value or Unknown, so we need to accept it. - if observed_position.height.distance < 0 and ( - observed_position.height.distance != -1000 - or self._rid_version == RIDVersion.f3411_19 - ): - check.record_failed( - "Height above ground reported by Service Provider is negative", - details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had telemetry index {mapping.telemetry_index} at {injected_telemetry.timestamp} with height={injected_position.height.distance} {injected_position.height.reference.value}, but Service Provider reported height={observed_position.height.distance} {observed_position.height.reference.value} at {mapping.observed_flight.query.query.request.initiated_at}", - ) - - elif ( - observed_position.height.reference.value - == RIDHeightReference.TakeoffLocation - ): - if observed_position.height.distance > MAX_HEIGHT_M: - check.record_failed( - "Height above takeoff location reported by Service Provider is unreasonably high and may indicate a bug", - details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had telemetry index {mapping.telemetry_index} at {injected_telemetry.timestamp} with height={injected_position.height.distance} {injected_position.height.reference.value}, which exceeds the maximum of {MAX_HEIGHT_M} at {mapping.observed_flight.query.query.request.initiated_at}", - ) - - # Relative to the takeoff location, negative values are acceptable (ie, flying off and down a mountain) - # and nothing in the standard explicitly forbids them. - if observed_position.height.distance < -MAX_HEIGHT_M: - check.record_failed( - "Height above takeoff location reported by Service Provider is unreasonably low and may indicate a bug", - details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had telemetry index {mapping.telemetry_index} at {injected_telemetry.timestamp} with height={injected_position.height.distance} {injected_position.height.reference.value}, which is below the minimum of {-MAX_HEIGHT_M} at {mapping.observed_flight.query.query.request.initiated_at}", - ) - else: - raise ValueError( - f"Unexpected height reference value: {observed_position.height.reference.value}" - ) + check.record_failed( + "Height reference reported by Service Provider does not match injected height reference", + details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had telemetry index {mapping.telemetry_index} at {injected_telemetry.timestamp} with height={injected_position.height.distance} {injected_position.height.reference.value}, but Service Provider reported height={observed_position.height.distance} {observed_position.height.reference.value} at {mapping.observed_flight.query.query.request.initiated_at}", + ) + if ( + abs( + injected_position.height.distance + - observed_position.height.distance + ) + > HEIGHT_PRECISION_M + ): + check.record_failed( + "Height reported by Service Provider does not match injected height", + details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had telemetry index {mapping.telemetry_index} at {injected_telemetry.timestamp} with height={injected_position.height.distance} {injected_position.height.reference.value}, but Service Provider reported height={observed_position.height.distance} {observed_position.height.reference.value} at {mapping.observed_flight.query.query.request.initiated_at}", + ) + else: + # We did not inject a height, but a height returning the magic 'unknown' value would still be seen as valid + if "height" in observed_position: + if not math.isclose(observed_position.height.distance, -1000, abs_tol=1): + check.record_failed( + "Injected no height, but Service Provider reported a height", + details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had no height injected, but Service Provider reported height={observed_position.height.distance} {observed_position.height.reference.value} at {mapping.observed_flight.query.query.request.initiated_at}", + ) # Verify that flight details queries succeeded and returned correctly-formatted data for mapping in mappings.values():