Skip to content

Commit

Permalink
[mock_uss/ridsp] Expose aircraft_type through observation interface (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mickmis authored Dec 10, 2024
1 parent 8561824 commit 9b8372b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 2 additions & 1 deletion monitoring/mock_uss/ridsp/routes_ridsp_v19.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from uas_standards.interuss.automated_testing.rid.v1 import injection

from monitoring.monitorlib import geo
from monitoring.monitorlib.rid import RIDVersion
from monitoring.monitorlib.rid_automated_testing.injection_api import TestFlight
from monitoring.mock_uss import webapp
from monitoring.mock_uss.auth import requires_scope
Expand Down Expand Up @@ -70,7 +71,7 @@ def _get_report(
recent_states.sort(key=lambda p: p.timestamp)
result = RIDFlight(
id=details.id,
aircraft_type="NotDeclared", # TODO: Include aircraft_type in TestFlight API
aircraft_type=flight.get_aircraft_type(RIDVersion.f3411_19),
current_state=_make_state(recent_states[-1]),
simulated=True,
)
Expand Down
6 changes: 3 additions & 3 deletions monitoring/mock_uss/ridsp/routes_ridsp_v22a.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
from uas_standards.interuss.automated_testing.rid.v1 import injection

from monitoring.monitorlib import geo
from monitoring.monitorlib.rid import RIDVersion
from monitoring.monitorlib.rid_automated_testing.injection_api import TestFlight
from monitoring.monitorlib.rid_v2 import make_time
from monitoring.mock_uss import webapp
from monitoring.mock_uss.auth import requires_scope
from . import behavior
from .database import db
from ...monitorlib.rid_v2 import make_time


def _make_position(p: injection.RIDAircraftPosition) -> RIDAircraftPosition:
Expand Down Expand Up @@ -124,7 +124,7 @@ def _get_report(
recent_states.sort(key=lambda p: p.timestamp)
result = RIDFlight(
id=details.id,
aircraft_type="NotDeclared", # TODO: Include aircraft_type in TestFlight API
aircraft_type=flight.get_aircraft_type(RIDVersion.f3411_22a),
current_state=_make_state(recent_states[-1]),
simulated=True,
)
Expand Down
18 changes: 18 additions & 0 deletions monitoring/monitorlib/rid_automated_testing/injection_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
from uas_standards.interuss.automated_testing.rid.v1.injection import (
RIDFlightDetails,
RIDAircraftState,
UAType,
)

from monitoring.monitorlib.rid import RIDVersion

SCOPE_RID_QUALIFIER_INJECT = "rid.inject_test_data"


Expand Down Expand Up @@ -50,6 +53,21 @@ def get_id(self, t_now: datetime.datetime) -> Optional[str]:
details = self.get_details(t_now)
return details.id if details else None

def get_aircraft_type(self, rid_version: RIDVersion) -> UAType:
if not self.has_field_with_value("aircraft_type"):
return UAType.NotDeclared

# there exists a small difference in the enums between both versions of RID, this ensures we always return the expected one
if (
rid_version == RIDVersion.f3411_19
and self.aircraft_type == UAType.HybridLift
):
return UAType.VTOL
if rid_version == RIDVersion.f3411_22a and self.aircraft_type == UAType.VTOL:
return UAType.HybridLift

return self.aircraft_type

def order_telemetry(self):
self.telemetry = sorted(
self.telemetry, key=lambda telemetry: telemetry.timestamp.datetime
Expand Down

0 comments on commit 9b8372b

Please sign in to comment.