Skip to content

tesseract_robotics.tesseract_geometry

Geometric primitives for collision and visualization.

Primitives

Box

Python
from tesseract_robotics.tesseract_geometry import Box

box = Box(1.0, 0.5, 0.25)  # x, y, z dimensions
print(f"Dimensions: {box.getX()} x {box.getY()} x {box.getZ()}")

Sphere

Python
from tesseract_robotics.tesseract_geometry import Sphere

sphere = Sphere(0.1)  # radius
print(f"Radius: {sphere.getRadius()}")

Cylinder

Python
from tesseract_robotics.tesseract_geometry import Cylinder

cylinder = Cylinder(0.05, 0.2)  # radius, length
print(f"Radius: {cylinder.getRadius()}, Length: {cylinder.getLength()}")

Capsule

Python
from tesseract_robotics.tesseract_geometry import Capsule

capsule = Capsule(0.05, 0.2)  # radius, length

Cone

Python
from tesseract_robotics.tesseract_geometry import Cone

cone = Cone(0.1, 0.3)  # radius, length

Plane

Python
from tesseract_robotics.tesseract_geometry import Plane

# ax + by + cz + d = 0
plane = Plane(0, 0, 1, 0)  # XY plane (z = 0)

Meshes

Mesh

Triangle mesh from file.

Python
from tesseract_robotics.tesseract_geometry import Mesh, createMeshFromPath
import numpy as np

# Load from file
meshes = createMeshFromPath("model.stl")
mesh = meshes[0]

# Access data
vertices = mesh.getVertices()   # VectorVector3d
triangles = mesh.getTriangles() # face indices

# With scale
meshes = createMeshFromPath("model.stl", scale=np.array([0.001, 0.001, 0.001]))

ConvexMesh

Convex hull for efficient collision.

Python
from tesseract_robotics.tesseract_geometry import ConvexMesh, createConvexMeshFromPath

meshes = createConvexMeshFromPath("model.stl")
convex = meshes[0]

SDFMesh

Signed distance field mesh.

Python
from tesseract_robotics.tesseract_geometry import SDFMesh, createSDFMeshFromPath

meshes = createSDFMeshFromPath("model.stl")
sdf = meshes[0]

CompoundMesh

Multiple mesh parts as single geometry.

Python
from tesseract_robotics.tesseract_geometry import CompoundMesh

# Combine multiple meshes
compound = CompoundMesh(meshes)

Octree

Occupancy octree from 3D sensor data, backed by octomap.

PointCloud → Octree

Python
from tesseract_robotics.tesseract_geometry import (
    PointCloud, Octree, OctreeSubType, createOctree,
)

# Build a point cloud and convert to an octomap OcTree
pc = PointCloud()
pc.addPoint(0.0, 0.0, 0.0)
pc.addPoint(0.1, 0.0, 0.0)
pc.addPoint(0.0, 0.1, 0.0)

ot = createOctree(pc, resolution=0.05, prune=True, binary=True)

# Wrap in a tesseract Octree geometry
octree = Octree(ot, OctreeSubType.BOX, pruned=True, binary_octree=True)
print(octree.calcNumSubShapes())

Building an Octree directly

Python
from tesseract_robotics.tesseract_geometry import OcTree

ot = OcTree(0.05)  # leaf resolution
ot.updateNode(0.0, 0.0, 0.0, True)
ot.updateNode(0.1, 0.0, 0.0, True)
ot.updateInnerOccupancy()
ot.toMaxLikelihood()
ot.writeBinary("/tmp/scene.bt")

# Load back from file
loaded = OcTree("/tmp/scene.bt")
OctreeSubType Description
BOX Each occupied voxel becomes a box
SPHERE_INSIDE Inscribed sphere per voxel
SPHERE_OUTSIDE Circumscribed sphere per voxel

Utilities & Conversions

Python
from tesseract_robotics.tesseract_geometry import (
    Box, Sphere, isIdentical, extractVertices, toTriangleMesh,
)
from tesseract_robotics.tesseract_common import Isometry3d

origin = Isometry3d()
box = Box(1, 1, 1)

# Compare two geometries structurally
isIdentical(box, Box(1, 1, 1))   # True
isIdentical(box, Sphere(1))      # False

# Extract vertices (primitives are converted to a mesh first)
verts = extractVertices(box, origin)        # 8 verts

# Convert a primitive to a triangle Mesh
mesh = toTriangleMesh(box, tolerance=0.01, origin=origin)

Mesh Materials

MeshMaterial

