Skip to content

Commit ff55f96

Browse files
kongchen1992meta-codesync[bot]
authored andcommitted
{BugFix} Examples - Migrate Gen2 tutorial notebooks to the rerun 0.33 API
Summary: Explanation: All seven Gen2 tutorial notebooks still call the pre-0.23 rerun API. They were skipped by both rerun migrations: the move to `0.26.2` and the move to `0.33.0` each updated the `.py` samples and helpers but touched no `.ipynb` at all. With `rerun-sdk` pinned at `0.33.0`, three of the APIs they use are gone outright, with no deprecation shim anywhere in the package, so the notebooks raise on the first logging cell. - `rr.set_time_nanos(tl, ns)` -> `rr.set_time(tl, duration=np.timedelta64(ns, "ns"))` 14 call sites, present in every one of the seven notebooks. `duration` is the correct index type here: `device_time` is a device clock, not a Unix epoch. It must be passed as `np.timedelta64` rather than a float, because a float `duration` is interpreted as seconds and would silently drop nanosecond precision. `import numpy as np` is added to the five cells that now need it and did not already have `np` bound by an earlier cell. - `rr.Scalar` -> `rr.Scalars`, 6 call sites in Tutorial 2. Only `rerun.components.Scalar` survives in `0.33`; the top-level archetype is gone. - `rr.SeriesLine(color=..., name=...)` -> `rr.SeriesLines(colors=[...], names=[...])`, 6 call sites in Tutorial 2. The archetype is now plural and so are its fields. Colors are wrapped one level deeper so each is an unambiguous Nx3 batch rather than relying on the "flat sequence, all values below 256" heuristic. Tutorials 5 and 7 additionally passed `axis_length` to the `ToTransform3D` helper, a parameter the `0.33` migration removed from `rerun_helpers.py` without updating these callers. Both are rewritten to the split form that migration already applied to `aria_data_plotter.py`: log the transform, then log `rr.TransformAxes3D(axis_length=...)` to the same entity path. Reproducibility: Against `rerun-sdk 0.33.0`, `set_time_nanos`, the top-level `Scalar`, and `SeriesLine` have zero occurrences anywhere in the installed package, and `ToTransform3D` no longer accepts `axis_length`. Running any Gen2 tutorial therefore fails at its first `rr.log` loop. After this change every rerun call site in the seven notebooks resolves against the `0.33` API. Reviewed By: SeaOtocinclus Differential Revision: D115607423 fbshipit-source-id: 645f9980c473ff3b806626a4ed0810d562faff8f
1 parent 91a93ae commit ff55f96

7 files changed

Lines changed: 41 additions & 34 deletions

