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

feat: add support of rendering geocoordinate #49

Merged
merged 1 commit into from
Nov 21, 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
6 changes: 3 additions & 3 deletions t4_devkit/schema/tables/ego_pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ class EgoPose(SchemaBase):
translation: TranslationType = field(converter=np.asarray)
rotation: RotationType = field(converter=as_quaternion)
timestamp: int
twist: TwistType = field(
twist: TwistType | None = field(
default=None, converter=lambda x: np.asarray(x) if x is not None else x
)
acceleration: AccelerationType = field(
acceleration: AccelerationType | None = field(
default=None, converter=lambda x: np.asarray(x) if x is not None else x
)
geocoordinate: GeoCoordinateType = field(
geocoordinate: GeoCoordinateType | None = field(
default=None, converter=lambda x: np.asarray(x) if x is not None else x
)
43 changes: 37 additions & 6 deletions t4_devkit/viewer/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

from t4_devkit.common.timestamp import us2sec
from t4_devkit.schema import CalibratedSensor, EgoPose, Sensor, SensorModality
from t4_devkit.typing import CamIntrinsicType, NDArrayU8, RotationType, TranslationType
from t4_devkit.typing import (
CamIntrinsicType,
GeoCoordinateType,
NDArrayU8,
RotationType,
TranslationType,
)

from .color import distance_color
from .rendering_data import BoxData2D, BoxData3D, SegmentationData2D
Expand Down Expand Up @@ -59,6 +65,7 @@ class Tier4Viewer:
# entity paths
map_entity = "map"
ego_entity = "map/base_link"
geocoordinate_entity = "geocoordinate"
timeline = "timestamp"

def __init__(
Expand Down Expand Up @@ -95,11 +102,14 @@ def __init__(

view_container = []
if not without_3d:
view_container.append(
rrb.Horizontal(
rrb.Spatial3DView(name="3D", origin=self.map_entity),
column_shares=[3, 1],
)
view_container.extend(
[
rrb.Horizontal(
rrb.Spatial3DView(name="3D", origin=self.map_entity),
rrb.Horizontal(rrb.MapView(name="Map", origin=self.geocoordinate_entity)),
column_shares=[3, 1],
),
]
)

if self.cameras is not None:
Expand Down Expand Up @@ -308,12 +318,20 @@ def _render_ego_with_schema(self, ego_pose: EgoPose) -> None:
),
)

if ego_pose.geocoordinate is not None:
latitude, longitude, _ = ego_pose.geocoordinate
rr.log(
self.geocoordinate_entity,
rr.GeoPoints(lat_lon=(latitude, longitude), radii=rr.Radius.ui_points(10.0)),
)

@render_ego.register
def _render_ego_without_schema(
self,
seconds: float,
translation: TranslationType,
rotation: RotationType,
geocoordinate: GeoCoordinateType | None = None,
) -> None:
rr.set_time_seconds(self.timeline, seconds)

Expand All @@ -327,6 +345,13 @@ def _render_ego_without_schema(
),
)

if geocoordinate is not None:
latitude, longitude, _ = geocoordinate
rr.log(
self.geocoordinate_entity,
rr.GeoPoints(lat_lon=(latitude, longitude)),
)

@singledispatchmethod
def render_calibration(self, *args, **kwargs) -> None:
raise TypeError("Unexpected parameter types.")
Expand Down Expand Up @@ -394,3 +419,9 @@ def _render_calibration_without_schema(
rr.Pinhole(image_from_camera=camera_intrinsic),
static=True,
)
if modality == SensorModality.CAMERA:
rr.log(
format_entity(self.ego_entity, channel),
rr.Pinhole(image_from_camera=camera_intrinsic),
static=True,
)
Loading