Surface material properties.

Python
from tesseract_robotics.tesseract_geometry import MeshMaterial
import numpy as np

material = MeshMaterial()
material.base_color = np.array([1.0, 0.0, 0.0, 1.0])  # RGBA red
material.metallic = 0.0
material.roughness = 0.5

MeshTexture

Texture for mesh surfaces.

Python
from tesseract_robotics.tesseract_geometry import MeshTexture

texture = MeshTexture()
texture.image = resource  # Resource pointing to image file
texture.uvs = uv_coords   # UV coordinates per vertex

Geometry Base

Geometry

Base class for all geometry types.

Python
from tesseract_robotics.tesseract_geometry import Geometry, GeometryType

geom = box  # any geometry

# Type checking
geom_type = geom.getType()
if geom_type == GeometryType.BOX:
    print("It's a box")

# Clone
copy = geom.clone()
GeometryType Description
BOX Rectangular box
SPHERE Sphere
CYLINDER Cylinder
CAPSULE Capsule (cylinder + hemisphere caps)
CONE Cone
PLANE Infinite plane
MESH Triangle mesh
CONVEX_MESH Convex hull
SDF_MESH Signed distance field
OCTREE Occupancy octree
COMPOUND_MESH Multiple meshes

Factory Functions

Function Description
createMeshFromPath(path, scale) Load mesh from file
createMeshFromResource(resource, scale) Load mesh from Resource
createConvexMeshFromPath(path, scale) Load as convex hull
createConvexMeshFromResource(resource, scale) Convex from Resource
createSDFMeshFromPath(path, scale) Load as SDF mesh
createSDFMeshFromResource(resource, scale) SDF from Resource
createOctree(point_cloud, resolution, prune, binary) Build an octomap OcTree from a PointCloud

Auto-generated API Reference

tesseract_geometry Python bindings

GeometryType

Bases: Enum

UNINITIALIZED class-attribute instance-attribute

Python
UNINITIALIZED = 0

SPHERE class-attribute instance-attribute

Python
SPHERE = 1

CYLINDER class-attribute instance-attribute

Python
CYLINDER = 2

CAPSULE class-attribute instance-attribute

Python
CAPSULE = 3

CONE class-attribute instance-attribute

Python
CONE = 4

BOX class-attribute instance-attribute

Python
BOX = 5

PLANE class-attribute instance-attribute

Python
PLANE = 6

MESH class-attribute instance-attribute

Python
MESH = 7

CONVEX_MESH class-attribute instance-attribute

Python
CONVEX_MESH = 8

SDF_MESH class-attribute instance-attribute

Python
SDF_MESH = 9

OCTREE class-attribute instance-attribute

Python
OCTREE = 10

POLYGON_MESH class-attribute instance-attribute

Python
POLYGON_MESH = 11

COMPOUND_MESH class-attribute instance-attribute

Python
COMPOUND_MESH = 12

Geometry

getType

Python
getType() -> GeometryType

Get the geometry type

clone

Python
clone() -> Geometry

Create a copy of this geometry

__eq__

Python
__eq__(arg: Geometry) -> bool

__ne__

Python
__ne__(arg: Geometry) -> bool

GeometriesConst

__init__

Python
__init__() -> None

__len__

Python
__len__() -> int

__getitem__

Python
__getitem__(arg: int) -> Geometry

append

Python
append(arg: Geometry) -> None

clear

Python
clear() -> None

Box

Bases: Geometry

getX

Python
getX() -> float

Get X dimension

getY

Python
getY() -> float

Get Y dimension

getZ

Python
getZ() -> float

Get Z dimension

__eq__

Python
__eq__(arg: Box) -> bool

__ne__

Python
__ne__(arg: Box) -> bool

__repr__

Python
__repr__() -> str

Sphere

Bases: Geometry

getRadius

Python
getRadius() -> float

Get the radius

__eq__

Python
__eq__(arg: Sphere) -> bool

__ne__

Python
__ne__(arg: Sphere) -> bool

__repr__

Python
__repr__() -> str

Cylinder

Bases: Geometry

getRadius

Python
getRadius() -> float

Get the radius

getLength

Python
getLength() -> float

Get the length

__eq__

Python
__eq__(arg: Cylinder) -> bool

__ne__

Python
__ne__(arg: Cylinder) -> bool

__repr__

Python
__repr__() -> str

Capsule

Bases: Geometry

getRadius

Python
getRadius() -> float

Get the radius

getLength

Python
getLength() -> float

