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:
Abstract base class for workspace constraint checkers. |
|
Interface for constraint checkers. |
|
Workspace constraint checker for robotic workspace analysis. |
- class embodichain.lab.sim.motion.workspace.constraints.BaseConstraintChecker[source]#
Bases:
ABCAbstract 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 information about the workspace bounds.
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.
- class embodichain.lab.sim.motion.workspace.constraints.IConstraintChecker[source]#
Bases:
objectInterface 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.
- class embodichain.lab.sim.motion.workspace.constraints.WorkspaceConstraintChecker[source]#
Bases:
BaseConstraintCheckerWorkspace 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.
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 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 metersmax_bounds (
ndarray|None) – Maximum bounds [x_max, y_max, z_max] in metersground_height (
float) – Ground plane height in metersexclude_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 metersmax_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)