|
74 | 74 | "OTHER_VEHICLES": OTHER_VEHICLES, |
75 | 75 | } |
76 | 76 |
|
| 77 | +import av2.geometry.geometry as geometry_utils |
| 78 | +from av2.geometry.se3 import SE3 |
| 79 | +from av2.utils.typing import NDArrayFloat |
| 80 | +from av2.utils.io import read_feather |
| 81 | + |
| 82 | +# Mapping from egovehicle time in nanoseconds to egovehicle pose. |
| 83 | +TimestampedCitySE3EgoPoses = Dict[int, SE3] |
| 84 | + |
| 85 | +# Mapping from sensor name to sensor pose. |
| 86 | +SensorPosesMapping = Dict[str, SE3] |
| 87 | + |
| 88 | +def read_ego_SE3_sensor(log_dir: Path) -> SensorPosesMapping: |
| 89 | + """Read the sensor poses for the given log. |
| 90 | +
|
| 91 | + The sensor pose defines an SE3 transformation from the sensor reference frame to the egovehicle reference frame. |
| 92 | + Mathematically we define this transformation as: $$ego_SE3_sensor$$. |
| 93 | +
|
| 94 | + In other words, when this transformation is applied to a set of points in the sensor reference frame, they |
| 95 | + will be transformed to the egovehicle reference frame. |
| 96 | +
|
| 97 | + Example (1). |
| 98 | + points_ego = ego_SE3_sensor(points_sensor) apply the SE3 transformation to points in the sensor reference frame. |
| 99 | +
|
| 100 | + Example (2). |
| 101 | + sensor_SE3_ego = ego_SE3_sensor^{-1} take the inverse of the SE3 transformation. |
| 102 | + points_sensor = sensor_SE3_ego(points_ego) apply the SE3 transformation to points in the ego reference frame. |
| 103 | +
|
| 104 | + Extrinsics: |
| 105 | + sensor_name: Name of the sensor. |
| 106 | + qw: scalar component of a quaternion. |
| 107 | + qx: X-axis coefficient of a quaternion. |
| 108 | + qy: Y-axis coefficient of a quaternion. |
| 109 | + qz: Z-axis coefficient of a quaternion. |
| 110 | + tx_m: X-axis translation component. |
| 111 | + ty_m: Y-axis translation component. |
| 112 | + tz_m: Z-axis translation component. |
| 113 | +
|
| 114 | + Args: |
| 115 | + log_dir: Path to the log directory. |
| 116 | +
|
| 117 | + Returns: |
| 118 | + Mapping from sensor name to sensor pose. |
| 119 | + """ |
| 120 | + ego_SE3_sensor_path = Path(log_dir, "calibration", "egovehicle_SE3_sensor.feather") |
| 121 | + ego_SE3_sensor = read_feather(ego_SE3_sensor_path) |
| 122 | + rotations = geometry_utils.quat_to_mat( |
| 123 | + ego_SE3_sensor.loc[:, ["qw", "qx", "qy", "qz"]].to_numpy() |
| 124 | + ) |
| 125 | + translations = ego_SE3_sensor.loc[:, ["tx_m", "ty_m", "tz_m"]].to_numpy() |
| 126 | + sensor_names = ego_SE3_sensor.loc[:, "sensor_name"].to_numpy() |
| 127 | + |
| 128 | + sensor_name_to_pose: SensorPosesMapping = { |
| 129 | + name: SE3(rotation=rotations[i], translation=translations[i]) |
| 130 | + for i, name in enumerate(sensor_names) |
| 131 | + } |
| 132 | + return sensor_name_to_pose |
| 133 | + |
77 | 134 | @unique |
78 | 135 | class SceneFlowMetricType(str, Enum): |
79 | 136 | """Scene Flow metrics.""" |
|
0 commit comments