curobo.geom.sdf.world module

class CollisionBuffer(
distance_buffer: torch.Tensor,
grad_distance_buffer: torch.Tensor,
sparsity_index_buffer: torch.Tensor,
shape: torch.Size | None = None,
)

Bases: object

distance_buffer: Tensor
grad_distance_buffer: Tensor
sparsity_index_buffer: Tensor
shape: Size | None = None
classmethod initialize_from_shape(
shape: Size,
tensor_args: TensorDeviceType,
)
_update_from_shape(
shape: Size,
tensor_args: TensorDeviceType,
)
update_buffer_shape(
shape: Size,
tensor_args: TensorDeviceType,
)
clone()
class CollisionQueryBuffer(
primitive_collision_buffer: CollisionBuffer | None = None,
mesh_collision_buffer: CollisionBuffer | None = None,
blox_collision_buffer: CollisionBuffer | None = None,
voxel_collision_buffer: CollisionBuffer | None = None,
shape: Size | None = None,
)

Bases: object

Class stores all buffers required to query collisions This class currently has three main buffers. We initialize the required buffers based on ?

primitive_collision_buffer: CollisionBuffer | None = None
mesh_collision_buffer: CollisionBuffer | None = None
blox_collision_buffer: CollisionBuffer | None = None
voxel_collision_buffer: CollisionBuffer | None = None
shape: Size | None = None
clone()
classmethod initialize_from_shape(
shape: Size,
tensor_args: TensorDeviceType,
collision_types: Dict[str, bool],
)
create_from_shape(
shape: Size,
tensor_args: TensorDeviceType,
collision_types: Dict[str, bool],
)
update_buffer_shape(
shape: Size,
tensor_args: TensorDeviceType,
collision_types: Dict[str, bool] | None,
)
get_gradient_buffer()
class CollisionCheckerType(value)

Bases: Enum

Type of collision checker to use. :param Enum: _description_ :type Enum: _type_

PRIMITIVE = 'PRIMITIVE'
BLOX = 'BLOX'
MESH = 'MESH'
VOXEL = 'VOXEL'
class WorldCollisionConfig(tensor_args: curobo.types.base.TensorDeviceType, world_model: Union[List[curobo.geom.types.WorldConfig], curobo.geom.types.WorldConfig, NoneType] = None, cache: Optional[Dict[curobo.geom.types.Obstacle, int]] = None, n_envs: int = 1, checker_type: curobo.geom.sdf.world.CollisionCheckerType = <CollisionCheckerType.PRIMITIVE: 'PRIMITIVE'>, max_distance: Union[torch.Tensor, float] = 0.1, max_esdf_distance: Union[torch.Tensor, float] = 100.0)

Bases: object

tensor_args: TensorDeviceType
world_model: List[WorldConfig] | WorldConfig | None = None
cache: Dict[Obstacle, int] | None = None
n_envs: int = 1
checker_type: CollisionCheckerType = 'PRIMITIVE'
max_distance: Tensor | float = 0.1
max_esdf_distance: Tensor | float = 100.0
static load_from_dict(
world_coll_checker_dict: Dict,
world_model_dict: WorldConfig | Dict | List[WorldConfig] | None = None,
tensor_args: TensorDeviceType = TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32),
)
class WorldCollision(
config: WorldCollisionConfig | None = None,
)

Bases: WorldCollisionConfig

load_collision_model(
world_model: WorldConfig,
)
get_sphere_distance(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
activation_distance: Tensor,
env_query_idx: Tensor | None = None,
return_loss: bool = False,
sum_collisions: bool = True,
compute_esdf: bool = False,
)

Computes the signed distance via analytic function Args: tensor_sphere: b, n, 4

get_sphere_collision(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
activation_distance: Tensor,
env_query_idx: Tensor | None = None,
return_loss: bool = False,
)

Computes the signed distance via analytic function Args: tensor_sphere: b, n, 4 we assume we don’t need gradient for this function. If you need gradient, use get_sphere_distance

