Skip to content

Commit

Permalink
Fill out archetype docs: Transform3d, Pinhole, Scalar, TextEntry (#2473)
Browse files Browse the repository at this point in the history
Simple first pass on adding python examples for archetypes:

- [x] Transform3d
- [x] Pinhole
- [x] Scalar
- [x] TextEntry

---------

Co-authored-by: Jeremy Leibs <jeremy@rerun.io>
  • Loading branch information
nikolausWest and jleibs authored Jun 19, 2023
1 parent 0620a9b commit 049bce2
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/code-examples/pinhole_simple.py
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 13 additions & 0 deletions docs/code-examples/scalar_simple.py
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions docs/code-examples/text_entry_simple.py
Original file line number Diff line number Diff line change
@@ -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`")
20 changes: 20 additions & 0 deletions docs/code-examples/transform3d_simple.py
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions docs/content/reference/data_types/pinhole.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/afed0f5649166b7d28d49190fd83af979ef543e7_pinhole_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/2ae4e17d0fb935346d57aac6c2682bdbd1164382_pinhole_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/5cc82cf0cd60fc50aaa39d150f58cbfe3b16779c_pinhole_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/8f4c364976371b9d183a108895fb1fe3b09f125f_pinhole_simple_1200w.png">
<img src="https://static.rerun.io/9af9441a94bcd9fd54e1fea44fb0c59ff381a7f2_pinhole_simple_full.png" alt="">
</picture>
13 changes: 13 additions & 0 deletions docs/content/reference/data_types/scalar.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/bf2ac4a8f261c4341ab9be2944abffdfd03de7fa_scalar_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/f57794eeff8c4e5f4fc2956b31ff561edc5b2464_scalar_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/d46f90bbd67c81a1ebe19048f270edefb23bb492_scalar_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/db2806e01110223a3fda91ad9eb35ac71721c079_scalar_simple_1200w.png">
<img src="https://static.rerun.io/edf309ee6bdd4de4db0057a791bf658ac1917fbe_scalar_simple_full.png" alt="">
</picture>
14 changes: 14 additions & 0 deletions docs/content/reference/data_types/text_entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand All @@ -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

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/7ea83c0af16f53c7e746b06b56f273cd42f087c8_text_entry_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/f69d393e075469c022a3f916d43bbdc9fc89ad17_text_entry_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/160163db0745b4c5120881789b35b52f8674759d_text_entry_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/2c158d3ea7141166bb0dfab4b880c87815d14c78_text_entry_simple_1200w.png">
<img src="https://static.rerun.io/1d40df02963e8476f2f91992f470b331e2315245_text_entry_simple_full.png" alt="">
</picture>
13 changes: 13 additions & 0 deletions docs/content/reference/data_types/transform3d.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@
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`

Python APIs: [log_transform3d](https://ref.rerun.io/docs/python/latest/common/transforms/#rerun.log_transform3d), [log_rigid3](https://ref.rerun.io/docs/python/latest/common/transforms/#rerun.log_rigid3)


Rust API: [Transform3D](https://docs.rs/rerun/latest/rerun/components/struct.Transform3D.html)

## Simple Example
code-example: transform3d_simple

<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/9e5bf32baf0492dc4721bea477be7a26fff6bc98_transform3d_simple_480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/bbbe9a9872ca24a237ff27701e7e833e3e9ec4df_transform3d_simple_768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/4e35c234549ca93a0412645d6be2c534b9a1b47a_transform3d_simple_1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/eea6f00a413dae4228aebf9493f02816c74503d3_transform3d_simple_1200w.png">
<img src="https://static.rerun.io/141368b07360ce3fcb1553079258ae3f42bdb9ac_transform3d_simple_full.png" alt="">
</picture>

0 comments on commit 049bce2

Please sign in to comment.