From 049bce27316dd24eb5adc580ece8202fe8b7d8df Mon Sep 17 00:00:00 2001 From: Nikolaus West Date: Mon, 19 Jun 2023 16:48:15 +0200 Subject: [PATCH] Fill out archetype docs: Transform3d, Pinhole, Scalar, TextEntry (#2473) Simple first pass on adding python examples for archetypes: - [x] Transform3d - [x] Pinhole - [x] Scalar - [x] TextEntry --------- Co-authored-by: Jeremy Leibs --- docs/code-examples/pinhole_simple.py | 12 +++++++++++ docs/code-examples/scalar_simple.py | 13 ++++++++++++ docs/code-examples/text_entry_simple.py | 14 +++++++++++++ docs/code-examples/transform3d_simple.py | 20 +++++++++++++++++++ docs/content/reference/data_types/pinhole.md | 14 +++++++++++++ docs/content/reference/data_types/scalar.md | 13 ++++++++++++ .../reference/data_types/text_entry.md | 14 +++++++++++++ .../reference/data_types/transform3d.md | 13 ++++++++++++ 8 files changed, 113 insertions(+) create mode 100644 docs/code-examples/pinhole_simple.py create mode 100644 docs/code-examples/scalar_simple.py create mode 100644 docs/code-examples/text_entry_simple.py create mode 100644 docs/code-examples/transform3d_simple.py diff --git a/docs/code-examples/pinhole_simple.py b/docs/code-examples/pinhole_simple.py new file mode 100644 index 000000000000..dec1e51254c7 --- /dev/null +++ b/docs/code-examples/pinhole_simple.py @@ -0,0 +1,12 @@ +"""Log a pinhole and a random image.""" +import numpy as np +import rerun as rr + +rr.init("pinhole", spawn=True) +rng = np.random.default_rng(12345) + +image = rng.uniform(0, 255, size=[3, 3, 3]) +intrinsics = np.array([[3, 0, 1.5], [0, 3, 1.5], [0, 0, 1]]) + +rr.log_pinhole("world/image", child_from_parent=intrinsics, width=3, height=3) +rr.log_image("world/image", image=image) diff --git a/docs/code-examples/scalar_simple.py b/docs/code-examples/scalar_simple.py new file mode 100644 index 000000000000..e48abd787149 --- /dev/null +++ b/docs/code-examples/scalar_simple.py @@ -0,0 +1,13 @@ +"""Log a scalar over time.""" +import numpy as np +import rerun as rr + +rr.init("scalar", spawn=True) +rng = np.random.default_rng(12345) + +value = 1.0 +for step in range(100): + rr.set_time_sequence("step", step) + + value += rng.normal() + rr.log_scalar("scalar", value) diff --git a/docs/code-examples/text_entry_simple.py b/docs/code-examples/text_entry_simple.py new file mode 100644 index 000000000000..1ec19541a216 --- /dev/null +++ b/docs/code-examples/text_entry_simple.py @@ -0,0 +1,14 @@ +"""Log some text entries.""" +import logging + +import rerun as rr + +rr.init("text_entry", spawn=True) + +# Log a direct entry directly +rr.log_text_entry("logs", "this entry has loglevel TRACE", level=rr.LogLevel.TRACE) + +# Or log via a logging handler +logging.getLogger().addHandler(rr.LoggingHandler("logs/handler")) +logging.getLogger().setLevel(-1) +logging.info("This log got added through a `LoggingHandler`") diff --git a/docs/code-examples/transform3d_simple.py b/docs/code-examples/transform3d_simple.py new file mode 100644 index 000000000000..adc61c2eed61 --- /dev/null +++ b/docs/code-examples/transform3d_simple.py @@ -0,0 +1,20 @@ +"""Log different transforms between three arrows.""" +import rerun as rr + +rr.init("transform", spawn=True) + +origin = [0, 0, 0] +base_vector = [0, 1, 0] + +rr.log_arrow("base", origin=origin, vector=base_vector) + +rr.log_transform3d("base/translated", rr.Translation3D([1, 0, 0])) + +rr.log_arrow("base/translated", origin=origin, vector=base_vector) + +rr.log_transform3d( + "base/rotated_scaled", + rr.TranslationRotationScale3D(rotation=rr.RotationAxisAngle(axis=[0, 0, 1], radians=3.14 / 4), scale=rr.Scale3D(2)), +) + +rr.log_arrow("base/rotated_scaled", origin=origin, vector=base_vector) diff --git a/docs/content/reference/data_types/pinhole.md b/docs/content/reference/data_types/pinhole.md index 60e8391e4785..3620825378a7 100644 --- a/docs/content/reference/data_types/pinhole.md +++ b/docs/content/reference/data_types/pinhole.md @@ -2,9 +2,23 @@ title: Pinhole order: 10 --- +`Pinhole` represents a pinhole, or perspective, camera model. It's used to project data from a 3D space to a 2D space, or to situate 2D content inside a 3D view. Read more about transforms that relate between spaces [here](https://www.rerun.io/docs/concepts/spaces-and-transforms#space-transformations). + ## Components and APIs Primary component: `pinhole` Python APIs: [log_pinhole](https://ref.rerun.io/docs/python/latest/common/transforms/#rerun.log_pinhole) Rust API: [Pinhole](https://docs.rs/rerun/latest/rerun/components/struct.Pinhole.html) + + +## Simple Example +code-example: pinhole_simple + + + + + + + + diff --git a/docs/content/reference/data_types/scalar.md b/docs/content/reference/data_types/scalar.md index 2cb2c6a7bdf0..6110be627e64 100644 --- a/docs/content/reference/data_types/scalar.md +++ b/docs/content/reference/data_types/scalar.md @@ -2,6 +2,8 @@ title: Scalar order: 30 --- +`Scalar` represents a single scalar value that can be plotted as a time series if logged over time. + ## Components and APIs Primary component: `scalar` @@ -10,3 +12,14 @@ Secondary components: `scalar_plot_props`, `colorrgba`, `radius`, `label` Python APIs: [log_scalar](https://ref.rerun.io/docs/python/latest/common/plotting/#rerun.log_scalar) Rust API: [Scalar](https://docs.rs/rerun/latest/rerun/components/struct.Scalar.html) + +## Simple Example +code-example: scalar_simple + + + + + + + + diff --git a/docs/content/reference/data_types/text_entry.md b/docs/content/reference/data_types/text_entry.md index 25eda1979437..95b51b17f7cf 100644 --- a/docs/content/reference/data_types/text_entry.md +++ b/docs/content/reference/data_types/text_entry.md @@ -2,6 +2,8 @@ title: TextEntry order: 40 --- +`TextEntry` represents a text log with a log level, and is mainly used to get regular text logs into Rerun. + ## Components and APIs Primary component: `text_entry` @@ -10,3 +12,15 @@ Secondary components: `colorrgba` Python APIs: [log_text_entry](https://ref.rerun.io/docs/python/latest/common/text/#rerun.log_text_entry) Rust API: [TextEntry](https://docs.rs/rerun/latest/rerun/components/struct.TextEntry.html) + +## Simple Examples + +code-example: text_entry_simple + + + + + + + + diff --git a/docs/content/reference/data_types/transform3d.md b/docs/content/reference/data_types/transform3d.md index e87b2369477d..6fd6371ce482 100644 --- a/docs/content/reference/data_types/transform3d.md +++ b/docs/content/reference/data_types/transform3d.md @@ -2,6 +2,8 @@ title: Transform3D order: 9 --- +`Transform3D` represents an affine 3D transformation between an entity and it's parent space in the entity hierarchy. Read more about spaces and transforms [here](../../concepts/spaces-and-transforms.md) + ## Components and APIs Primary component: `transform3d` @@ -9,3 +11,14 @@ Python APIs: [log_transform3d](https://ref.rerun.io/docs/python/latest/common/tr Rust API: [Transform3D](https://docs.rs/rerun/latest/rerun/components/struct.Transform3D.html) + +## Simple Example +code-example: transform3d_simple + + + + + + + +