Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Capsules3D archetype. #7574

Merged
merged 12 commits into from
Oct 29, 2024
5 changes: 3 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4069,9 +4069,9 @@ dependencies = [

[[package]]
name = "ordered-float"
version = "4.2.0"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a76df7075c7d4d01fdcb46c912dd17fba5b60c78ea480b475f2b6ab6f666584e"
checksum = "44d501f1a72f71d3c063a6bbc8f7271fa73aa09fe5d6283b6571e2ed176a2537"
dependencies = [
"num-traits",
]
Expand Down Expand Up @@ -5538,6 +5538,7 @@ dependencies = [
"mimalloc",
"nohash-hasher",
"once_cell",
"ordered-float",
"re_chunk_store",
"re_data_ui",
"re_entity_db",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ notify = { version = "6.1.1", features = ["macos_kqueue"] }
num-derive = "0.4"
num-traits = "0.2"
once_cell = "1.17" # No lazy_static - use `std::sync::OnceLock` or `once_cell` instead
ordered-float = "4.2"
ordered-float = "4.2.2"
kpreid marked this conversation as resolved.
Show resolved Hide resolved
parking_lot = "0.12"
paste = "1.0"
pathdiff = "0.2"
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/archetypes.fbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions crates/store/re_types/definitions/rerun/archetypes/capsules3d.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
namespace rerun.archetypes;

// ---

/// 3D capsules; cylinders with hemispherical caps.
///
/// Capsules are defined by two endpoints (the centers of their end cap spheres), which are located
/// at (0, 0, 0) and (0, 0, length), that is, extending along the positive direction of the Z axis.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check what other libraries use as their "length" axis? See #1361 (comment)

I'm especially interested in what is commonly used in the ROS ecosystem

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some web searching and couldn’t easily find any ROS-related things that had actually implemented and documented capsules to compare. While I was looking I found a couple unrelated things that used Z or the two-points representation. But I am absolutely terrible at thorough research and wouldn’t know where to start with reliably determining what “other visualization tools” tend to use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've decided to make this configurable in a follow-up PR: #1361 (comment)

/// Capsules in other orientations may be produced by applying a rotation to the entity or
/// instances.
//
// TODO: Needs an example image.
// TODO(#1361): This archetype should eventually generalize to cylinders without caps, truncated
// cones, and tapered capsules -- all common shapes based on expanding a line segment circularly.
table Capsules3D (
"attr.rust.derive": "PartialEq",
"attr.rust.new_pub_crate",
"attr.cpp.no_field_ctors",
"attr.docs.category": "Spatial 3D",
"attr.docs.view_types": "Spatial3DView, Spatial2DView: if logged above active projection",
"attr.docs.unreleased"
) {
// --- Required ---

/// The shape of the capsule defined as the length of the line between its endpoints.
lengths: [rerun.components.Length] ("attr.rerun.component_required", order: 1000);

/// Radius of the capsules.
//
// TODO(#1361): This should eventually become two radii, to generate truncated cones and tapered capsules.
radii: [rerun.components.Radius] ("attr.rerun.component_required", order: 1100);
kpreid marked this conversation as resolved.
Show resolved Hide resolved

// --- Recommended ---

/// Optional translations of the capsules.
///
/// If not specified, one end of each capsule will be at (0, 0, 0).
/// Note that this uses a [components.PoseTranslation3D] which is also used by [archetypes.InstancePoses3D].
translations: [rerun.components.PoseTranslation3D] ("attr.rerun.component_recommended", nullable, order: 2000);

/// Rotations via axis + angle.
///
/// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
/// Note that this uses a [components.PoseRotationAxisAngle] which is also used by [archetypes.InstancePoses3D].
rotation_axis_angles: [rerun.components.PoseRotationAxisAngle] ("attr.rerun.component_optional", nullable, order: 2100);

/// Rotations via quaternion.
///
/// If no rotation is specified, the capsules align with the +Z axis of the local coordinate system.
/// Note that this uses a [components.PoseRotationQuat] which is also used by [archetypes.InstancePoses3D].
quaternions: [rerun.components.PoseRotationQuat] ("attr.rerun.component_optional", nullable, order: 2200);

/// Optional colors for the capsules.
colors: [rerun.components.Color] ("attr.rerun.component_recommended", nullable, order: 2300);

// --- Optional ---

// TODO(#1361): Add fill_mode component, or whatever succeeds it in case a wireframe
// or other alternate rendering is wanted.

/// Optional text labels for the capsules, which will be located at their centers.
labels: [rerun.components.Text] ("attr.rerun.component_optional", nullable, order: 3100);

/// Optional choice of whether the text labels should be shown by default.
show_labels: rerun.components.ShowLabels ("attr.rerun.component_optional", nullable, order: 3200);

/// Optional class ID for the ellipsoids.
///
/// The class ID provides colors and labels if not specified explicitly.
class_ids: [rerun.components.ClassId] ("attr.rerun.component_optional", nullable, order: 3300);
}
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/components.fbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions crates/store/re_types/definitions/rerun/components/length.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace rerun.components;

// ---

/// Length, or one-dimensional size.
///
/// Measured in its local coordinate system; consult the archetype in use to determine which
/// axis or part of the entity this is the length of.
struct Length (
"attr.python.aliases": "float",
"attr.python.array_aliases": "float, npt.NDArray[np.float32]",
"attr.rust.derive": "Copy, PartialEq, PartialOrd, bytemuck::Pod, bytemuck::Zeroable",
"attr.rust.repr": "transparent"
) {
length: rerun.datatypes.Float32 (order: 100);
}
1 change: 1 addition & 0 deletions crates/store/re_types/src/archetypes/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading