-
Notifications
You must be signed in to change notification settings - Fork 4
fix: resolve input types of viewer #187
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,10 @@ | |
| import rerun.blueprint as rrb | ||
| from typing_extensions import Self | ||
|
|
||
| from t4_devkit.common.converter import to_quaternion | ||
|
||
| from t4_devkit.common.timestamp import us2sec | ||
| from t4_devkit.lanelet import LaneletParser | ||
| from t4_devkit.schema import SensorModality | ||
| from t4_devkit.typing import Quaternion, Roi, Vector3 | ||
|
|
||
| from .color import distance_color | ||
| from .geography import calculate_geodetic_point | ||
|
|
@@ -27,7 +27,7 @@ | |
| if TYPE_CHECKING: | ||
| from t4_devkit.dataclass import Box2D, Box3D, Future, PointCloudLike | ||
| from t4_devkit.schema import CalibratedSensor, EgoPose, Sensor | ||
| from t4_devkit.typing import CamIntrinsicLike, NDArrayU8 | ||
| from t4_devkit.typing import CamIntrinsicLike, NDArrayU8, RoiLike, RotationLike, Vector3Like | ||
|
|
||
| __all__ = ["RerunViewer", "format_entity"] | ||
|
|
||
|
|
@@ -214,23 +214,23 @@ def render_box3ds(self, seconds: float, boxes: Sequence[Box3D]) -> None: | |
| def render_box3ds( | ||
| self, | ||
| seconds: float, | ||
| centers: Sequence[Vector3], | ||
| rotations: Sequence[Quaternion], | ||
| sizes: Sequence[Vector3], | ||
| centers: Sequence[Vector3Like], | ||
| rotations: Sequence[RotationLike], | ||
| sizes: Sequence[Vector3Like], | ||
| class_ids: Sequence[int], | ||
| velocities: Sequence[Vector3] | None = None, | ||
| velocities: Sequence[Vector3Like] | None = None, | ||
| uuids: Sequence[str] | None = None, | ||
| futures: Sequence[Future] | None = None, | ||
| ) -> None: | ||
| """Render 3D boxes with its elements. | ||
|
|
||
| Args: | ||
| seconds (float): Timestamp in [sec]. | ||
| centers (Sequence[Vector3]): Sequence of 3D positions in the order of (x, y, z). | ||
| rotations (Sequence[Quaternion]): Sequence of quaternions. | ||
| sizes (Sequence[Vector3]): Sequence of box sizes in the order of (width, length, height). | ||
| centers (Sequence[Vector3Like]): Sequence of 3D positions in the order of (x, y, z). | ||
| rotations (Sequence[RotationLike]): Sequence of rotations. | ||
| sizes (Sequence[Vector3Like]): Sequence of box sizes in the order of (width, length, height). | ||
| class_ids (Sequence[int]): Sequence of class IDs. | ||
| velocities (Sequence[Vector3] | None, optional): Sequence of velocities. | ||
| velocities (Sequence[Vector3Like] | None, optional): Sequence of velocities. | ||
| uuids (Sequence[str] | None, optional): Sequence of unique identifiers. | ||
| futures (Sequence[Future] | None, optional): Sequence future trajectories. | ||
| """ | ||
|
|
@@ -276,11 +276,11 @@ def _render_box3ds_with_boxes(self, seconds: float, boxes: Sequence[Box3D]) -> N | |
| def _render_box3ds_with_elements( | ||
| self, | ||
| seconds: float, | ||
| centers: Sequence[Vector3], | ||
| rotations: Sequence[Quaternion], | ||
| sizes: Sequence[Vector3], | ||
| centers: Sequence[Vector3Like], | ||
| rotations: Sequence[RotationLike], | ||
| sizes: Sequence[Vector3Like], | ||
| class_ids: Sequence[int], | ||
| velocities: Sequence[Vector3] | None = None, | ||
| velocities: Sequence[Vector3Like] | None = None, | ||
| uuids: Sequence[str] | None | None = None, | ||
| futures: Sequence[Future] | None = None, | ||
| ) -> None: | ||
|
|
@@ -346,7 +346,7 @@ def render_box2ds( | |
| self, | ||
| seconds: float, | ||
| camera: str, | ||
| rois: Sequence[Roi], | ||
| rois: Sequence[RoiLike], | ||
| class_ids: Sequence[int], | ||
| uuids: Sequence[str] | None = None, | ||
| ) -> None: | ||
|
|
@@ -355,7 +355,7 @@ def render_box2ds( | |
| Args: | ||
| seconds (float): Timestamp in [sec]. | ||
| camera (str): Camera name. | ||
| rois (Sequence[Roi]): Sequence of ROIs in the order of (xmin, ymin, xmax, ymax). | ||
| rois (Sequence[RoiLike]): Sequence of ROIs in the order of (xmin, ymin, xmax, ymax). | ||
| class_ids (Sequence[int]): Sequence of class IDs. | ||
| uuids (Sequence[str] | None, optional): Sequence of unique identifiers. | ||
| """ | ||
|
|
@@ -391,7 +391,7 @@ def _render_box2ds_with_elements( | |
| self, | ||
| seconds: float, | ||
| camera: str, | ||
| rois: Sequence[Roi], | ||
| rois: Sequence[RoiLike], | ||
| class_ids: Sequence[int], | ||
| uuids: Sequence[str] | None = None, | ||
| ) -> None: | ||
|
|
@@ -496,18 +496,18 @@ def render_ego(self, ego_pose: EgoPose) -> None: | |
| def render_ego( | ||
| self, | ||
| seconds: float, | ||
| translation: Vector3, | ||
| rotation: Quaternion, | ||
| geocoordinate: Vector3 | None = None, | ||
| translation: Vector3Like, | ||
| rotation: RotationLike, | ||
| geocoordinate: Vector3Like | None = None, | ||
| ) -> None: | ||
| """Render an ego pose. | ||
|
|
||
| Args: | ||
| seconds (float): Timestamp in [sec]. | ||
| translation (Vector3): 3D position in the map coordinate system | ||
| translation (Vector3Like): 3D position in the map coordinate system | ||
| , in the order of (x, y, z) in [m]. | ||
| rotation (Quaternion): Rotation in the map coordinate system. | ||
| geocoordinate (Vector3 | None, optional): Coordinates in the WGS 84 | ||
| rotation (RotationLike): Rotation in the map coordinate system. | ||
| geocoordinate (Vector3Like | None, optional): Coordinates in the WGS 84 | ||
| reference ellipsoid (latitude, longitude, altitude) in degrees and meters. | ||
| """ | ||
| pass | ||
|
|
@@ -530,18 +530,17 @@ def _render_ego_with_schema(self, ego_pose: EgoPose) -> None: | |
| def _render_ego_without_schema( | ||
| self, | ||
| seconds: float, | ||
| translation: Vector3, | ||
| rotation: Quaternion, | ||
| geocoordinate: Vector3 | None = None, | ||
| translation: Vector3Like, | ||
| rotation: RotationLike, | ||
| geocoordinate: Vector3Like | None = None, | ||
| ) -> None: | ||
| rr.set_time_seconds(self.timeline, seconds) | ||
|
|
||
| rotation_xyzw = np.roll(rotation.q, shift=-1) | ||
| rr.log( | ||
| self.ego_entity, | ||
| rr.Transform3D( | ||
| translation=translation, | ||
| rotation=rr.Quaternion(xyzw=rotation_xyzw), | ||
| rotation=_to_rerun_quaternion(rotation), | ||
| relation=rr.TransformRelation.ParentFromChild, | ||
| ), | ||
| ) | ||
|
|
@@ -578,17 +577,17 @@ def render_calibration( | |
| self, | ||
| channel: str, | ||
| modality: str | SensorModality, | ||
| translation: Vector3, | ||
| rotation: Quaternion, | ||
| translation: Vector3Like, | ||
| rotation: RotationLike, | ||
| camera_intrinsic: CamIntrinsicLike | None = None, | ||
| ) -> None: | ||
| """Render a sensor calibration. | ||
|
|
||
| Args: | ||
| channel (str): Name of the sensor channel. | ||
| modality (str | SensorModality): Sensor modality. | ||
| translation (Vector3): Sensor translation in ego centric coords. | ||
| rotation (Quaternion): Sensor rotation in ego centric coords. | ||
| translation (Vector3Like): Sensor translation in ego centric coords. | ||
| rotation (RotationLike): Sensor rotation in ego centric coords. | ||
| camera_intrinsic (CamIntrinsicLike | None, optional): Camera intrinsic matrix. | ||
| Defaults to None. | ||
| """ | ||
|
|
@@ -618,25 +617,23 @@ def _render_calibration_without_schema( | |
| self, | ||
| channel: str, | ||
| modality: str | SensorModality, | ||
| translation: Vector3, | ||
| rotation: Quaternion, | ||
| translation: Vector3Like, | ||
| rotation: RotationLike, | ||
| camera_intrinsic: CamIntrinsicLike | None = None, | ||
| ) -> None: | ||
| """Render a sensor calibration. | ||
|
|
||
| Args: | ||
| channel (str): Name of the sensor channel. | ||
| modality (str | SensorModality): Sensor modality. | ||
| translation (Vector3): Sensor translation in ego centric coords. | ||
| rotation (Quaternion): Sensor rotation in ego centric coords. | ||
| translation (Vector3Like): Sensor translation in ego centric coords. | ||
| rotation (RotationLike): Sensor rotation in ego centric coords. | ||
| camera_intrinsic (CamIntrinsicLike | None, optional): Camera intrinsic matrix. | ||
| Defaults to None. | ||
| """ | ||
| rotation_xyzw = np.roll(rotation.q, shift=-1) | ||
|
|
||
| rr.log( | ||
| format_entity(self.ego_entity, channel), | ||
| rr.Transform3D(translation=translation, rotation=rr.Quaternion(xyzw=rotation_xyzw)), | ||
| rr.Transform3D(translation=translation, rotation=_to_rerun_quaternion(rotation)), | ||
| static=True, | ||
| ) | ||
|
|
||
|
|
@@ -661,3 +658,8 @@ def render_map(self, filepath: str) -> None: | |
| render_ways(parser, root_entity) | ||
|
|
||
| render_geographic_borders(parser, f"{self.geocoordinate_entity}/vector_map") | ||
|
|
||
|
|
||
| def _to_rerun_quaternion(rotation: RotationLike) -> rr.Quaternion: | ||
| rotation_xyzw = np.roll(to_quaternion(rotation).q, shift=-1) | ||
| return rr.Quaternion(xyzw=rotation_xyzw) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import statement is missing the removal of unused imports. Since concrete types are replaced with generic types, imports like
RoiandVector3from line 12 may no longer be needed if they're only used for type annotations that are now using*Liketypes.