Get the length

__eq__

Python
__eq__(arg: Capsule) -> bool

__ne__

Python
__ne__(arg: Capsule) -> bool

__repr__

Python
__repr__() -> str

Cone

Bases: Geometry

getRadius

Python
getRadius() -> float

Get the radius

getLength

Python
getLength() -> float

Get the length

__eq__

Python
__eq__(arg: Cone) -> bool

__ne__

Python
__ne__(arg: Cone) -> bool

__repr__

Python
__repr__() -> str

Plane

Bases: Geometry

getA

Python
getA() -> float

Get coefficient a

getB

Python
getB() -> float

Get coefficient b

getC

Python
getC() -> float

Get coefficient c

getD

Python
getD() -> float

Get coefficient d

__eq__

Python
__eq__(arg: Plane) -> bool

__ne__

Python
__ne__(arg: Plane) -> bool

__repr__

Python
__repr__() -> str

MeshMaterial

getBaseColorFactor

Python
getBaseColorFactor() -> Annotated[NDArray[numpy.float64], dict(shape=4, order=C)]

Get base color (RGBA)

getMetallicFactor

Python
getMetallicFactor() -> float

Get metallic factor (0-1)

getRoughnessFactor

Python
getRoughnessFactor() -> float

Get roughness factor (0-1)

getEmissiveFactor

Python
getEmissiveFactor() -> Annotated[NDArray[numpy.float64], dict(shape=4, order=C)]

Get emissive factor (RGBA)

MeshTexture

getTextureImage

Python
getTextureImage() -> 'tesseract_common::Resource'

Get the texture image resource

getUVs

Python
getUVs() -> list[Annotated[NDArray[numpy.float64], dict(shape=2, order=C)]]

Get UV coordinates

PolygonMesh

Bases: Geometry

getVertexCount

Python
getVertexCount() -> int

Get number of vertices

getFaceCount

Python
getFaceCount() -> int

Get number of faces

getScale

Python
getScale() -> Annotated[NDArray[numpy.float64], dict(shape=3, order=C)]

Get mesh scale

getVertices

Python
getVertices() -> list[Annotated[NDArray[numpy.float64], dict(shape=3, order=C)]]

getFaces

Python
getFaces() -> Annotated[NDArray[numpy.int32], dict(shape=(None,), order=C)]

getNormals

Python
getNormals() -> list[Annotated[NDArray[numpy.float64], dict(shape=3, order=C)]] | None

Get vertex normals (optional)

getVertexColors

Python
getVertexColors() -> list[Annotated[NDArray[numpy.float64], dict(shape=4, order=C)]] | None

Get vertex colors (optional)

getMaterial

Python
getMaterial() -> MeshMaterial

Get mesh material (optional)

getTextures

Python
getTextures() -> list[MeshTexture] | None

Get mesh textures (optional)

getResource

Python
getResource() -> 'tesseract_common::Resource'

Get mesh resource

Mesh

Bases: PolygonMesh

__init__

Python
__init__(vertices: Sequence[Annotated[NDArray[float64], dict(shape=3, order=C)]], faces: Annotated[NDArray[int32], dict(shape=(None,), order=C)]) -> None

ConvexMesh

Bases: PolygonMesh

__init__

Python
__init__(vertices: Sequence[Annotated[NDArray[float64], dict(shape=3, order=C)]], faces: Annotated[NDArray[int32], dict(shape=(None,), order=C)]) -> None

SDFMesh

Bases: PolygonMesh

__init__

Python
__init__(vertices: Sequence[Annotated[NDArray[float64], dict(shape=3, order=C)]], faces: Annotated[NDArray[int32], dict(shape=(None,), order=C)]) -> None

CompoundMesh

Bases: Geometry

__init__

Python
__init__(meshes: Sequence[PolygonMesh]) -> None

getMeshes

Python
getMeshes() -> list[PolygonMesh]

Get the vector of meshes

getResource

Python
getResource() -> 'tesseract_common::Resource'

Get the resource used to create this mesh

getScale

Python
getScale() -> Annotated[NDArray[numpy.float64], dict(shape=3, order=C)]

Get the scale applied to the mesh

OcTree

getResolution

Python
getResolution() -> float

Get the leaf resolution

size

Python
size() -> int

Get the total number of nodes

getNumLeafNodes

Python
getNumLeafNodes() -> int

Get the number of leaf nodes

updateNode

Python
updateNode(x: float, y: float, z: float, occupied: bool, lazy_eval: bool = False) -> None