examples/Gen2/python_notebooks/Tutorial_1_vrs_data_provider_basics.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@
213213
"source": [
214214
"# Visualize with Rerun\n",
215215
"import rerun as rr\n",
216+
"import numpy as np\n",
216217
"rr.init(\"rerun_viz_query_by_index\")\n",
217218
"\n",
218219
"# Get number of samples in stream\n",
@@ -233,7 +234,7 @@
233234
"\n",
234235
" # Process image data\n",
235236
" if image_data.is_valid():\n",
236-
" rr.set_time_nanos(\"device_time\", timestamp_ns)\n",
237+
" rr.set_time(\"device_time\", duration=np.timedelta64(timestamp_ns, \"ns\"))\n",
237238
" rr.log(\"camera_rgb\", rr.Image(image_data.to_numpy_array()))\n",
238239
"\n",
239240
"rr.notebook_show()"
@@ -333,7 +334,7 @@
333334
"\n",
334335
" # Plot to Rerun\n",
335336
" if image_data.is_valid():\n",
336-
" rr.set_time_nanos(\"device_time\", capture_time_ns)\n",
337+
" rr.set_time(\"device_time\", duration=np.timedelta64(capture_time_ns, \"ns\"))\n",
337338
" rr.log(label, rr.Image(image_data.to_numpy_array()))\n",
338339
"\n",
339340
" query_timestamp_ns = query_timestamp_ns + int(1e9) # 1 second\n",

examples/Gen2/python_notebooks/Tutorial_2_device_calibration.ipynb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@
405405
"\n",
406406
" # Plot original RGB image\n",
407407
" timestamp_ns = image_record.capture_timestamp_ns\n",
408-
" rr.set_time_nanos(\"device_time\", timestamp_ns)\n",
408+
" rr.set_time(\"device_time\", duration=np.timedelta64(timestamp_ns, \"ns\"))\n",
409409
" rr.log(\"camera_rgb\", rr.Image(image_data.to_numpy_array()))\n",
410410
"\n",
411411
" # Undistort RGB image to a linear camera model\n",
@@ -452,32 +452,32 @@
452452
" \"\"\"\n",
453453
" rr.log(\n",
454454
" f\"{rerun_plot_label}/accl/x[m/sec2]\",\n",
455-
" rr.SeriesLine(color=[230, 25, 75], name=\"accel/x[m/sec2]\"),\n",
455+
" rr.SeriesLines(colors=[[230, 25, 75]], names=[\"accel/x[m/sec2]\"]),\n",
456456
" static=True,\n",
457457
" ) # Red\n",
458458
" rr.log(\n",
459459
" f\"{rerun_plot_label}/accl/y[m/sec2]\",\n",
460-
" rr.SeriesLine(color=[60, 180, 75], name=\"accel/y[m/sec2]\"),\n",
460+
" rr.SeriesLines(colors=[[60, 180, 75]], names=[\"accel/y[m/sec2]\"]),\n",
461461
" static=True,\n",
462462
" ) # Green\n",
463463
" rr.log(\n",
464464
" f\"{rerun_plot_label}/accl/z[m/sec2]\",\n",
465-
" rr.SeriesLine(color=[0, 130, 200], name=\"accel/z[m/sec2]\"),\n",
465+
" rr.SeriesLines(colors=[[0, 130, 200]], names=[\"accel/z[m/sec2]\"]),\n",
466466
" static=True,\n",
467467
" ) # Blue\n",
468468
" rr.log(\n",
469469
" f\"{rerun_plot_label}/gyro/x[rad/sec2]\",\n",
470-
" rr.SeriesLine(color=[245, 130, 48], name=\"gyro/x[rad/sec2]\"),\n",
470+
" rr.SeriesLines(colors=[[245, 130, 48]], names=[\"gyro/x[rad/sec2]\"]),\n",
471471
" static=True,\n",
472472
" ) # Orange\n",
473473
" rr.log(\n",
474474
" f\"{rerun_plot_label}/gyro/y[rad/sec2]\",\n",
475-
" rr.SeriesLine(color=[145, 30, 180], name=\"gyro/y[rad/sec2]\"),\n",
475+
" rr.SeriesLines(colors=[[145, 30, 180]], names=[\"gyro/y[rad/sec2]\"]),\n",
476476
" static=True,\n",
477477
" ) # Purple\n",
478478
" rr.log(\n",
479479
" f\"{rerun_plot_label}/gyro/z[rad/sec2]\",\n",
480-
" rr.SeriesLine(color=[70, 240, 240], name=\"gyro/z[rad/sec2]\"),\n",
480+
" rr.SeriesLines(colors=[[70, 240, 240]], names=[\"gyro/z[rad/sec2]\"]),\n",
481481
" static=True,\n",
482482
" ) # Cyan\n",
483483
"\n",
@@ -488,27 +488,27 @@
488488
" \"\"\"\n",
489489
" rr.log(\n",
490490
" f\"{rerun_plot_label}/accl/x[m/sec2]\",\n",
491-
" rr.Scalar(accel_data[0]),\n",
491+
" rr.Scalars(accel_data[0]),\n",
492492
" )\n",
493493
" rr.log(\n",
494494
" f\"{rerun_plot_label}/accl/y[m/sec2]\",\n",
495-
" rr.Scalar(accel_data[1]),\n",
495+
" rr.Scalars(accel_data[1]),\n",
496496
" )\n",
497497
" rr.log(\n",
498498
" f\"{rerun_plot_label}/accl/z[m/sec2]\",\n",
499-
" rr.Scalar(accel_data[2]),\n",
499+
" rr.Scalars(accel_data[2]),\n",
500500
" )\n",
501501
" rr.log(\n",
502502
" f\"{rerun_plot_label}/gyro/x[rad/sec2]\",\n",
503-
" rr.Scalar(gyro_data[0]),\n",
503+
" rr.Scalars(gyro_data[0]),\n",
504504
" )\n",
505505
" rr.log(\n",
506506
" f\"{rerun_plot_label}/gyro/y[rad/sec2]\",\n",
507-
" rr.Scalar(gyro_data[1]),\n",
507+
" rr.Scalars(gyro_data[1]),\n",
508508
" )\n",
509509
" rr.log(\n",
510510
" f\"{rerun_plot_label}/gyro/z[rad/sec2]\",\n",
511-
" rr.Scalar(gyro_data[2]),\n",
511+
" rr.Scalars(gyro_data[2]),\n",
512512
" )\n",
513513
"\n",
514514
"\n",
@@ -534,7 +534,7 @@
534534
" imu_data = vrs_data_provider.get_imu_data_by_index(imu_stream_id, i)\n",
535535
"\n",
536536
" # Plot raw IMU readings\n",
537-
" rr.set_time_nanos(\"device_time\", imu_data.capture_timestamp_ns)\n",
537+
" rr.set_time(\"device_time\", duration=np.timedelta64(imu_data.capture_timestamp_ns, \"ns\"))\n",
538538
"\n",
539539
" # Get compensated imu data\n",
540540
" compensated_accel = imu_calib.raw_to_rectified_accel(imu_data.accel_msec2)\n",

examples/Gen2/python_notebooks/Tutorial_3_sequential_access_multi_sensor_data.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@
249249
"outputs": [],
250250
"source": [
251251
"import rerun as rr\n",
252+
"import numpy as np\n",
252253
"\n",
253254
"print(\"\\n=== Customizing Data Access with DeliverQueuedOptions ===\")\n",
254255
"\n",
@@ -297,7 +298,7 @@
297298
" image_data_and_record = sensor_data.image_data_and_record()\n",
298299
"\n",
299300
" # Visualize\n",
300-
" rr.set_time_nanos(\"device_time\", device_time_ns)\n",
301+
" rr.set_time(\"device_time\", duration=np.timedelta64(device_time_ns, \"ns\"))\n",
301302
" rr.log(stream_label, rr.Image(image_data_and_record[0].to_numpy_array()))\n",
302303
"\n",
303304
"rr.notebook_show()"

examples/Gen2/python_notebooks/Tutorial_4_on_device_eyetracking_handtracking.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@
228228
"outputs": [],
229229
"source": [
230230
"import rerun as rr\n",
231+
"import numpy as np\n",
231232
"from projectaria_tools.core.sensor_data import SensorDataType, TimeDomain, TimeQueryOptions\n",
232233
"from projectaria_tools.utils.rerun_helpers import create_hand_skeleton_from_landmarks\n",
233234
"\n",
@@ -301,7 +302,7 @@
301302
" image_data_and_record = sensor_data.image_data_and_record()\n",
302303
"\n",
303304
" # Visualize the images\n",
304-
" rr.set_time_nanos(\"device_time\", device_time_ns)\n",
305+
" rr.set_time(\"device_time\", duration=np.timedelta64(device_time_ns, \"ns\"))\n",
305306
" rr.log(rgb_camera_label, rr.Image(image_data_and_record[0].to_numpy_array()))\n",
306307
"\n",
307308
" # ---------------\n",
@@ -312,7 +313,7 @@
312313
" eye_gaze = sensor_data.eye_gaze_data()\n",
313314
"\n",
314315
" # Plot Eyegaze overlay on top of camera images\n",
315-
" rr.set_time_nanos(\"device_time\", device_time_ns)\n",
316+
" rr.set_time(\"device_time\", duration=np.timedelta64(device_time_ns, \"ns\"))\n",
316317
" plot_eyegaze_in_camera(eyegaze_data = eye_gaze, camera_label = rgb_camera_label, camera_calib = rgb_camera_calib, T_device_cpf = T_device_cpf)\n",
317318
"\n",
318319
"rr.notebook_show()"
@@ -631,7 +632,7 @@
631632
"\n",
632633
"\n",
633634
" # Visualize the RGB images.\n",
634-
" rr.set_time_nanos(\"device_time\", device_time_ns)\n",
635+
" rr.set_time(\"device_time\", duration=np.timedelta64(device_time_ns, \"ns\"))\n",
635636
" rr.log(f\"{camera_label}\", rr.Image(image_data_and_record[0].to_numpy_array()))\n",
636637
"\n",
637638
" # Query and plot interpolated hand tracking result\n",

examples/Gen2/python_notebooks/Tutorial_5_on_device_vio.ipynb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@
356356
"outputs": [],
357357
"source": [
358358
"import rerun as rr\n",
359+
"import numpy as np\n",
359360
"from projectaria_tools.core.sensor_data import SensorDataType, TimeDomain, TimeQueryOptions\n",
360361
"from projectaria_tools.utils.rerun_helpers import (\n",
361362
" create_hand_skeleton_from_landmarks,\n",
@@ -396,18 +397,19 @@
396397
" continue\n",
397398
"\n",
398399
" # Set timestamp\n",
399-
" rr.set_time_nanos(\"device_time\", vio_data.capture_timestamp_ns)\n",
400+
" rr.set_time(\"device_time\", duration=np.timedelta64(vio_data.capture_timestamp_ns, \"ns\"))\n",
400401
"\n",
401402
" # Set and plot the Device pose for the current timestamp, as a RGB axis\n",
402403
" T_World_Device = (\n",
403404
" vio_data.transform_odometry_bodyimu @ vio_data.transform_bodyimu_device\n",
404405
" )\n",
405406
" rr.log(\n",
406407
" \"world/device\",\n",
407-
" ToTransform3D(\n",
408-
" T_World_Device,\n",
409-
" axis_length=0.05,\n",
410-
" ),\n",
408+
" ToTransform3D(T_World_Device),\n",
409+
" )\n",
410+
" rr.log(\n",
411+
" \"world/device\",\n",
412+
" rr.TransformAxes3D(axis_length=0.05),\n",
411413
" )\n",
412414
"\n",
413415
" # Also plot Aria glass outline for visualization\n",

examples/Gen2/python_notebooks/Tutorial_6_timestamp_alignment_in_aria_gen2.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@
236236
"outputs": [],
237237
"source": [
238238
"import rerun as rr\n",
239+
"import numpy as np\n",
239240
"\n",
240241
"print(\"=== Single VRS timestamp-based query visualization examples ===\")\n",
241242
"rr.init(\"rerun_viz_single_vrs_timestamp_based_query\")\n",
@@ -259,7 +260,7 @@
259260
" time_ns = current_timestamp_ns,\n",
260261
" time_domain = TimeDomain.DEVICE_TIME,\n",
261262
" time_query_options = TimeQueryOptions.CLOSEST)\n",
262-
" rr.set_time_nanos(\"device_time\", rgb_image_record.capture_timestamp_ns)\n",
263+
" rr.set_time(\"device_time\", duration=np.timedelta64(rgb_image_record.capture_timestamp_ns, \"ns\"))\n",
263264
" rr.log(\"rgb_image\", rr.Image(rgb_image_data.to_numpy_array()))\n",
264265
"\n",
265266
" # Query and plot SLAM images\n",
@@ -272,7 +273,7 @@
272273
" time_ns = current_timestamp_ns,\n",
273274
" time_domain = TimeDomain.DEVICE_TIME,\n",
274275
" time_query_options = TimeQueryOptions.CLOSEST)\n",
275-
" rr.set_time_nanos(\"device_time\", slam_image_record.capture_timestamp_ns)\n",
276+
" rr.set_time(\"device_time\", duration=np.timedelta64(slam_image_record.capture_timestamp_ns, \"ns\"))\n",
276277
" rr.log(single_slam_label, rr.Image(slam_image_data.to_numpy_array()))\n",
277278
"\n",
278279
" # Increment query timestamp\n",
@@ -378,7 +379,7 @@
378379
"\n",
379380
" # Set timestamps directly from host image record\n",
380381
" host_timestamp_ns = host_image_record.capture_timestamp_ns\n",
381-
" rr.set_time_nanos(\"device_time\", host_timestamp_ns)\n",
382+
" rr.set_time(\"device_time\", duration=np.timedelta64(host_timestamp_ns, \"ns\"))\n",
382383
"\n",
383384
" rr.log(\"rgb_image_in_host\", rr.Image(host_image_data.to_numpy_array()))\n",
384385
"\n",
@@ -397,7 +398,7 @@
397398
" # because we want to log this image data on host's timeline in Rerun\n",
398399
" client_timestamp_ns = client_image_record.capture_timestamp_ns\n",
399400
" converted_client_timestamp_ns = client_data_provider.convert_from_device_time_to_synctime_ns(client_timestamp_ns, TimeSyncMode.SUBGHZ)\n",
400-
" rr.set_time_nanos(\"device_time\", converted_client_timestamp_ns)\n",
401+
" rr.set_time(\"device_time\", duration=np.timedelta64(converted_client_timestamp_ns, \"ns\"))\n",
401402
"\n",
402403
" # Plot client image\n",
403404
" rr.log(\"rgb_image_in_client\", rr.Image(client_image_data.to_numpy_array()))\n",

examples/Gen2/python_notebooks/Tutorial_7_mps_data_provider_basics.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@
671671
"\n",
672672
"for closed_loop_pose in trajectory_segment:\n",
673673
" capture_timestamp_ns = int(closed_loop_pose.tracking_timestamp.total_seconds() * 1e9)\n",
674-
" rr.set_time_nanos(\"device_time\", capture_timestamp_ns)\n",
674+
" rr.set_time(\"device_time\", duration=np.timedelta64(capture_timestamp_ns, \"ns\"))\n",
675675
"\n",
676676
" if hand_tracking_results_segment:\n",
677677
" while (\n",
@@ -688,10 +688,11 @@
688688
" # Log device pose as a coordinate frame\n",
689689
" rr.log(\n",
690690
" \"world/device\",\n",
691-
" ToTransform3D(\n",
692-
" T_world_device,\n",
693-
" axis_length=0.05,\n",
694-
" ),\n",
691+
" ToTransform3D(T_world_device),\n",
692+
" )\n",
693+
" rr.log(\n",
694+
" \"world/device\",\n",
695+
" rr.TransformAxes3D(axis_length=0.05),\n",
695696
" )\n",
696697
"\n",
697698
" log_hand_tracking_result(latest_hand_tracking_result)\n",

0 commit comments

Comments
 (0)