Skip to content

Commit b873ddc

Browse files
ewhitmiremeta-codesync[bot]
authored andcommitted
Migrate projectaria_tools to Rerun 0.26.2 API (#327)
Summary: Pull Request resolved: #327 Pull Request resolved: #326 X-link: facebookresearch/projectaria_gen2_pilot_dataset#5 Part of a repo-wide upgrade of the Rerun visualization SDK from 0.22.1 to 0.26.2. Rerun 0.26.2 introduces a unified `rr.set_time()` API, renames several archetypes to plural forms, and moves from TCP to gRPC transport. This diff migrates aria_data_plotter.py (the core Aria rerun viewer). Key API changes applied: - `rr.set_time_nanos` → `rr.set_time("device_time", timestamp=ns * 1e-9)` - `rr.TimeNanosColumn` → `rr.TimeColumn("device_time", timestamp=...)` - `rr.Scalar` → `rr.Scalars` Reviewed By: YLouWashU Differential Revision: D94047679 fbshipit-source-id: c549e3ed647298e765c9f1b2d62779ad341ae3f9
1 parent 6085de9 commit b873ddc

6 files changed

Lines changed: 54 additions & 47 deletions

File tree

projectaria_tools/tools/aria_rerun_viewer/aria_data_plotter.py

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def plot_image(self, frame, label, device_timestamp_ns):
622622
f"Frame is not a numpy array for label {label}",
623623
)
624624
return
625-
rr.set_time_nanos("device_time", device_timestamp_ns)
625+
rr.set_time("device_time", timestamp=device_timestamp_ns * 1e-9)
626626
frame = self._check_and_rotate_image_for_gen1(frame, label)
627627
rr.log(
628628
label,
@@ -655,34 +655,34 @@ def plot_imu_batch_vectorized(self, imu_data_list, label):
655655
# Log accelerometer data
656656
rr.send_columns(
657657
f"{label}/accl/x[m-sec2]",
658-
indexes=[rr.TimeNanosColumn("device_time", timestamps)],
658+
indexes=[rr.TimeColumn("device_time", timestamp=timestamps * 1e-9)],
659659
columns=[rr.components.ScalarBatch(accel_data[:, 0])],
660660
)
661661
rr.send_columns(
662662
f"{label}/accl/y[m-sec2]",
663-
indexes=[rr.TimeNanosColumn("device_time", timestamps)],
663+
indexes=[rr.TimeColumn("device_time", timestamp=timestamps * 1e-9)],
664664
columns=[rr.components.ScalarBatch(accel_data[:, 1])],
665665
)
666666
rr.send_columns(
667667
f"{label}/accl/z[m-sec2]",
668-
indexes=[rr.TimeNanosColumn("device_time", timestamps)],
668+
indexes=[rr.TimeColumn("device_time", timestamp=timestamps * 1e-9)],
669669
columns=[rr.components.ScalarBatch(accel_data[:, 2])],
670670
)
671671

672672
# Log gyroscope data
673673
rr.send_columns(
674674
f"{label}/gyro/x[rad-sec]",
675-
indexes=[rr.TimeNanosColumn("device_time", timestamps)],
675+
indexes=[rr.TimeColumn("device_time", timestamp=timestamps * 1e-9)],
676676
columns=[rr.components.ScalarBatch(gyro_data[:, 0])],
677677
)
678678
rr.send_columns(
679679
f"{label}/gyro/y[rad-sec]",
680-
indexes=[rr.TimeNanosColumn("device_time", timestamps)],
680+
indexes=[rr.TimeColumn("device_time", timestamp=timestamps * 1e-9)],
681681
columns=[rr.components.ScalarBatch(gyro_data[:, 1])],
682682
)
683683
rr.send_columns(
684684
f"{label}/gyro/z[rad-sec]",
685-
indexes=[rr.TimeNanosColumn("device_time", timestamps)],
685+
indexes=[rr.TimeColumn("device_time", timestamp=timestamps * 1e-9)],
686686
columns=[rr.components.ScalarBatch(gyro_data[:, 2])],
687687
)
688688

@@ -701,13 +701,13 @@ def plot_imu(self, imu_data, label):
701701
f"IMU data missing required attributes for label {label}",
702702
)
703703
return
704-
rr.set_time_nanos("device_time", imu_data.capture_timestamp_ns)
705-
rr.log(f"{label}/accl/x[m-sec2]", rr.Scalar(imu_data.accel_msec2[0]))
706-
rr.log(f"{label}/accl/y[m-sec2]", rr.Scalar(imu_data.accel_msec2[1]))
707-
rr.log(f"{label}/accl/z[m-sec2]", rr.Scalar(imu_data.accel_msec2[2]))
708-
rr.log(f"{label}/gyro/x[rad-sec]", rr.Scalar(imu_data.gyro_radsec[0]))
709-
rr.log(f"{label}/gyro/y[rad-sec]", rr.Scalar(imu_data.gyro_radsec[1]))
710-
rr.log(f"{label}/gyro/z[rad-sec]", rr.Scalar(imu_data.gyro_radsec[2]))
704+
rr.set_time("device_time", timestamp=imu_data.capture_timestamp_ns * 1e-9)
705+
rr.log(f"{label}/accl/x[m-sec2]", rr.Scalars(imu_data.accel_msec2[0]))
706+
rr.log(f"{label}/accl/y[m-sec2]", rr.Scalars(imu_data.accel_msec2[1]))
707+
rr.log(f"{label}/accl/z[m-sec2]", rr.Scalars(imu_data.accel_msec2[2]))
708+
rr.log(f"{label}/gyro/x[rad-sec]", rr.Scalars(imu_data.gyro_radsec[0]))
709+
rr.log(f"{label}/gyro/y[rad-sec]", rr.Scalars(imu_data.gyro_radsec[1]))
710+
rr.log(f"{label}/gyro/z[rad-sec]", rr.Scalars(imu_data.gyro_radsec[2]))
711711

