curobo.wrap.model.curobo_robot_world module

This module has differentiable layers built from CuRobo’s core features for use in Pytorch.

class CuroboRobotWorldConfig(
kinematics: curobo.cuda_robot_model.cuda_robot_model.CudaRobotModel,
sampler: curobo.util.sample_lib.HaltonGenerator,
bound_scale: torch.Tensor,
bound_cost: curobo.rollout.cost.bound_cost.BoundCost,
pose_cost: curobo.rollout.cost.pose_cost.PoseCost,
self_collision_cost: curobo.rollout.cost.self_collision_cost.SelfCollisionCost | None = None,
collision_cost: curobo.rollout.cost.primitive_collision_cost.PrimitiveCollisionCost | None = None,
collision_constraint: curobo.rollout.cost.primitive_collision_cost.PrimitiveCollisionCost | None = None,
world_model: curobo.geom.sdf.world.WorldCollision | None = None,
rejection_ratio: int = 10,
tensor_args: curobo.types.base.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),
contact_distance: float = 0.0,
)

Bases: RobotWorldConfig

collision_constraint: PrimitiveCollisionCost | None = None
collision_cost: PrimitiveCollisionCost | None = None
contact_distance: float = 0.0
static load_from_config(
robot_config: RobotConfig | str = 'franka.yml',
world_model: None | str | Dict | WorldConfig | List[WorldConfig] | List[str] = 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),
n_envs: int = 1,
n_meshes: int = 50,
n_cuboids: int = 50,
collision_activation_distance: float = 0.2,
self_collision_activation_distance: float = 0.0,
max_collision_distance: float = 1.0,
collision_checker_type: CollisionCheckerType = CollisionCheckerType.MESH,
world_collision_checker: WorldCollision | None = None,
pose_weight: List[float] = [1, 1, 1, 1],
)
rejection_ratio: int = 10
self_collision_cost: SelfCollisionCost | 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)
world_model: WorldCollision | None = None
kinematics: CudaRobotModel
sampler: HaltonGenerator
bound_scale: torch.Tensor
bound_cost: BoundCost
pose_cost: PoseCost
class CuroboRobotWorld(
config: CuroboRobotWorldConfig,
)

Bases: RobotWorld

clear_world_cache()
collision_constraint: PrimitiveCollisionCost | None = None
collision_cost: PrimitiveCollisionCost | None = None
contact_distance: float = 0.0
get_active_js(
full_js: JointState,
)
get_bound(
q: Tensor,
) Tensor
get_collision_constraint(
x_sph: Tensor,
env_query_idx: Tensor | None = None,
) Tensor

Get collision distance

Parameters:

x_sph (torch.Tensor) – batch, horizon, n_spheres, 4

Returns:

_description_

Return type:

torch.Tensor

get_collision_distance(
x_sph: Tensor,
env_query_idx: Tensor | None = None,
) Tensor

Get collision distance

Parameters:

x_sph (torch.Tensor) – batch, horizon, n_spheres, 4

Returns:

_description_

Return type:

torch.Tensor

get_collision_vector(
x_sph: Tensor,
env_query_idx: Tensor | None = None,
)

NOTE: This function is not differentiable

get_kinematics(
q: Tensor,
) CudaRobotModelState
get_point_robot_distance(
points: Tensor,
q: Tensor,
)

Compute distance from the robot at q joint configuration to points (e.g., pointcloud)

Parameters:
  • points – [b,n,3]

  • q – [1, dof]

Returns:

[b,1] Positive is in collision with robot

Return type:

distance

NOTE: This currently does not support batched robot but can be done easily.

get_self_collision(
x_sph: Tensor,
) Tensor
get_self_collision_distance(
x_sph: Tensor,
) Tensor
get_world_self_collision_distance_from_joint_trajectory(
q: Tensor,
env_query_idx: Tensor | None = None,
) Tuple[Tensor, Tensor]

q : batch, horizon, dof

get_world_self_collision_distance_from_joints(
q: Tensor,
env_query_idx: Tensor | None = None,
) Tuple[Tensor, Tensor]

q : batch, dof

static load_from_config(
robot_config: RobotConfig | str = 'franka.yml',
world_model: None | str | Dict | WorldConfig | List[WorldConfig] | List[str] = 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),
n_envs: int = 1,
n_meshes: int = 50,
n_cuboids: int = 50,
collision_activation_distance: float = 0.2,
self_collision_activation_distance: float = 0.0,
max_collision_distance: float = 1.0,
collision_checker_type: CollisionCheckerType = CollisionCheckerType.MESH,
world_collision_checker: WorldCollision | None = None,
pose_weight: List[float] = [1, 1, 1, 1],
)
pose_distance(
x_des: Pose,
x_current: Pose,
resize: bool = False,
)
rejection_ratio: int = 10
sample(
n: int,
mask_valid: bool = True,
env_query_idx: Tensor | None = None,
)

This does not support batched environments, use sample_trajectory instead.

sample_trajectory(
batch: int,
horizon: int,
mask_valid: bool = True,
env_query_idx: Tensor | None = None,
)
self_collision_cost: SelfCollisionCost | 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)
update_world(
world_config: WorldConfig,
)
validate(
q: Tensor,
env_query_idx: Tensor | None = None,
)

This does not support batched environments, use validate_trajectory instead

validate_trajectory(
q: Tensor,
env_query_idx: Tensor | None = None,
)

q: batch , horizon, dof env_query_idx: batch, 1

world_model: WorldCollision | None = None
kinematics: CudaRobotModel
sampler: HaltonGenerator
bound_scale: torch.Tensor
bound_cost: BoundCost
pose_cost: PoseCost