Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mock_uss/riddp] Expose aircraft_type through observation interface #864

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions monitoring/mock_uss/riddp/routes_observation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from uas_standards.interuss.automated_testing.rid.v1.observation import (
AltitudeReference,
MSLAltitude,
UAType,
)
from . import clustering, database, utm_client
from .behavior import DisplayProviderBehavior
Expand Down Expand Up @@ -79,6 +80,9 @@ def _make_flight_observation(
h.distance = limit_resolution(h.distance, MinHeightResolution)
return observation_api.Flight(
id=flight.id,
aircraft_type=flight.aircraft_type
if flight.aircraft_type
else UAType.NotDeclared,
most_recent_position=observation_api.Position(
lat=p.lat,
lng=p.lng,
Expand Down
17 changes: 17 additions & 0 deletions monitoring/monitorlib/fetch/rid.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,23 @@ def timestamp_accuracy(self) -> Optional[float]:
f"Cannot retrieve speed using RID version {self.rid_version}"
)

@property
def aircraft_type(
self,
) -> Optional[Union[v19.api.RIDAircraftType, v22a.api.UAType]]:
if self.rid_version == RIDVersion.f3411_19:
if not self.v19_value.has_field_with_value("aircraft_type"):
return None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer the current implementation (distinguishing "missing" from "explicitly NotDeclared"), but note that Optional could be dropped from the return type annotation if this returned NotDeclared instead of None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is the common 'fetch' lib that is not only used by the mock USS, indeed it is best keeping that implement as is. An upcoming PR will actually rely on this function returning None if the field is not present. So I will keep it as is and update the observation endpoint implementation.

return self.v19_value.aircraft_type
elif self.rid_version == RIDVersion.f3411_22a:
if not self.v22a_value.has_field_with_value("aircraft_type"):
return None
return self.v22a_value.aircraft_type
else:
raise NotImplementedError(
f"Cannot retrieve aircraft_type using RID version {self.rid_version}"
)

def errors(self) -> List[str]:
try:
rid_version = self.rid_version
Expand Down
Loading