embodichain.lab.sim.motion.workspace.constraints#

Workspace constraint checkers that validate sampled configurations against the robot’s limits.

Provides BaseConstraintChecker / IConstraintChecker and the concrete WorkspaceConstraintChecker.

Classes:

BaseConstraintChecker

Abstract base class for workspace constraint checkers.

IConstraintChecker

Interface for constraint checkers.

WorkspaceConstraintChecker

Workspace constraint checker for robotic workspace analysis.

class embodichain.lab.sim.motion.workspace.constraints.BaseConstraintChecker[source]#

Bases: ABC

Abstract base class for workspace constraint checkers.

Provides common functionality for checking dimensional constraints, bounds, excluded zones, and other workspace limitations.

Methods:

__init__([min_bounds, max_bounds, ...])

Initialize the constraint checker.

check_bounds(points)

Check if points are within bounds.

check_collision(points)

Check if points are collision-free (to be implemented by subclasses).

filter_points(points)

Filter points to keep only those satisfying all constraints.

get_bounds_info()

Get information about the workspace bounds.

get_bounds_volume()

Calculate the volume of the bounded workspace.

__init__(min_bounds=None, max_bounds=None, ground_height=0.0, device=None)[source]#

Initialize the constraint checker.

Parameters:
  • min_bounds (ndarray | None) – Minimum bounds [x_min, y_min, z_min]. If None, no lower limit.

  • max_bounds (ndarray | None) – Maximum bounds [x_max, y_max, z_max]. If None, no upper limit.

  • ground_height (float) – Ground plane height. Points below this are filtered.

  • device (device | None) – PyTorch device for tensor operations. Defaults to cpu.

check_bounds(points)[source]#

Check if points are within bounds.

Parameters:

points (Tensor | ndarray) – Array of shape (N, 3) containing point positions.

Return type:

Tensor | ndarray

Returns:

Boolean array of shape (N,) indicating which points are within bounds.

abstract check_collision(points)[source]#

Check if points are collision-free (to be implemented by subclasses).

Parameters:

points (Tensor | ndarray) – Array of shape (N, 3) containing point positions.

Return type:

Tensor | ndarray

Returns:

Boolean array of shape (N,) indicating which points are collision-free.

filter_points(points)[source]#

Filter points to keep only those satisfying all constraints.

Parameters:

points (Tensor | ndarray) – Array of shape (N, 3) containing point positions.

Return type:

Tensor | ndarray

Returns:

Filtered array of shape (M, 3) where M <= N.

get_bounds_info()[source]#

Get information about the workspace bounds.

Return type:

dict

Returns:

Dictionary containing bounds information.

get_bounds_volume()[source]#

Calculate the volume of the bounded workspace.

Return type:

float

Returns:

Volume in cubic meters, or inf if unbounded.

class embodichain.lab.sim.motion.workspace.constraints.IConstraintChecker[source]#

Bases: object

Interface for constraint checkers.

This protocol defines the contract that all constraint checkers must follow.

Methods:

check_bounds(points)

Check if points are within bounds.

filter_points(points)

Filter points to keep only those satisfying all constraints.

check_bounds(points)[source]#

Check if points are within bounds.

Parameters:

points (Tensor | ndarray) – Array of shape (N, 3) containing point positions.

Return type:

Tensor | ndarray

Returns:

Boolean array of shape (N,) indicating which points satisfy bounds.

filter_points(points)[source]#

Filter points to keep only those satisfying all constraints.

Parameters:

points (Tensor | ndarray) – Array of shape (N, 3) containing point positions.

Return type:

Tensor | ndarray

Returns:

Filtered array of shape (M, 3) where M <= N.

class embodichain.lab.sim.motion.workspace.constraints.WorkspaceConstraintChecker[source]#

Bases: BaseConstraintChecker

Workspace constraint checker for robotic workspace analysis.

Main features: - Boundary constraint checking (prevents robot from exceeding safe working range) - Excluded zone checking (avoids obstacles, tables, and other fixed objects) - Ground height constraints (prevents robot collision with ground or work surface) - Configuration-based creation for easy reuse across different scenarios

Extends base checker with excluded zones and configuration-based setup.

Methods:

__init__([min_bounds, max_bounds, ...])

