Skip to content

Commit

Permalink
Updated docs to favour log_transform3d over log_rigid3
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Jun 21, 2023
1 parent cd7ef75 commit 2eb234b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
45 changes: 25 additions & 20 deletions docs/content/concepts/spaces-and-transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ order: 2

## The Definition of Spaces

Every Entity in Rerun exists in some *Space.* This is at the core of how Rerun organizes the visualizations of the data
that you have logged. In the [Rerun Viewer](../reference/viewer.md) you view data by configuring a "Space View," which is a view
Every Entity in Rerun exists in some *Space*. This is at the core of how Rerun organizes the visualizations of the data
that you have logged. In the [Rerun Viewer](../reference/viewer.md) you view data by configuring a "Space View", which is a view
of a set of entities *as seen from a particular Space.*

A "Space" is, very loosely, a generalization of the idea of a "Coordinate System" (sometimes known as a "Coordinate Frame") to arbitrary data. If a collection of
entities are part of the same Space, it means they can be rendered together in the same view, using the same
"coordinates." As some examples:
entities are part of the same Space, it means they can be rendered together in the same "coordinate system".

For examples:
- For 2d and 3d geometric primitives this means they share the same origin and coordinate system.
- For scalar plots it means they share the same plot axes.
- For text logs, it means they share the same conceptual stream.

As explained bellow, a Space View *may* display data belonging to multiple Spaces, but its coordinate system is defined
by a specific Space, and the other Spaces must have well-defined transforms to that Space to be displayed in the same view.

Which entities belong to which Spaces is a function of the Transform system, which uses the following rules to define
the connectivity of Spaces:

Expand All @@ -34,7 +38,7 @@ Consider the following scenario:
```python
rr.log_points("world/mapped_keypoints", ...)
rr.log_points("world/robot/observed_features", ...)
rr.log_rigid3("world/robot", ...)
rr.log_transform3d("world/robot", ...)
```

There are 4 parent/child entity relationships represented in this hierarchy.
Expand All @@ -44,34 +48,35 @@ There are 4 parent/child entity relationships represented in this hierarchy.
- `world` -> `world/robot`
- `world/robot` -> `world/robot/observed_features`

The call: `rr.log_rigid3("world/robot", ...)` only applies to the relationship: `world` -> `world/robot` because the
logged transform (`world/robot`) describes the relationship between the entity and its _parent_ (`world`). All of the
other relationships are considered to be an identity transform.
The call: `rr.log_transform3d("world/robot", ...)` only applies to the relationship: `world` -> `world/robot` because the
logged transform (`world/robot`) describes the relationship between the entity and its _parent_ (`world`). All other
relationships are considered to be an identity transform.

This leaves us with two spaces. In one space, we have the entities `world`, and `world/mapped_keypoints`. In the other
space we have the entities `world/robot` and `world/robot/observed_features`.

Practically speaking, this means that the position values of the points from `world/mapped_keypoints` and the points
from `world/robot/observed_features` are not directly comparable. If you were to directly draw these points in a single
coordinate system the results would be meaningless. Fortunately, Rerun can still put these entities in the same Space View because it is able to automatically transform data between different spaces.
coordinate system the results would be meaningless. As noted above, Rerun can still display these entities in the same
Space View because it is able to automatically transform data between different spaces.


## Space Transformations

In order to correctly display data from different Spaces in the same view, Rerun uses the information from logged
transforms. Since most transforms are invertible, Rerun can usually transform data from a parent space to a child space
or vice versa. As long as there is a continuous chain of well defined transforms, Rerun will apply the correct series
or vice versa. As long as there is a continuous chain of well-defined transforms, Rerun will apply the correct series
of transformations to the component data when building the scene.

Rerun transforms are currently limited to connections between _Spatial_ views of 2D or 3D data. There are 3 types of
transforms that can be logged:

- Rigid3D transforms define a pure 3D translation + rotation relationship between two paths.
[rerun.log_rigid3](https://ref.rerun.io/docs/python/latest/common/transforms/#rerun.log_rigid3))
- Affine 3D transforms, which can define any combination of translation, rotation, and scale relationship between two paths.
[rerun.log_transform3d](https://ref.rerun.io/docs/python/latest/common/transforms/#rerun.log_transform3d))
- Pinhole transforms define a 3D -> 2D camera projection. (See:
[rerun.log_pinhole](https://ref.rerun.io/docs/python/latest/common/transforms/#rerun.log_pinhole))
- Unknown transforms specify that the data cannot be transformed. In this case it will not be possible to combine the
data into a single view and you will need to create two separate views to explore the data. (See:
data into a single view, and you will need to create two separate views to explore the data. (See:
[rerun.log_unknown_transform](https://ref.rerun.io/docs/python/latest/common/transforms/#rerun.log_unknown_transform))

In the future, Rerun will be adding support for additional types of transforms.
Expand All @@ -84,19 +89,19 @@ Say you have a 3D world with two cameras with known extrinsics (pose) and intrin

```py
# Log some data to the 3D world:
rr.log_points("world/points", )
rr.log_points("world/points", ...)

# Log first camera:
rr.log_rigid3("world/camera/#0", parent_from_child=(cam0_pose.pos, cam0_pose.rot))
rr.log_pinhole("world/camera/#0/image", )
rr.log_transform3d("world/camera/#0", rr.TranslationAndMat3(translation=cam0_pose.pos, matrix=cam0_pose.rot))
rr.log_pinhole("world/camera/#0/image", ...)

# Log second camera:
rr.log_rigid3("world/camera/#1", parent_from_child=(cam1_pose.pos, cam1_pose.rot))
rr.log_pinhole("world/camera/#1/image", )
rr.log_transform3d("world/camera/#1", rr.TranslationAndMat3(translation=cam1_pose.pos, matrix=cam1_pose.rot))
rr.log_pinhole("world/camera/#1/image", ...)

# Log some data to the image spaces of the first camera:
rr.log_image("world/camera/#0/image", )
rr.log_rect("world/camera/#0/image/detection", )
rr.log_image("world/camera/#0/image", ...)
rr.log_rect("world/camera/#0/image/detection", ...)
```

Rerun will from this understand how the `world` space and the two image spaces (`world/camera/#0/image` and `world/camera/#1/image`) relate to each other, which allows you to explore their relationship in the Rerun Viewer. In the 3D view you will see the two cameras show up with their respective camera frustums (based on the intrinsics). If you hover your mouse in one of the image spaces, a corresponding ray will be shot through the 3D space.
Expand Down
2 changes: 1 addition & 1 deletion rerun_py/docs/gen_common_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ class Section:
title="Transforms",
module_summary="log.transform",
func_list=[
"log_rigid3",
"log_transform3d",
"log_pinhole",
"log_unknown_transform",
"log_disconnected_space",
"log_view_coordinates",
"log_rigid3",
],
class_list=[],
),
Expand Down
4 changes: 3 additions & 1 deletion rerun_py/rerun_sdk/rerun/log/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,12 @@ def log_rigid3(
recording: RecordingStream | None = None,
) -> None:
"""
Log a proper rigid 3D transform between this entity and the parent.
Log a proper rigid 3D transform between this entity and the parent (_deprecated_).
Set either `parent_from_child` or `child_from_parent` to a tuple of `(translation_xyz, quat_xyzw)`.
Note: This function is deprecated. Use [`rerun.log_transform3d`][] instead.
Parent-from-child
-----------------
Also known as pose (e.g. camera extrinsics).
Expand Down

0 comments on commit 2eb234b

Please sign in to comment.