712712
def plot_magnetometer(self, magnetometer_data):
713713
"""Plot magnetometer sensor data."""
@@ -725,19 +725,21 @@ def plot_magnetometer(self, magnetometer_data):
725725
)
726726
return
727727

728-
rr.set_time_nanos("device_time", magnetometer_data.capture_timestamp_ns)
728+
rr.set_time(
729+
"device_time", timestamp=magnetometer_data.capture_timestamp_ns * 1e-9
730+
)
729731
# Convert magnetometer reading from tesla (SI unit) to microtesla (µT): 1 tesla = 1e6 microtesla
730732
rr.log(
731733
f"{self.sensor_labels.magnetometer_label}/x[µT]",
732-
rr.Scalar(magnetometer_data.mag_tesla[0] * 1e6),
734+
rr.Scalars(magnetometer_data.mag_tesla[0] * 1e6),
733735
)
734736
rr.log(
735737
f"{self.sensor_labels.magnetometer_label}/y[µT]",
736-
rr.Scalar(magnetometer_data.mag_tesla[1] * 1e6),
738+
rr.Scalars(magnetometer_data.mag_tesla[1] * 1e6),
737739
)
738740
rr.log(
739741
f"{self.sensor_labels.magnetometer_label}/z[µT]",
740-
rr.Scalar(magnetometer_data.mag_tesla[2] * 1e6),
742+
rr.Scalars(magnetometer_data.mag_tesla[2] * 1e6),
741743
)
742744

743745
def plot_barometer(self, barometer_data):
@@ -757,15 +759,15 @@ def plot_barometer(self, barometer_data):
757759
"Barometer data missing required attributes",
758760
)
759761
return
760-
rr.set_time_nanos("device_time", barometer_data.capture_timestamp_ns)
762+
rr.set_time("device_time", timestamp=barometer_data.capture_timestamp_ns * 1e-9)
761763
# Convert pressure from pascal (SI unit) to kilopascal (kPa): 1 pascal = 1e-3 kilopascal
762764
rr.log(
763765
f"{self.sensor_labels.barometer_labels[0]}/pressure[kPa]",
764-
rr.Scalar(barometer_data.pressure * 1e-3),
766+
rr.Scalars(barometer_data.pressure * 1e-3),
765767
) # Pascals converter to kPascals
766768
rr.log(
767769
f"{self.sensor_labels.barometer_labels[1]}/temperature[Celsius]",
768-
rr.Scalar(barometer_data.temperature),
770+
rr.Scalars(barometer_data.temperature),
769771
) # Degree Celsius
770772