Initialize the workspace constraint checker.

add_exclude_zone(min_bounds, max_bounds)

Add an excluded zone (obstacle region) to the workspace.

check_collision(points)

Check if points are not in excluded zones (collision checking).

check_constraints(points)

Check all constraints (bounds + collision) in a single call.

clear_exclude_zones()

Remove all excluded zones.

filter_points(points)

Filter points to keep only those satisfying all constraints.

from_config(config[, device])

Create a constraint checker from a DimensionConstraint config (recommended approach).

get_num_exclude_zones()

Get the number of current excluded zones.

__init__(min_bounds=None, max_bounds=None, ground_height=0.0, exclude_zones=None, device=None)[source]#

Initialize the workspace constraint checker.

Parameters:
  • min_bounds (ndarray | None) – Minimum bounds [x_min, y_min, z_min] in meters

  • max_bounds (ndarray | None) – Maximum bounds [x_max, y_max, z_max] in meters

  • ground_height (float) – Ground plane height in meters

  • exclude_zones (list[tuple[ndarray, ndarray]] | None) – List of excluded zones as [(min_bounds, max_bounds), …]

  • device (device | None) – PyTorch device (CPU/GPU)

add_exclude_zone(min_bounds, max_bounds)[source]#

Add an excluded zone (obstacle region) to the workspace.

Used for dynamically adding obstacles such as temporarily placed objects, newly installed equipment, etc.

Parameters:
  • min_bounds (ndarray) – Minimum bounds of the excluded zone [x_min, y_min, z_min] in meters

  • max_bounds (ndarray) – Maximum bounds of the excluded zone [x_max, y_max, z_max] in meters

Return type:

None

Example

>>> # Add a cubic obstacle
>>> checker.add_exclude_zone(
...     min_bounds=np.array([0.2, 0.2, 0.0]),
...     max_bounds=np.array([0.4, 0.4, 0.2])
... )
check_collision(points)[source]#

Check if points are not in excluded zones (collision checking).

This method checks whether the robot end-effector positions would collide with predefined obstacle zones such as cabinets, tables, walls, and other fixed obstacles.

Parameters:

points (Tensor | ndarray) – Array of shape (N, 3) containing 3D point positions

Return type:

Tensor | ndarray

Returns:

Boolean array of shape (N,) indicating which points are collision-free True = collision-free (safe), False = collision detected (dangerous)

check_constraints(points)[source]#

Check all constraints (bounds + collision) in a single call.

Parameters:

points (Tensor | ndarray) – Array of shape (N, 3) containing 3D point positions.

Return type:

Tensor | ndarray

Returns:

Boolean array of shape (N,) indicating which points satisfy all constraints.

clear_exclude_zones()[source]#

Remove all excluded zones.

Used to reset the workspace environment by clearing all previously configured obstacle zones.

Return type:

None

filter_points(points)[source]#

Filter points to keep only those satisfying all constraints.

This is a comprehensive filtering method that checks both boundary constraints and collision constraints, returning only safe and reachable workspace points.

Parameters:

points (Tensor | ndarray) – Array of shape (N, 3) containing 3D point positions

Return type:

Tensor | ndarray

Returns:

Filtered array of shape (M, 3) where M <= N Contains only points that satisfy all constraint conditions

classmethod from_config(config, device=None)[source]#

Create a constraint checker from a DimensionConstraint config (recommended approach).

This is the recommended way to create constraint checkers. Using configuration objects allows for easy reuse of the same constraint settings across different scenarios.

Parameters:
  • config (DimensionConstraint) – Dimension constraint configuration object containing bounds, excluded zones, etc.

  • device (device | None) – PyTorch device for tensor operations

Returns:

Configured WorkspaceConstraintChecker instance

Example

>>> from embodichain.lab.sim.motion.workspace.configs import DimensionConstraint
>>> config = DimensionConstraint(
...     min_bounds=np.array([-1, -1, 0]),
...     max_bounds=np.array([1, 1, 2]),
...     exclude_zones=[]
... )
>>> checker = WorkspaceConstraintChecker.from_config(config)
get_num_exclude_zones()[source]#

Get the number of current excluded zones.

Return type:

int

Returns:

Number of excluded zones