get_swept_sphere_distance(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
activation_distance: Tensor,
speed_dt: Tensor,
sweep_steps: int,
enable_speed_metric=False,
env_query_idx: Tensor | None = None,
return_loss: bool = False,
sum_collisions: bool = True,
)
get_swept_sphere_collision(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
activation_distance: Tensor,
speed_dt: Tensor,
sweep_steps: int,
enable_speed_metric=False,
env_query_idx: Tensor | None = None,
return_loss: bool = False,
)
get_sphere_trace(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
sweep_steps: int,
env_query_idx: Tensor | None = None,
return_loss: bool = False,
)
get_voxels_in_bounding_box(
cuboid: Cuboid = Cuboid(name='test', pose=[0, 0, 0, 1, 0, 0, 0], scale=None, color=None, texture_id=None, texture=None, material=Material(metallic=0.0, roughness=0.4), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), dims=[1, 1, 1]),
voxel_size: float = 0.02,
) List[Cuboid] | Tensor
clear_voxelization_cache()
update_cache_voxelization(
new_grid: VoxelGrid,
)
get_occupancy_in_bounding_box(
cuboid: Cuboid = Cuboid(name='test', pose=[0, 0, 0, 1, 0, 0, 0], scale=None, color=None, texture_id=None, texture=None, material=Material(metallic=0.0, roughness=0.4), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), dims=[1, 1, 1]),
voxel_size: float = 0.02,
) VoxelGrid
get_esdf_in_bounding_box(
cuboid: Cuboid = Cuboid(name='test', pose=[0, 0, 0, 1, 0, 0, 0], scale=None, color=None, texture_id=None, texture=None, material=Material(metallic=0.0, roughness=0.4), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), dims=[1, 1, 1]),
voxel_size: float = 0.02,
dtype=torch.float32,
) VoxelGrid
get_mesh_in_bounding_box(
cuboid: Cuboid = Cuboid(name='test', pose=[0, 0, 0, 1, 0, 0, 0], scale=None, color=None, texture_id=None, texture=None, material=Material(metallic=0.0, roughness=0.4), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), dims=[1, 1, 1]),
voxel_size: float = 0.02,
) Mesh
cache: Dict[Obstacle, int] | None = None
checker_type: CollisionCheckerType = 'PRIMITIVE'
static load_from_dict(
world_coll_checker_dict: Dict,
world_model_dict: WorldConfig | Dict | List[WorldConfig] | None = None,
tensor_args: TensorDeviceType = TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32),
)
max_distance: Tensor | float = 0.1
max_esdf_distance: Tensor | float = 100.0
n_envs: int = 1
world_model: List[WorldConfig] | WorldConfig | None = None
tensor_args: TensorDeviceType
class WorldPrimitiveCollision(
config: WorldCollisionConfig,
)

Bases: WorldCollision

World Oriented Bounding Box representation object

We represent the world with oriented bounding boxes. For speed, we assume there is a maximum number of obbs that can be instantiated. This number is read from the WorldCollisionConfig. If no cache is setup, we use the number from the first call of load_collision_model.

_init_cache()
load_collision_model(
world_config: WorldConfig,
env_idx=0,
fix_cache_reference: bool = False,
)
load_batch_collision_model(
world_config_list: List[WorldConfig],
)

Load a batch of collision environments from a list of world configs.

Parameters:

world_config_list – list of world configs to load from.

_load_collision_model_in_cache(
world_config: WorldConfig,
env_idx: int = 0,
fix_cache_reference: bool = False,
)
_create_obb_cache(
obb_cache,
)
add_obb_from_raw(
name: str,
dims: Tensor,
env_idx: int,
w_obj_pose: Pose | None = None,
obj_w_pose: Pose | None = None,
)

Args: dims: lenght, width, height position: x,y,z rotation: matrix (3x3)

add_obb(
cuboid: Cuboid,
env_idx: int = 0,
)
update_obb_dims(
obj_dims: Tensor,
name: str | None = None,
env_obj_idx: Tensor | None = None,
env_idx: int = 0,
)

Update obstacle dimensions

Parameters:
enable_obstacle(
name: str,
enable: bool = True,
env_idx: int = 0,
)
enable_obb(
enable: bool = True,
name: str | None = None,
env_obj_idx: Tensor | None = None,
env_idx: int = 0,
)

Update obstacle dimensions