Insert/update a node at the given coordinate

updateInnerOccupancy

Python
updateInnerOccupancy() -> None

Recompute inner occupancies after lazy updates

toMaxLikelihood

Python
toMaxLikelihood() -> None

Convert occupancy probabilities to a binary maximum-likelihood representation

writeBinary

Python
writeBinary(filename: str) -> bool

Write the octree to a binary .bt file

OctreeSubType

Bases: Enum

BOX class-attribute instance-attribute

Python
BOX = 0

SPHERE_INSIDE class-attribute instance-attribute

Python
SPHERE_INSIDE = 1

SPHERE_OUTSIDE class-attribute instance-attribute

Python
SPHERE_OUTSIDE = 2

PointCloudPoint

x property writable

Python
x: float

y property writable

Python
y: float

z property writable

Python
z: float

PointCloud

points property writable

Python
points: list[PointCloudPoint]

__init__

Python
__init__() -> None

addPoint

Python
addPoint(x: float, y: float, z: float) -> None

Add a point to the cloud

Octree

Bases: Geometry

__init__

Python
__init__(octree: OcTree, sub_type: OctreeSubType, pruned: bool = False, binary_octree: bool = False) -> None

Create an Octree geometry wrapping an octomap OcTree

getOctree

Python
getOctree() -> OcTree

Get the underlying octomap OcTree

getSubType

Python
getSubType() -> OctreeSubType

Get the sub-shape type

getPruned

Python
getPruned() -> bool

Whether the octree was pruned

calcNumSubShapes

Python
calcNumSubShapes() -> int

Calculate the number of sub-shapes (expensive)

__eq__

Python
__eq__(arg: Octree) -> bool

__ne__

Python
__ne__(arg: Octree) -> bool

prune staticmethod

Python
prune(octree: OcTree) -> None

Prune the octomap OcTree using tesseract's occupancy-threshold rule

createOctree

Python
createOctree(point_cloud: PointCloud, resolution: float, prune: bool, binary: bool = True) -> OcTree

Build an octomap OcTree from a PointCloud

createMeshFromPath

Python
createMeshFromPath(path: str, scale: Annotated[NDArray[float64], dict(shape=3, order=C)] = ..., triangulate: bool = True, flatten: bool = False) -> list[Mesh]

Load mesh from file and return vector of Mesh geometries

createConvexMeshFromPath

Python
createConvexMeshFromPath(path: str, scale: Annotated[NDArray[float64], dict(shape=3, order=C)] = ..., triangulate: bool = True, flatten: bool = False) -> list[ConvexMesh]

Load mesh from file and return vector of ConvexMesh geometries

createSDFMeshFromPath

Python
createSDFMeshFromPath(path: str, scale: Annotated[NDArray[float64], dict(shape=3, order=C)] = ..., triangulate: bool = True, flatten: bool = False) -> list[SDFMesh]

Load mesh from file and return vector of SDFMesh geometries

createMeshFromResource

Python
createMeshFromResource(resource: 'tesseract_common::Resource', scale: Annotated[NDArray[float64], dict(shape=3, order=C)] = ..., triangulate: bool = True, flatten: bool = False) -> list[Mesh]

Load Mesh from resource (e.g., package:// URL)

createConvexMeshFromResource

Python
createConvexMeshFromResource(resource: 'tesseract_common::Resource', scale: Annotated[NDArray[float64], dict(shape=3, order=C)] = ..., triangulate: bool = True, flatten: bool = False) -> list[ConvexMesh]

Load ConvexMesh from resource (e.g., package:// URL)

createSDFMeshFromResource

Python
createSDFMeshFromResource(resource: 'tesseract_common::Resource', scale: Annotated[NDArray[float64], dict(shape=3, order=C)] = ..., triangulate: bool = True, flatten: bool = False) -> list[SDFMesh]

Load SDFMesh from resource (e.g., package:// URL)

isIdentical

Python
isIdentical(geom1: Geometry, geom2: Geometry) -> bool

Check if two geometries are identical

extractVertices

Python
extractVertices(geom: Geometry, origin: 'Eigen::Transform<double, 3, 1, 0>') -> list[Annotated[NDArray[numpy.float64], dict(shape=3, order=C)]]

Extract vertices from a geometry, transforming primitives to a mesh first

toTriangleMesh

Python
toTriangleMesh(geom: Geometry, tolerance: float, origin: 'Eigen::Transform<double, 3, 1, 0>') -> Mesh

Convert a primitive geometry to a triangle Mesh