API Reference
Class summary
Spatial geometry classes for 3D shapes and scene graph management.
|
Base class for a node in a scene graph. |
|
An ordered, list-like collection of |
|
Abstract base class for a renderable 3D shape in a scene graph. |
|
Base class for a |
|
An ordered, list-like collection of |
The class hierarchy for all Spatial Geometry classes is shown below:

Collision shapes
These are the basic 3D geometric shapes that can be rendered into a scene, and can also be used for collision detection.
|
A rectangular prism whose centre is at the local origin. |
|
A sphere whose centre is at the local origin. |
|
An ellipsoid whose centre is at the local origin. |
|
A cylinder whose centre is at the local origin and its axis along the z-axis. |
|
A triangular mesh object. |
|
Deprecated alias for |
These shapes all inherit from:
the
CollisionShapebase class which means they can be used for collision detection, andthe
SceneNodebase class which means they can be nodes in a scene graph to allow visualization and animation of complex scenes.
Collision shapes also support the collision operator & which returns True if the two shapes are colliding, and False otherwise. For example:
- class Cuboid(scale: list | ndarray | tuple | set, **kwargs)[source]
Bases:
CollisionShapeA rectangular prism whose centre is at the local origin.
- Parameters:
scale – [length, width, height] in metres.
collision – Whether this shape participates in collision checking.
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- closest_point(shape: CollisionShape, inf_dist: float = 1.0) tuple[float | None, ndarray | None, ndarray | None]
Return the minimum euclidean distance between self and shape.
- Parameters:
shape – The shape (or
CollisionShapeGroup) to compare distance toinf_dist – Only return a result when distance < inf_dist
- Returns:
(d, p1, p2) — distance and closest points in world frame, or (None, None, None) when the shapes are farther than inf_dist. d is negative when the shapes are penetrating.
Inherited from
CollisionShape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- iscollided(shape: CollisionShape) bool
Return True if self and shape have collided (distance ≤ 0).
- Parameters:
shape – The shape (or
CollisionShapeGroup) to check against
Inherited from
CollisionShape.
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property scale: ndarray
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- class Sphere(radius: float, **kwargs)[source]
Bases:
CollisionShapeA sphere whose centre is at the local origin.
- Parameters:
radius – Radius in metres.
collision – Whether this shape participates in collision checking.
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- closest_point(shape: CollisionShape, inf_dist: float = 1.0) tuple[float | None, ndarray | None, ndarray | None]
Return the minimum euclidean distance between self and shape.
- Parameters:
shape – The shape (or
CollisionShapeGroup) to compare distance toinf_dist – Only return a result when distance < inf_dist
- Returns:
(d, p1, p2) — distance and closest points in world frame, or (None, None, None) when the shapes are farther than inf_dist. d is negative when the shapes are penetrating.
Inherited from
CollisionShape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- iscollided(shape: CollisionShape) bool
Return True if self and shape have collided (distance ≤ 0).
- Parameters:
shape – The shape (or
CollisionShapeGroup) to check against
Inherited from
CollisionShape.
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property radius: float
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- class Cylinder(radius: float, length: float, **kwargs)[source]
Bases:
CollisionShapeA cylinder whose centre is at the local origin and its axis along the z-axis.
- Parameters:
radius – Radius in metres.
length – Total length in metres.
collision – Whether this shape participates in collision checking.
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- closest_point(shape: CollisionShape, inf_dist: float = 1.0) tuple[float | None, ndarray | None, ndarray | None]
Return the minimum euclidean distance between self and shape.
- Parameters:
shape – The shape (or
CollisionShapeGroup) to compare distance toinf_dist – Only return a result when distance < inf_dist
- Returns:
(d, p1, p2) — distance and closest points in world frame, or (None, None, None) when the shapes are farther than inf_dist. d is negative when the shapes are penetrating.
Inherited from
CollisionShape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- iscollided(shape: CollisionShape) bool
Return True if self and shape have collided (distance ≤ 0).
- Parameters:
shape – The shape (or
CollisionShapeGroup) to check against
Inherited from
CollisionShape.
- property length: float
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property radius: float
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- class Ellipsoid(radii: list | ndarray | tuple | set, **kwargs)[source]
Bases:
CollisionShapeAn ellipsoid whose centre is at the local origin.
- Parameters:
radii – Semi-axis lengths along X, Y, Z, in metres. A sphere is the special case radii=[r, r, r] – use
Spherefor that, it’s cheaper both to construct and to collision-check.collision – Whether this shape participates in collision checking.
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- closest_point(shape: CollisionShape, inf_dist: float = 1.0) tuple[float | None, ndarray | None, ndarray | None]
Return the minimum euclidean distance between self and shape.
- Parameters:
shape – The shape (or
CollisionShapeGroup) to compare distance toinf_dist – Only return a result when distance < inf_dist
- Returns:
(d, p1, p2) — distance and closest points in world frame, or (None, None, None) when the shapes are farther than inf_dist. d is negative when the shapes are penetrating.
Inherited from
CollisionShape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- iscollided(shape: CollisionShape) bool
Return True if self and shape have collided (distance ≤ 0).
- Parameters:
shape – The shape (or
CollisionShapeGroup) to check against
Inherited from
CollisionShape.
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property radii: ndarray
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- class Box(scale: list | ndarray | tuple | set, **kwargs)[source]
Bases:
CuboidDeprecated alias for
Cuboid– a rectangular prism whose centre is at the local origin.- Parameters:
scale – [length, width, height] in metres.
collision – Whether this shape participates in collision checking.
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- closest_point(shape: CollisionShape, inf_dist: float = 1.0) tuple[float | None, ndarray | None, ndarray | None]
Return the minimum euclidean distance between self and shape.
- Parameters:
shape – The shape (or
CollisionShapeGroup) to compare distance toinf_dist – Only return a result when distance < inf_dist
- Returns:
(d, p1, p2) — distance and closest points in world frame, or (None, None, None) when the shapes are farther than inf_dist. d is negative when the shapes are penetrating.
Inherited from
CollisionShape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- iscollided(shape: CollisionShape) bool
Return True if self and shape have collided (distance ≤ 0).
- Parameters:
shape – The shape (or
CollisionShapeGroup) to check against
Inherited from
CollisionShape.
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
Inherited from
Cuboid.
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- class Mesh(filename: str | None = None, scale: list | ndarray | tuple | set | float = [1, 1, 1], color: list | ndarray | tuple | set | None = None, y_up: bool = False, **kwargs)[source]
Bases:
CollisionShapeA triangular mesh object.
- Parameters:
filename – Absolute path to the mesh file. Checked for existence at construction (raises
FileNotFoundErrorif missing) – this only confirms the path exists, not that it’s a well-formed or readable mesh file, which is still discovered lazily, the first time the file is actually loaded (see_init_coal()and_local_corners()).scale – Scale factor(s) along XYZ axes (default [1, 1, 1]). A single number applies the same scale to all three axes.
y_up – Set True if the mesh file was authored with +Y as the “up” axis – a common convention in general 3D/graphics tooling – rather than this ecosystem’s +Z-up convention.
collision – Whether this shape participates in collision checking.
Note
For a
Mesh,coloris a flat color override applied to every face/vertex. If not given, the renderer uses whatever per-vertex/per-face colors are baked into the mesh file itself, when present.Unlike the primitive shapes, a mesh’s local origin is not guaranteed to be at its geometric centre – it’s whatever origin the file was authored/exported with, which may be off-centre or even outside the mesh entirely.
- Parameters:
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- closest_point(shape: CollisionShape, inf_dist: float = 1.0) tuple[float | None, ndarray | None, ndarray | None]
Return the minimum euclidean distance between self and shape.
- Parameters:
shape – The shape (or
CollisionShapeGroup) to compare distance toinf_dist – Only return a result when distance < inf_dist
- Returns:
(d, p1, p2) — distance and closest points in world frame, or (None, None, None) when the shapes are farther than inf_dist. d is negative when the shapes are penetrating.
Inherited from
CollisionShape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- property filename: str | None
Absolute path to this mesh’s source file, as given to the constructor. There’s no use case for repointing an existing
Meshat a different file – construct a new one instead.This is a read-only property.
- Return type:
str
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- iscollided(shape: CollisionShape) bool
Return True if self and shape have collided (distance ≤ 0).
- Parameters:
shape – The shape (or
CollisionShapeGroup) to check against
Inherited from
CollisionShape.
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property scale: ndarray
Scale factors along the local X, Y, Z axes. A scalar sets all three axes equally;
Noneresets to[1, 1, 1].This is a read/write property.
- Return type:
ndarray(3)
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- property y_up: bool
True if this mesh file was authored with +Y as “up” and needs the +Y -> +Z correction applied.
This describes a fact about the mesh file itself, fixed at construction – it isn’t live scene state.
This is a read-only property.
- Return type:
bool
Shapes
These are the basic 3D geometric shapes that can be rendered into a scene, but they cannot be used for collision detection.
|
A set of 3D axes whose centre is at the local origin. |
|
An arrow whose centre is at the local origin, and points in the positive z-direction. |
|
A polyline through a sequence of waypoints defined with respect to the local frame of the shape. |
|
Deprecated alias for |
They all inherit directly from the Shape base class.
- class Axes(length: float, arrows: bool = False, radius: float = 0.0, linewidth: float = 1.0, **kwargs)[source]
Bases:
ShapeA set of 3D axes whose centre is at the local origin.
Parameters
- Parameters:
length (float) – The length of each axis.
arrows (bool) – If True, render each axis as a colored Arrow (red/ green/blue for X/Y/Z) instead of a plain line.
radius (float) – Shaft radius of each arrow. Only used when arrows=True; passed straight through to each constituent Arrow (see Arrow’s own radius/linewidth docs – they are mutually exclusive, radius > 0 takes precedence).
linewidth (float) – Shaft width in pixels, only used when arrows=True and radius == 0. Passed straight through to each constituent Arrow.
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- property arrows: bool
If
True, each axis is rendered as a coloredArrow(red/green/blue for X/Y/Z) instead of a plain line, as set byarrowsin the constructor.This is a read/write property.
- Return type:
bool
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- property length: float
The length of each axis, as set by
lengthin the constructor.This is a read/write property.
- Return type:
float
- property linewidth: float
Shaft width in pixels, only used when
arrowsisTrueandradiusis 0. Passed straight through to each constituentArrow. Set bylinewidthin the constructor.This is a read/write property.
- Return type:
float
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property radius: float
Shaft radius of each arrow. Only used when
arrowsisTrue; passed straight through to each constituentArrow(radiusandlinewidthare mutually exclusive –radius> 0 takes precedence). Set byradiusin the constructor.This is a read/write property.
- Return type:
float
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- class Arrow(length: float, radius: float = 0.0, linewidth: float = 1.0, head_length: float = 0.2, head_radius: float = 0.2, **kwargs)[source]
Bases:
ShapeAn arrow whose centre is at the local origin, and points in the positive z-direction.
- Parameters:
length – The total length of the arrow.
radius – The radius of the arrow shaft. If radius is 0, the shaft is rendered as a line instead of a cylinder – see linewidth. radius and linewidth are mutually exclusive: radius > 0 always takes precedence, and linewidth is ignored in that case (a real cylinder mesh has no notion of a pixel width).
linewidth – Width of the shaft in pixels. Only used when radius == 0.
head_length – The length of the cone (head of the arrow). This is represented as a fraction of the length. Must be a value between 0 and 1.
head_radius – The width of the cone (head of the arrow). This is represented as a fraction of the head_length.
The arrow has a cylindrical shaft and a conical head.
Note
This shape cannot be used for collision detection, and is only for visualisation purposes.
- Parameters:
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- classmethod FromTo(start: list | ndarray | tuple | set, end: list | ndarray | tuple | set, **kwargs) Arrow[source]
Construct an Arrow spanning from
starttoend.- Parameters:
start – 3-vector, world-frame point the arrow points from
end – 3-vector, world-frame point the arrow points to
kwargs – passed through to the constructor (
radius,linewidth,head_length,head_radius,color, …)
lengthandposeare computed fromstart/end– don’t pass them directly.- Raises:
ValueError – if
startandendare the same point (the direction, and therefore the pose, would be undefined)- Return type:
- property head_length: float
The length of the cone forming the arrow head, as a fraction of
lengthin the range [0, 1]. Set byhead_lengthin the constructor.This is a read/write property.
- Return type:
float
- property head_radius: float
The width of the cone forming the arrow head, as a fraction of
head_length. Set byhead_radiusin the constructor.This is a read/write property.
- Return type:
float
- property length: float
The total length of the arrow, as set by
lengthin the constructor.This is a read/write property.
- Return type:
float
- property linewidth: float
Width of the shaft in pixels. Only used when
radiusis 0. Set bylinewidthin the constructor.This is a read/write property.
- Return type:
float
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property radius: float
The radius of the arrow shaft. If 0, the shaft is rendered as a line instead of a cylinder – see
linewidth.radiusandlinewidthare mutually exclusive:radius> 0 always takes precedence. Set byradiusin the constructor.This is a read/write property.
- Return type:
float
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- class Polyline(points: list | ndarray | tuple | set, radius: float = 0.0, linewidth: float = 1.0, **kwargs)[source]
Bases:
ShapeA polyline through a sequence of waypoints defined with respect to the local frame of the shape.
- Parameters:
points (ArrayLike) – waypoints defining the polyline
radius – tube radius; if 0, rendered as a line instead of a tube – see linewidth. radius and linewidth are mutually exclusive: radius > 0 always takes precedence, and linewidth is ignored in that case (a real tube mesh has no notion of a pixel width).
linewidth – Width of the line in pixels. Only used when radius == 0.
This shape is used for drawing paths and trajectories in the scene. The line comprises straight segments joining consecutive points, not a smoothed curve.
Note
This shape cannot be used for collision detection, and is only for visualisation purposes.
- Parameters:
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- property linewidth: float
Width of the line in pixels. Only used when
radiusis 0. Set bylinewidthin the constructor.This is a read/write property.
- Return type:
float
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property points: ndarray
- Return type:
ndarray(3,n)
- property radius: float
Tube radius; if 0, rendered as a line instead of a tube – see
linewidth.radiusandlinewidthare mutually exclusive:radius> 0 always takes precedence. Set byradiusin the constructor.This is a read/write property.
- Return type:
float
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
Returns the shape’s information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
- class Path(points: list | ndarray | tuple | set, radius: float = 0.0, linewidth: float = 1.0, **kwargs)[source]
Bases:
PolylineDeprecated alias for
Polyline– a polyline through a sequence of waypoints defined with respect to the local frame of the shape.- Parameters:
points (ArrayLike) – waypoints defining the polyline
radius – tube radius; if 0, rendered as a line instead of a tube – see linewidth.
linewidth – Width of the line in pixels. Only used when radius == 0.
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- property linewidth: float
Width of the line in pixels. Only used when
radiusis 0. Set bylinewidthin the constructor.This is a read/write property.
- Return type:
float
Inherited from
Polyline.
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- property radius: float
Tube radius; if 0, rendered as a line instead of a tube – see
linewidth.radiusandlinewidthare mutually exclusive:radius> 0 always takes precedence. Set byradiusin the constructor.This is a read/write property.
- Return type:
float
Inherited from
Polyline.
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any]
Returns the shape’s information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
Inherited from
Polyline.
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.
Scene Graphs
- class SceneNode(pose: ndarray | SE3 = array([[1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.], [0., 0., 0., 1.]]), scene_parent: SceneNode | None = None, scene_children: list[SceneNode] | None = None)[source]
Bases:
objectBase class for a node in a scene graph.
Subclassed for particular shapes and provides the shape’s pose, a parent/children relationship to other nodes, and the ability to compute its pose in the world frame from the scene graph.
- Parameters:
pose – Local reference frame of this node relative to its parent in the scene graph (or the world frame if it has no parent), defaults to the identity transform.
scene_parent – Parent node of this node in the scene graph.
scene_children – Child nodes of this node in the scene graph.
- attach(object: SceneNode) None[source]
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
- attach_to(object: SceneNode) None[source]
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
- tree() str[source]
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
- tree_children() str[source]
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
- update() None[source]
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.
- class SceneGroup(initlist: Iterable[SceneNode] | None = None, **kwargs)[source]
Bases:
SceneNode,UserListAn ordered, list-like collection of
SceneNodeobjects (nodes can be nested groups, shapes, or any otherSceneNodesubclass) that itself behaves like a singleSceneNode.- Parameters:
initlist – Initial elements to populate the group with.
A
SceneGroupis itself aSceneNodeso its elements can be collectively, parented or nested like any other node in the scene graph. This class inherits fromcollections.UserListso it behaves like a Python list, but it is not a subclass oflistso it can be subclassed itself.Every element’s
scene_parentis kept pointing at the group – adding an element (via the constructor,append,extend,insert, or item assignment) sets it, and removing one (remove,pop,clear,del) clears it back toNone. This is what makes moving the group move its elements with it.The reverse holds too, and isn’t just a side effect –
append()is nothing more thanitem.scene_parent = self, so setting any node’sscene_parentto aSceneGroupdirectly (with noappendcall at all) equally makes it a member of that group’s list. List membership and scene-graph parentage are the same relationship, not two things kept in sync – there’s no way for them to disagree.>>> from spatialgeometry import SceneGroup, Cuboid, Sphere >>> from spatialmath import SE3 >>> group = SceneGroup() >>> print(len(group)) 0 >>> group.append(Cuboid([1,2,3])) >>> group.append(Sphere(1, pose=SE3.Trans(1,0,0))) >>> print(len(group)) 2
- Parameters:
pose – Local reference frame of this node relative to its parent in the scene graph (or the world frame if it has no parent), defaults to the identity transform.
scene_parent – Parent node of this node in the scene graph.
scene_children – Child nodes of this node in the scene graph.
- append(item: SceneNode) None[source]
Add
itemto the end of the group and set itsscene_parentto this group.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- copy()
Inherited from
UserList.
- count(value) integer -- return number of occurrences of value
Inherited from
UserList.
- extend(other: Iterable[SceneNode]) None[source]
Add every element of
otherto the end of the group, setting each one’sscene_parentto this group.
- index(value[, start[, stop]]) integer -- return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
Inherited from
UserList.
- insert(i: int, item: SceneNode) None[source]
Insert
itemat positioniand set itsscene_parentto this group.
- pop(i: int = -1) SceneNode[source]
Remove and return the element at position
i(default: the last one), clearing itsscene_parent.
- reverse()
S.reverse() – reverse IN PLACE
Inherited from
UserList.
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- sort(*args, **kwds)
Inherited from
UserList.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- class CollisionShapeGroup(initlist: Iterable[CollisionShape] | None = None, **kwargs)[source]
Bases:
CollisionShape,UserListAn ordered, list-like collection of
CollisionShape(or nestedCollisionShapeGroup) objects that itself behaves like a single collision-checkable shape.- Parameters:
initlist – Initial elements to populate the group with.
collision – Whether this group participates in collision checking, defaults to True.
Unlike
SceneGroup, which admits anySceneNode, aCollisionShapeGrouponly acceptsCollisionShapeorCollisionShapeGroupinstances – adding anything else (a plainShapesuch asAxes, for instance) raisesTypeError.iscollided()/closest_point()work in every combination of shape-vs-shape, shape-vs-group, group-vs-shape, and group-vs-group, including arbitrarily nested groups – a group checks each of its own elements in turn (delegating to that element’s owniscollided()/closest_point(), which handles the other side being a group itself if needed) and aggregates: any element collided means the group collided; the closest element’s own(d, p1, p2)is the group’s.A
CollisionShapeGrouphas no single Coal collision geometry of its own – it is never itself passed to Coal, only iterated – soto_dict()(there is no single dict that could describe a collection) and_init_coal()(there is no single geometry to build) both raise if called directly. Nothing in normal use calls either, sinceiscollided()/closest_point()never touchself.co.Every element’s
scene_parentis kept pointing at the group, same asSceneGroup– adding an element (via the constructor,append,extend,insert, or item assignment) sets it, and removing one (remove,pop,clear,del) clears it back toNone.>>> from spatialgeometry import CollisionShapeGroup, Cuboid, Sphere >>> from spatialmath import SE3 >>> group = CollisionShapeGroup() >>> group.append(Cuboid([1, 1, 1])) >>> group.append(Sphere(1, pose=SE3.Trans(3, 0, 0))) >>> len(group) 2
- Parameters:
pose – Local reference frame of the shape, defaults to the identity transform.
color – Color as (r, g, b) or (r, g, b, a) in [0-1] (or [0-255], auto-normalised), or a matplotlib color name. Defaults to a mid-grey
(0.3, 0.3, 0.3, 1.0).stype – Shape type identifier used by the renderer/wire protocol (e.g.
"cuboid","mesh") – set by each concrete subclass, not normally passed directly by a caller.base – Deprecated alias for
pose.
- append(item: CollisionShape) None[source]
Add
itemto the end of the group and set itsscene_parentto this group.
- attach(object: SceneNode) None
Attach a child node
- Parameters:
object – the node to attach as a child of this node
- Seealso:
Inherited from
SceneNode.
- attach_to(object: SceneNode) None
Attach this node to a parent node
- Parameters:
object – the node to attach this node to, this node will become a child of the parent
- Seealso:
Inherited from
SceneNode.
- bounds(world: bool = False) ndarray
Min/max extent of this shape’s axis-aligned bounding box along each axis.
- Parameters:
world – See
corners().- Return type:
ndarray(3,2)
Inherited from
Shape.
- closest_point(shape: CollisionShape, inf_dist: float = 1.0) tuple[float | None, ndarray | None, ndarray | None][source]
Return the minimum euclidean distance between this group and shape – the closest
(d, p1, p2)among this group’s own elements.- Parameters:
shape – The shape (or
CollisionShapeGroup) to compare distance toinf_dist – Only return a result when distance < inf_dist
- Returns:
(d, p1, p2) — distance and closest points in world frame, or (None, None, None) when every element is farther than inf_dist.
- property collision: bool
True if this shape is used for collision checking rather than (or as well as) visual rendering, as set by the
collisionargument of aCollisionShapesubclass’ constructor.This is a read-only property.
- Return type:
bool
Inherited from
Shape.
- property color: tuple[float, float, float, float]
shape.color returns a four length tuple representing (red, green, blue, opacity) where opacity represents transparency. Values returned are in the range [0-1]. See
opacityfor a convenient way to get/set just this last channel.Inherited from
Shape.
- copy() Shape
Copy of Shape object
- Returns:
Shallow copy of Shape object
- Return type:
Inherited from
Shape.
- corners(world: bool = False) ndarray
The 8 corners of this shape’s axis-aligned bounding box.
- Parameters:
world – If True, apply this shape’s current pose and return the axis-aligned envelope of the posed shape (its corners will move as the shape is re-posed, and a rotated shape’s envelope is generally larger than its own local box – this is not the shape’s true oriented/rotated corners). If False (default), return the corners in the shape’s own local frame, independent of pose – constant unless the shape’s own parameters (radius, scale, …) change.
- Return type:
ndarray(3,8)
Inherited from
Shape.
- count(value) integer -- return number of occurrences of value
Inherited from
UserList.
- property data: list[CollisionShape]
- extend(other: Iterable[CollisionShape]) None[source]
Add every element of
otherto the end of the group, setting each one’sscene_parentto this group.
- extents(world: bool = False) ndarray
Dimensions (width, depth, height) of this shape’s axis-aligned bounding box.
- Parameters:
world – See
corners().- Return type:
ndarray(3,)
Inherited from
Shape.
- fk_dict() dict[str, Any]
fk_dict() outputs shapes pose in dictionary form
- Returns:
The shape pose in translation and quternion form
- Return type:
dict
Inherited from
Shape.
- index(value[, start[, stop]]) integer -- return first index of value.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
Inherited from
UserList.
- insert(i: int, item: CollisionShape) None[source]
Insert
itemat positioniand set itsscene_parentto this group.
- iscollided(shape: CollisionShape) bool[source]
Return True if any element of this group has collided with shape.
- Parameters:
shape – The shape (or
CollisionShapeGroup) to check against
- property opacity: float
The last channel of
color, in [0-1] – 1.0 is fully opaque, 0.0 fully transparent. A convenience for touching just this channel without needing to know or re-specify the current (r, g, b).Note
“Opacity” here is the same quantity commonly called “alpha” in computer graphics (as in RGBA) – this package uses “opacity” consistently as the public name for it.
This is a read/write property.
- Return type:
float
Inherited from
Shape.
- pop(i: int = -1) CollisionShape[source]
Remove and return the element at position
i(default: the last one), clearing itsscene_parent.
- remove(item: CollisionShape) None[source]
Remove
itemfrom the group and clear itsscene_parent.
- reverse()
S.reverse() – reverse IN PLACE
Inherited from
UserList.
- property scene_children: list[SceneNode]
Return the child nodes of this object in the scene graph.
Setting a new list of children updates each child’s
scene_parentto this object, but does not remove this object from any previous parent’sscene_children.This is a read/write property.
- Return type:
list(SceneNode)
- Seealso:
Inherited from
SceneNode.
- property scene_parent: SceneNode | None
Return the parent node of this object in the scene graph.
Setting a new parent adds this object to the new parent’s
scene_children.This is a read/write property.
- Return type:
SceneNode | None
- Seealso:
Inherited from
SceneNode.
- set_alpha(alpha: float | int) None
Deprecated – use the
opacityproperty instead.Inherited from
Shape.
- sort(*args, **kwds)
Inherited from
UserList.
- property T: ndarray
Pose of the shape relative to its parent frame in the scene graph (or the world frame if it has no parent), as a 4x4 homogeneous transformation matrix. Set via the
poseargument of the constructor.This is a read/write property. The getter always returns a plain
ndarray; the setter also accepts anSE3.Warning
Because the getter returns an
ndarray, in-place operators likeshape.T *= deltado an elementwise multiply, not a pose composition, even whendeltais anSE3– useshape.T = shape.T * delta(orshape.T @= delta.A) instead.- Return type:
ndarray(4,4)
Inherited from
SceneNode.
- to_dict() dict[str, Any][source]
to_dict() returns the shapes information in dictionary form
- Returns:
All information about the shape
- Return type:
dict
- tree() str
Render the whole tree this node lives in as indented text – walks up to the root first (the same root-finding as
update()), then renders down from there, with this node marked with a trailing<==so its position in the tree is visible.- Return type:
str
Inherited from
SceneNode.
- tree_children() str
Render this node’s own subtree as indented text (one
repr()per line), not walking through parents – the same “not through parents” scope as_propagate_scene_children().Nodes have no
.namein this package, so each line is that node’s ownrepr()(type, constructor params, color, pose) – usually enough to tell siblings apart, since it’s rare for two distinct nodes to share an identical pose as well as everything else.- Return type:
str
Inherited from
SceneNode.
- update() None
Recompute the world transform of every node in the scene graph this node belongs to, starting from the root and working down.
Call this after changing any node’s
T/pose(or itsscene_parent) – nothing propagates automatically. It doesn’t matter which node in the graph you call it on: this always walks up to the root first, then pushes fresh world transforms down through the whole tree, not just this node’s own subtree.Inherited from
SceneNode.
- property v: ndarray
Spatial velocity of the shape as a 6-vector: linear velocity
v[:3]followed by angular velocityv[3:6]. Used to integrate the shape’s pose between frames, e.g. bySwift.step()when no per-step callback is supplied.This is a read/write property.
- Return type:
ndarray(6)
Inherited from
Shape.