Parameters:
update_obstacle_pose(
name: str,
w_obj_pose: Pose,
env_idx: int = 0,
)
update_obb_pose(
w_obj_pose: Pose | None = None,
obj_w_pose: Pose | None = None,
name: str | None = None,
env_obj_idx: Tensor | None = None,
env_idx: int = 0,
)

Update pose of a specific objects. This also updates the signed distance grid to account for the updated object pose. Args: obj_w_pose: Pose obj_idx:

classmethod _get_obstacle_poses(
w_obj_pose: Pose | None = None,
obj_w_pose: Pose | None = None,
)
get_obb_idx(
name: str,
env_idx: int = 0,
) int
get_sphere_distance(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
activation_distance: Tensor,
env_query_idx: Tensor | None = None,
return_loss=False,
sum_collisions: bool = True,
compute_esdf: bool = False,
)

Computes the signed distance via analytic function Args: tensor_sphere: b, n, 4

get_sphere_collision(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
activation_distance: Tensor,
env_query_idx: Tensor | None = None,
return_loss=False,
**kwargs,
)

Computes the signed distance via analytic function Args: tensor_sphere: b, n, 4 we assume we don’t need gradient for this function. If you need gradient, use get_sphere_distance

get_swept_sphere_distance(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
activation_distance: Tensor,
speed_dt: Tensor,
sweep_steps: int,
enable_speed_metric=False,
env_query_idx: Tensor | None = None,
return_loss=False,
sum_collisions: bool = True,
)

Computes the signed distance via analytic function Args: tensor_sphere: b, n, 4

get_swept_sphere_collision(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
activation_distance: Tensor,
speed_dt: Tensor,
sweep_steps: int,
enable_speed_metric=False,
env_query_idx: Tensor | None = None,
return_loss=False,
)

Computes the signed distance via analytic function Args: tensor_sphere: b, n, 4

clear_cache()
cache: Dict[Obstacle, int] | None = None
checker_type: CollisionCheckerType = 'PRIMITIVE'
clear_voxelization_cache()
get_esdf_in_bounding_box(
cuboid: Cuboid = Cuboid(name='test', pose=[0, 0, 0, 1, 0, 0, 0], scale=None, color=None, texture_id=None, texture=None, material=Material(metallic=0.0, roughness=0.4), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), dims=[1, 1, 1]),
voxel_size: float = 0.02,
dtype=torch.float32,
) VoxelGrid
get_mesh_in_bounding_box(
cuboid: Cuboid = Cuboid(name='test', pose=[0, 0, 0, 1, 0, 0, 0], scale=None, color=None, texture_id=None, texture=None, material=Material(metallic=0.0, roughness=0.4), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), dims=[1, 1, 1]),
voxel_size: float = 0.02,
) Mesh
get_occupancy_in_bounding_box(
cuboid: Cuboid = Cuboid(name='test', pose=[0, 0, 0, 1, 0, 0, 0], scale=None, color=None, texture_id=None, texture=None, material=Material(metallic=0.0, roughness=0.4), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), dims=[1, 1, 1]),
voxel_size: float = 0.02,
) VoxelGrid
get_sphere_trace(
query_sphere,
collision_query_buffer: CollisionQueryBuffer,
weight: Tensor,
sweep_steps: int,
env_query_idx: Tensor | None = None,
return_loss: bool = False,
)
get_voxels_in_bounding_box(
cuboid: Cuboid = Cuboid(name='test', pose=[0, 0, 0, 1, 0, 0, 0], scale=None, color=None, texture_id=None, texture=None, material=Material(metallic=0.0, roughness=0.4), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), dims=[1, 1, 1]),
voxel_size: float = 0.02,
) List[Cuboid] | Tensor
static load_from_dict(
world_coll_checker_dict: Dict,
world_model_dict: WorldConfig | Dict | List[WorldConfig] | None = None,
tensor_args: TensorDeviceType = TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32),
)
max_distance: Tensor | float = 0.1
max_esdf_distance: Tensor | float = 100.0
n_envs: int = 1
update_cache_voxelization(
new_grid: VoxelGrid,
)
world_model: List[WorldConfig] | WorldConfig | None = None
tensor_args: TensorDeviceType