Expand description
std facade for the tf_tree transform engine.
Re-exports the tf_tree_core engine and adds the allocating conveniences:
TreeBuilder, the Tree that owns a HeapArena, the plan-cached
Tree::lookup, and Described, a Display wrapper that resolves error
ids to frame names.
use tf_tree::{TreeBuilder, InterpPolicy, Stamp, Iso3};
// Topology is declared on the builder; `build()` sizes the arena from exactly
// these edges (static edges reserve no ring slots).
let tree = TreeBuilder::new()
.static_edge("map", "odom", &Iso3::IDENTITY)
.build()
.expect("layout");
// map -> odom is a static identity, so the lookup is identity at any time.
// A typed binding pins the default `SystemDomain` (method-call inference does
// not apply a type parameter's default, so annotate the stamp once).
let now: Stamp = Stamp::from_nanos(0);
let t = tree.lookup("map", "odom", now).unwrap();
assert_eq!(t, Iso3::IDENTITY);§Minimum supported Rust version
1.87, from [workspace.package] rust-version; just msrv checks this line
against README.md, SUPPORT.md and every rust-version.
§Two stability tiers
The crate root is stable. tf_tree::unstable, behind the default-off
unstable feature, holds what the arena layout shapes (docs/API.md §2.6,
docs/PHASE5.md §1). On the stable tier use Tree::frames and
Tree::edges (docs/API.md §3.2).
These pin that ArenaView, EdgeKind and EdgeMeta moved (gated by
just test-doc-error-codes); one block each, so one absence cannot pass:
use tf_tree::ArenaView;use tf_tree::EdgeKind;use tf_tree::EdgeMeta;EdgeWriter carries a lifetime (docs/API.md §2.1); OwnedWriter is the
storable shape.
§no_std / std split
Arena-generic items (Plan, Step, Guard, Stamp, Domain,
Query) live in the no_std tf_tree_core; this crate adds the heap
arena, Tree::lookup’s per-thread plan cache and Described.
Tree is Send + Sync but not Clone: it owns its arena backing and a
participant-table slot (DEFAULT_MAX_PARTICIPANTS). Share it with an Arc:
use std::sync::Arc;
use tf_tree::{Iso3, Stamp, TreeBuilder};
let tree = Arc::new(
TreeBuilder::new()
.static_edge("map", "odom", &Iso3::IDENTITY)
.build()
.expect("layout"),
);
let reader = Arc::clone(&tree);
let joined = std::thread::spawn(move || {
let now: Stamp = Stamp::from_nanos(0);
reader.lookup("map", "odom", now)
})
.join()
.expect("reader thread");
assert_eq!(joined.unwrap(), Iso3::IDENTITY);docs/API.md §2.2.
§Set lto = "thin" and codegen-units = 1 in your release profile
[profile.release]
lto = "thin"
codegen-units = 1Worth about 25% of a depth-3 lookup, since Plan::at crosses a crate
boundary; see docs/API.md §2.3.
Modules§
- dualquat
- Fast SE(3) screw interpolation via unit dual-quaternion powers.
- unstable
- The unstable tier (
docs/API.md§2.6); enablingunstableis the waiver. The unstable tier. Nothing in this module is covered by semver.
Structs§
- Adaptive
Scratch - Caller-provided scratch for
Plan::at_adaptive, sized for the maximum knot set. - Capacity
- Ring capacity for one dynamic edge, always a power of two.
- Described
- A
LookupErrorpaired with theTreethat can resolve its ids to names. - EdgeCfg
- Per-edge configuration for
TreeBuilder::dynamic_edge. - EdgeId
- Stable identity of an edge (index into the edge table); append-only, removal is tombstoning (invariant 1 / D10).
- Edge
Writer - A claimed edge: the arena record, and the lease that makes its holder’s
death observable (
docs/PHASE2.md§6.1,docs/decisions/0005§5). - ErrBound
- The per-component error tolerance for
Plan::at_adaptive; build withErrBound::new. - Extrapolated
- A pose, and how far past the plan’s newest common sample it was extrapolated
(
0039): no accessor yields the pose alone. - FrameId
- Stable identity of a frame: a
NonZeroU32(0is the root / “no parent” sentinel). Append-only (invariant 1 / D10): never reused. - Frozen
Header - The
.tftcontainer header —docs/PHASE5.md§2.3, NORMATIVE: 128 bytes with 8 reserved, pinned byfrozen_header_has_no_padding. - Guard
- A batch-evaluation handle: it borrows the arena and pins the topology generation once, so a run of lookups validates against one snapshot.
- Iso3
- A rigid-body transform in SE(3): a rotation
qfollowed by a translationt.T_parent_child— applying it to a point inchildyields the point inparent. - Lerp
Slerp - tf2-compatible interpolation: translation LERP + rotation SLERP.
- Open
- The
docs/PHASE2.md§3.2 builder. - Owned
Writer - An
EdgeWriterthat owns its tree — the claim shape for a writer that is stored rather than scoped (docs/decisions/0017,docs/API.md§2.1). - Plan
- A compiled
lookup(target, source)path. - Publisher
- Exclusive writer handle for one edge.
- Quat
- Unit quaternion, Hamilton convention, scalar (
w) first. - Sample
- A pose and its derivatives at one instant (
docs/PHASE4.md§2.2); the twist is body-frame, in the plan’s source frame (tf_tree_math::twist). - ScLerp
- SE(3) screw-geodesic interpolation — the default policy.
- Sensor
Domain - A sensor’s own clock, tag
1. - SimDomain
- Simulated time (a
/clockpublisher, bag replay or physics engine), tag2. - Stamp
- A nanosecond timestamp in domain
D; the phantomDcosts nothing at runtime. - Steady
Domain - A steady, monotone clock, tag
3(docs/PHASE5.md§6,TFT019;docs/API.md§5.3). - System
Domain - The default domain: the host system clock (
CLOCK_REALTIME-like), tag0. - Tree
- A transform tree: a fixed-capacity arena plus the ergonomic operations for
publishing samples and looking up transforms. Build one with
TreeBuilder. - Tree
Builder - Builder for a
Tree. - Twist
- A body-frame (right) twist: angular velocity
ω(rad/s) and linear velocityv(m/s), both in the moving frame. 48 bytes,repr(C), no padding:Pod. - Vec3
- A point or vector in R³.
Enums§
- Attach
Mode - Shared-memory attachment surface (Phase 2). Linux-only, behind
--features shm. How a process attaches to an existing segment. - Await
Error - Why
Tree::await_framescould not produce ids. - Build
Error - Failure building a
Treefrom aTreeBuilder. - Claim
ApiError - Failure claiming an edge for writing.
- Claim
Error - A failed attempt to claim exclusive write access to an edge.
- Create
Policy - Re-exported so a caller need not depend on
tf_tree_ipcto name the policy. Whatopen()should do when no arena exists. - EnvVar
- An environment variable the rendezvous reads.
- Extrap
Policy - What to do when the requested stamp is newer than every published sample.
- Frame
Error - A failed frame interning.
- Frozen
Error - Why a
.tftcould not be written or opened.CopyandString-free (docs/PROJECT.md§5). - Frozen
File Error - Why a
.tftcould not be opened or written. - Hello
Status - Outcome of a handshake, as carried in
HelloResponse::status. - Inheritance
- How
Tree::inherit_ownershipresolved (§3.5). - Interp
Policy - Selects an interpolation policy from an edge’s stored discriminant
(
crate::edge::EdgeRecord::interp). Not#[non_exhaustive]; an unknown discriminant collapses to the default inInterpPolicy::from_u8. - IpcError
- Everything the rendezvous substrate can fail at.
- Layout
- How a transform is written into a caller’s buffer.
- Layout
Error - Error returned when an
ArenaLayoutcannot be constructed. - Lock
Role - Which lock-file role a failing operation was for.
- Lookup
Error - A lookup or sample failure, from the read path and plan compilation and
evaluation (
crate::plan). ImplementsDisplayandcore::error::Error(0040). - Name
Problem - Why an arena name was rejected.
- Open
Error - Why
Open::opencould not produce aTree. - Participant
Error - Why a process could not join the arena.
- Proc
Error - Reading a process’s identity out of
/proc. - Proc
Parse Error - A
/proc/<pid>/statparse failure, distinct from a read failure. - Push
Error - A failed
pushonto an edge’s sample ring. - Query
- A temporal query against a compiled
Plan(#[non_exhaustive]). - Reparent
Error - Failure re-parenting a frame at runtime.
- Runtime
DirSource - Which candidate of the
docs/PHASE2.md§3.1 resolution order a directory came from. - ShmError
- Shared-memory attachment surface (Phase 2). Linux-only, behind
--features shm. Everything that can go wrong obtaining or validating a shared segment. - Step
- One step of a compiled plan.
- Topology
Error - A failed topology mutation.
- Wire
Error - Why a datagram could not be decoded, as distinct from attach policy.
Constants§
- ARENA_
FILE_ ALIGN - Alignment of the arena image within the file (§2.3): 2 MiB, not one page, because a huge page needs congruent virtual address and file offset.
- CRASH_
SITES - Every
docs/PHASE2.md§11.3 crash point compiled into this crate. - MAX_
ADAPTIVE_ DEPTH - Maximum bisection recursion depth in
Plan::at_adaptive. - MAX_
DEPTH - Maximum length of a compiled plan: the
plan::Stepslots aplan::Plancarries by value, counted after constant folding; not the walk’s bound (MAX_PATH_EDGES). Set by0034. - MAX_
KNOTS - Maximum number of knots
Plan::at_adaptivemay emit. - MAX_
PATH_ EDGES - Maximum number of raw path edges
plan::compilewalks, across both sides of the lowest common ancestor. Exceeding it, or folding pastMAX_DEPTH, isLookupError::TreeTooDeep;depthtells them apart (docs/PHASE1.md§7.1).
Traits§
- Domain
- A time domain: a compile-time marker carrying a runtime
Domain::TAGbyte (docs/PROJECT.md§5 D9;docs/PHASE1.md§8). - Interp
- Interpolate between two poses
a(ats = 0) andb(ats = 1).
Functions§
- arena_
format_ version - This build’s arena format version (
docs/PHASE5.md§1). - arena_
layout_ hash - This build’s arena layout hash (geometry); checked on attach with the format version.
- counters_
compiled_ in - Whether this build compiled
docs/PHASE5.md§5’s diagnostic counters in. - exp_se3
- SE(3) exponential: map a twist
ξ = [ω, v]to a rigid transform. - exp_so3
- SO(3) exponential: map a rotation vector
ω(axis × angle) to a unit quaternion. - log_se3
- SE(3) logarithm: map a rigid transform to its twist
ξ = [ω, v]. - log_so3
- SO(3) logarithm: map a unit quaternion to its rotation vector
ωin the principal branch|ω| ∈ [0, π]. - open
- Join the running arena, read-only.
- quat_
from_ rot3 - The unit quaternion of a row-major 3×3 rotation matrix.
- slerp
- Shortest-arc spherical linear interpolation of two unit quaternions.
- write_
affine32 - Write
isoas a row-major 3x4f32affine. - write_
mat4 - Write
isoas a row-major 4x4f64matrix. - write_
quat - Write
isoas[qw qx qy qz tx ty tz]. - write_
quat_ twist - Write
isoandtwistas[qw qx qy qz tx ty tz | ωx ωy ωz vx vy vz].