771773
def _plot_audio_from_selected_channels(
@@ -804,9 +806,12 @@ def _plot_audio_from_selected_channels(
804806
rr.send_columns(
805807
f"{rerun_plotter_label}/{selected_channel_labels[c]}",
806808
indexes=[
807-
rr.TimeNanosColumn(
809+
rr.TimeColumn(
808810
"device_time",
809-
audio_data_timestamp[:: self.config.audio_subsample_rate],
811+
timestamp=np.array(audio_data_timestamp)[
812+
:: self.config.audio_subsample_rate
813+
]
814+
* 1e-9,
810815
)
811816
],
812817
columns=[
@@ -885,7 +890,7 @@ def plot_gps(self, gps_data):
885890
)
886891
return
887892

888-
rr.set_time_nanos("device_time", gps_data.capture_timestamp_ns)
893+
rr.set_time("device_time", timestamp=gps_data.capture_timestamp_ns * 1e-9)
889894
# gps_data.provider is a string that can be "APP" or "GPS", indicating data source.
890895
gps_settings = self.PLOT_COLORS_AND_SIZES_2D[
891896
"gps_app"
@@ -912,8 +917,8 @@ def plot_eye_gaze_data(self, eyegaze_data):
912917
"device_calibration is None. Cannot plot eye gaze data.",
913918
)
914919
return
915-
rr.set_time_nanos(
916-
"device_time", int(eyegaze_data.tracking_timestamp.total_seconds() * 1e9)
920+
rr.set_time(
921+
"device_time", timestamp=eyegaze_data.tracking_timestamp.total_seconds()
917922
)
918923
# Clear the canvas (only if eye_gaze_label exists for this device version)
919924
if self.sensor_labels.eye_gaze_label:
@@ -1013,7 +1018,7 @@ def plot_fixation_crop_data(self, fixation_crop_data) -> None:
10131018
device_timestamp_ns = image_data[1].capture_timestamp_ns
10141019
camera_label = "camera-fixation-crop"
10151020

1016-
rr.set_time_nanos("device_time", device_timestamp_ns)
1021+
rr.set_time("device_time", timestamp=device_timestamp_ns * 1e-9)
10171022

10181023
frame = np.array(image_array)
10191024
rr.log(
@@ -1045,7 +1050,7 @@ def plot_cropped_pov_image_data(self, image_data, image_record) -> None:
10451050
device_timestamp_ns = image_record.capture_timestamp_ns
10461051
camera_label = "camera-cropped-pov"
10471052

1048-
rr.set_time_nanos("device_time", device_timestamp_ns)
1053+
rr.set_time("device_time", timestamp=device_timestamp_ns * 1e-9)
10491054

10501055
frame = np.array(image_array)
10511056
rr.log(
@@ -1167,8 +1172,8 @@ def plot_hand_pose_data_3d(self, hand_pose_data):
11671172
"""
11681173
Plot hand pose data in 3D world view
11691174
"""
1170-
rr.set_time_nanos(
1171-
"device_time", int(hand_pose_data.tracking_timestamp.total_seconds() * 1e9)
1175+
rr.set_time(
1176+
"device_time", timestamp=hand_pose_data.tracking_timestamp.total_seconds()
11721177
)
11731178

11741179
# Clear the canvas (only if hand_tracking_label exists for this device version)
@@ -1211,9 +1216,9 @@ def plot_hand_pose_data_2d(self, hand_pose_data, camera_label: str):
12111216
return
12121217

12131218
if self.sensor_labels.hand_tracking_label:
1214-
rr.set_time_nanos(
1219+
rr.set_time(
12151220
"device_time",
1216-
int(hand_pose_data.tracking_timestamp.total_seconds() * 1e9),
1221+
timestamp=hand_pose_data.tracking_timestamp.total_seconds(),
12171222
)
12181223

12191224
# Clear the canvas first
@@ -1241,9 +1246,9 @@ def plot_vio_high_freq_data(self, vio_high_freq_data):
12411246
"device_calibration is None. Cannot plot VIO high frequency data.",
12421247
)
12431248
return
1244-
rr.set_time_nanos(
1249+
rr.set_time(
12451250
"device_time",
1246-
int(vio_high_freq_data.tracking_timestamp.total_seconds() * 1e9),
1251+
timestamp=vio_high_freq_data.tracking_timestamp.total_seconds(),
12471252
)
12481253
# Set and plot Aria Device for the current timestamp
12491254
T_World_Device = vio_high_freq_data.transform_odometry_device
@@ -1270,7 +1275,7 @@ def plot_vio_data(self, vio_data):
12701275
or vio_data.pose_quality != TrackingQuality.GOOD
12711276
):
12721277
return
1273-
rr.set_time_nanos("device_time", vio_data.capture_timestamp_ns)
1278+
rr.set_time("device_time", timestamp=vio_data.capture_timestamp_ns * 1e-9)
12741279
# Set and plot Aria Device for the current timestamp
12751280
T_World_Device = (
12761281
vio_data.transform_odometry_bodyimu @ vio_data.transform_bodyimu_device
@@ -1327,7 +1332,7 @@ def plot_vio_data(self, vio_data):
13271332
def plot_utc_timestamp(
13281333
self, utc_timestamp_ns, camera_label: str, device_timestamp_ns
13291334
):
1330-
rr.set_time_nanos("device_time", device_timestamp_ns)
1335+
rr.set_time("device_time", timestamp=device_timestamp_ns * 1e-9)
13311336
rr.log(
13321337
f"{camera_label}/utc_timestamp",
13331338
rr.Points2D(

projectaria_tools/tools/viewer_mps/rerun_viewer_mps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,8 @@ def post_process_image(img):
917917
# Iterate over the data and LOG data as we see fit
918918
for data in provider.deliver_queued_sensor_data(deliver_option):
919919
device_time_ns = data.get_time_ns(TimeDomain.DEVICE_TIME)
920-
rr.set_time_nanos("device_time", device_time_ns)
921-
rr.set_time_sequence("timestamp", device_time_ns)
920+
rr.set_time("device_time", duration=device_time_ns * 1e-9)
921+
rr.set_time("timestamp", sequence=device_time_ns)
922922
progress_bar.update(1)
923923

924924
log_camera_pose(

projectaria_tools/tools/viewer_projects/viewer_projects_adt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ def main():
244244
static_obj_ids: Set[int] = set()
245245
dynamic_obj_moved: Set[str] = set()
246246
for timestamp_ns in tqdm(img_timestamps_ns):
247-
rr.set_time_nanos("device_time", timestamp_ns)
248-
rr.set_time_sequence("timestamp", timestamp_ns)
247+
rr.set_time("device_time", duration=timestamp_ns * 1e-9)
248+
rr.set_time("timestamp", sequence=timestamp_ns)
249249

250250
# Log RGB image
251251
image_with_dt = gt_provider.get_aria_image_by_timestamp_ns(

projectaria_tools/tools/viewer_projects/viewer_projects_aea.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,13 @@ def logInstanceData(
147147
):
148148
device_time_ns = timestamp_ns
149149
if time_domain is TimeDomain.TIME_CODE:
150-
rr.set_time_nanos("timecode_ns", timestamp_ns)
150+
rr.set_time("timecode_ns", duration=timestamp_ns * 1e-9)
151151

152152
device_time_ns = aea_data_provider.vrs.convert_from_timecode_to_device_time_ns(
153153
timestamp_ns
154154
)
155-
rr.set_time_nanos("device_time_ns", device_time_ns)
156-
rr.set_time_sequence("timestamp", device_time_ns)
155+
rr.set_time("device_time_ns", duration=device_time_ns * 1e-9)
156+
rr.set_time("timestamp", sequence=device_time_ns)
157157

158158
rgb_stream_label = aea_data_provider.vrs.get_label_from_stream_id(RGB_STREAM_ID)
159159
device_calibration = aea_data_provider.vrs.get_device_calibration()

projectaria_tools/tools/viewer_projects/viewer_projects_ase.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ def main():
160160
trajectory["Ts_world_from_device"],
161161
)
162162
):
163-
rr.set_time_nanos("device_time", int(timestamp_ns * 1e3)) # convert to us to ns
164-
rr.set_time_sequence("frame_id", frame_id)
163+
rr.set_time(
164+
"device_time", duration=int(timestamp_ns * 1e3) * 1e-9
165+
) # convert to us to ns
166+
rr.set_time("frame_id", sequence=frame_id)
165167
T_world_from_device = pose # SE3.from_matrix(pose)
166168
T_world_camera = T_world_from_device @ T_device_from_camera
167169
rr.log("world/device", ToTransform3D(T_world_camera, False))

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def main():
158158
install_requires=[
159159
"numpy",
160160
"requests", # Required for datasets downloader
161-
"rerun-sdk==0.22.1",
161+
"rerun-sdk==0.26.2",
162162
"tqdm",
163163
],
164164
extras_require={
@@ -170,7 +170,7 @@ def main():
170170
"pillow",
171171
"plotly",
172172
"scipy",
173-
"rerun-notebook==0.22.1",
173+
"rerun-notebook==0.26.2",
174174
## Required for vrs_to_mp4
175175
"moviepy==1.0.3",
176176
]

0 commit comments

Comments
 (0)