Skip to content

Commit 579cbf9

Browse files
committed
fix(av2): update av2 func missing in old version.
read_ego_SE3_sensor docs(git): cuda build files
1 parent 2bd9036 commit 579cbf9

3 files changed

Lines changed: 66 additions & 3 deletions

File tree

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ cancel.sh
2020

2121
# figure
2222
*.png
23-
*.pdf
23+
*.pdf
24+
25+
# cuda build files
26+
*.egg-info
27+
build*
28+
dist*

dataprocess/extract_av2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from av2.datasets.sensor.av2_sensor_dataloader import convert_pose_dataframe_to_SE3
1919
from av2.structures.sweep import Sweep
2020
from av2.structures.cuboid import CuboidList, Cuboid
21-
from av2.utils.io import read_feather, io_utils
21+
from av2.utils.io import read_feather
2222
from av2.map.map_api import ArgoverseStaticMap
2323
from av2.geometry.se3 import SE3
2424
from av2.datasets.sensor.constants import AnnotationCategories
@@ -39,6 +39,7 @@
3939
BASE_DIR = os.path.abspath(os.path.join( os.path.dirname( __file__ ), '..' ))
4040
sys.path.append(BASE_DIR)
4141
from dataprocess.misc_data import create_reading_index
42+
from scripts.utils.av2_eval import read_ego_SE3_sensor
4243

4344
BOUNDING_BOX_EXPANSION: Final = 0.2
4445
CATEGORY_TO_INDEX: Final = {
@@ -84,7 +85,7 @@ def create_eval_mask(data_mode: str, output_dir_: Path, mask_dir: str):
8485
def read_pose_pc_ground(data_dir: Path, log_id: str, timestamp: int, avm: ArgoverseStaticMap):
8586
log_poses_df = read_feather(data_dir / log_id / "city_SE3_egovehicle.feather")
8687
# more detail: https://argoverse.github.io/user-guide/datasets/lidar.html#sensor-suite
87-
ego2sensor_pose = io_utils.read_ego_SE3_sensor((data_dir / log_id))['up_lidar']
88+
ego2sensor_pose = read_ego_SE3_sensor((data_dir / log_id))['up_lidar']
8889
filtered_log_poses_df = log_poses_df[log_poses_df["timestamp_ns"].isin([timestamp])]
8990
pose = convert_pose_dataframe_to_SE3(filtered_log_poses_df.loc[filtered_log_poses_df["timestamp_ns"] == timestamp])
9091
pc = Sweep.from_feather(data_dir / log_id / "sensors" / "lidar" / f"{timestamp}.feather").xyz

scripts/utils/av2_eval.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,63 @@
7474
"OTHER_VEHICLES": OTHER_VEHICLES,
7575
}
7676

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+
77134
@unique
78135
class SceneFlowMetricType(str, Enum):
79136
"""Scene Flow metrics."""

0 commit comments

Comments
 (0)