Spatial¶
Spatial provides TF tree access plus local pose, transform, and geometry types.
Spatial maths and TF wrapper over olo.spatial.v1.Spatial.
Client interfaces
- class olo.spatial.Spatial[source]¶
Bases:
objectTF tree access via the Spatial gRPC service.
- handle(namespace=None)[source]¶
Return a namespace-scoped TF frame handle for a robot.
Noneauto-resolves the unambiguous appliance default.""or"global"select the global namespace without discovery; bare frame names are not prefixed server-side. For the full TF tree across all robots, usetree()instead.- Return type:
- Parameters:
namespace (str | None)
- lookup(target_frame, source_frame, *, at=None, timeout=5.0, robot_namespace=None)[source]¶
Look up a transform between two TF frames.
target_frameis the frame poses are expressed in;source_frameis the frame being looked up. The returnedTransformhasframe_id=target_frameandchild_frame_id=source_frame.When
robot_namespaceis set, bare frame names are resolved server-side for that robot (seeRobotFrames).atselects a historical transform; when omitted the latest value is returned.timeoutbounds how long to wait for the transform to become available.
- publish_static(transform, *, timeout=5.0, robot_namespace=None)[source]¶
Publish a static transform to the TF tree.
The transform is broadcast on
/tf_static.frame_idandchild_frame_idmust be set. Whenstampis omitted the server stamps the transform with its current time.When
robot_namespaceis set, bare frame ids are resolved server-side for that robot (seeRobotFrames).
- subscribe(target_frame, source_frame, *, timeout=None, robot_namespace=None)[source]¶
Subscribe to transform updates between two frames.
target_frameandsource_framefollow the same convention aslookup().When
robot_namespaceis set, bare frame names are resolved server-side for that robot (seeRobotFrames).timeoutis a deadline for the whole stream, not the wait for the next update: the subscription is terminated with a timeout error once it elapses. Leave itNone(the default) for a long-lived subscription and close it via the context manager orclose().- Return type:
- Parameters:
- subscribe_tree(*, timeout=None)[source]¶
Subscribe to TF tree updates across the full tree.
Each yield is a materialized
FrameTreewith current edge poses. UseTreeSubscription.changes()on the returned subscription for raw deltas.timeoutis a deadline for the whole stream, not the wait for the next update. Leave itNone(the default) for a long-lived subscription and close it via the context manager orclose().- Return type:
- Parameters:
timeout (float | None)
- class olo.spatial.RobotFrames[source]¶
Bases:
objectNamespace-scoped TF frame handle for a robot.
- base_frame(*, timeout=5.0)[source]¶
Return the detected base frame for this robot, or None when unknown.
- lookup(target_frame, source_frame, *, at=None, timeout=5.0)[source]¶
Look up a transform between two frames, resolving bare names for this robot.
- publish_static(transform, *, timeout=5.0)[source]¶
Publish a static transform, resolving bare frame ids for this robot.
- subscribe(target_frame, source_frame, *, timeout=None)[source]¶
Subscribe to transform updates, resolving bare names for this robot.
- Return type:
- Parameters:
- class olo.spatial.TransformSubscription[source]¶
Bases:
objectContext-managed sync iterator over a Spatial.SubscribeTransform stream.
- class olo.spatial.TreeSubscription[source]¶
Bases:
objectContext-managed sync iterator over a Spatial.SubscribeTree stream.
Default iteration yields a materialized
FrameTreeafter each server message. Usechanges()for the raw delta view. Only one consumer should iterate a subscription at a time.- __init__(stream, *, namespace='')[source]¶
Wrap a SubscribeTree server stream.
- Parameters:
namespace (str)
- Return type:
None
- class olo.spatial.TreeDelta[source]¶
Bases:
objectRaw tree change batch from a SubscribeTree stream.
Types
- class olo.spatial.types.Point[source]¶
Bases:
objectCartesian position in metres.
- class olo.spatial.types.Vector[source]¶
Bases:
objectCartesian vector in metres.
- class olo.spatial.types.Quaternion[source]¶
Bases:
objectOrientation quaternion (xyzw).
- __init__(x=0.0, y=0.0, z=0.0, w=1.0)¶
- classmethod from_array(values)[source]¶
Create a quaternion from an
[x, y, z, w]array-like.- Return type:
- Parameters:
- classmethod from_axis_angle(axis, angle)[source]¶
Create a quaternion from an axis-angle rotation.
- Return type:
- Parameters:
- classmethod from_matrix(matrix)[source]¶
Create a quaternion from a 3x3 rotation matrix.
- Return type:
- Parameters:
matrix (ndarray)
- classmethod from_rpy(roll, pitch, yaw)[source]¶
Create a quaternion from roll-pitch-yaw angles (radians, xyz extrinsic).
- Return type:
- Parameters:
- isclose(other, *, tol=1e-09)[source]¶
Return whether two quaternions represent the same rotation within a tolerance.
- class olo.spatial.types.Pose[source]¶
Bases:
objectA combined 3D position and orientation.
- __init__(position=<factory>, orientation=<factory>)¶
- Parameters:
position (Point)
orientation (Quaternion)
- Return type:
None
- classmethod from_xy_yaw(x, y, yaw, *, z=0.0)[source]¶
Create a planar pose from x, y, and yaw (radians).
- isclose(other, *, tol=1e-09)[source]¶
Return whether two poses are geometrically equal within a tolerance.
- class olo.spatial.types.Transform[source]¶
Bases:
objectRigid transform, optionally stamped with TF frame metadata.
- __init__(translation=<factory>, rotation=<factory>, frame_id='', child_frame_id='', stamp=None)¶
- Parameters:
translation (Vector)
rotation (Quaternion)
frame_id (str)
child_frame_id (str)
stamp (datetime | None)
- Return type:
None
- classmethod from_matrix(matrix, *, frame_id='', child_frame_id='', stamp=None)[source]¶
Create a transform from a 4x4 homogeneous transform matrix.
- class olo.spatial.types.Twist[source]¶
Bases:
objectLinear and angular velocity vectors.
- __init__(linear=<factory>, angular=<factory>)¶
Import from olo/spatial:
The TypeScript surface mirrors the Python module: method names are
camelCase, keyword arguments become an options object with millisecond
timeouts, and Python’s * operator maps to multiply().
Client interfaces
Spatial — TF tree access:
lookup(),tree(),handle(),subscribe(),subscribeTree(), andpublishStatic().RobotFrames — namespace-scoped TF frame handle (created via
client.spatial.handle()), plusbaseFrame().TransformSubscription — async iterable transform stream.
TreeSubscription — async iterable tree stream; yields materialized
FrameTreesnapshots, or raw deltas viachanges().TreeDelta — raw tree change batch (
added/updated).
Types
Point — Cartesian position in metres.
Vector — Cartesian vector in metres with dot/cross, normalization, and magnitude clamping.
Quaternion — orientation (xyzw) with RPY, axis-angle, matrix constructors, and vector rotation.
Pose — position plus orientation;
matrix(),inverse(),apply(),rotate(), andmultiply().Transform — rigid transform with optional TF frame metadata and
stamp; composition validates frame chaining.Twist — linear and angular velocity vectors.
FrameInfo — flattened frame entry.
FrameTreeNode — node in a TF subtree.
FrameTree — multi-root tree with
flatten()and a tree-shapedtoString().