curobo.wrap.model.robot_world module

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

class curobo.wrap.model.robot_world.RobotWorldConfig(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), contact_distance: float = 0.0)

Bases: object

Parameters:
kinematics: CudaRobotModel
sampler: HaltonGenerator
bound_scale: Tensor
bound_cost: BoundCost
pose_cost: PoseCost
self_collision_cost: SelfCollisionCost | None = None
collision_cost: PrimitiveCollisionCost | None = None
collision_constraint: PrimitiveCollisionCost | None = None
world_model: WorldCollision | None = None
rejection_ratio: int = 10
tensor_args: TensorDeviceType = TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32)
contact_distance: float = 0.0
static load_from_config(robot_config='franka.yml', world_model=None, tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32), n_envs=1, n_meshes=50, n_cuboids=50, collision_activation_distance=0.2, self_collision_activation_distance=0.0, max_collision_distance=1.0, collision_checker_type=CollisionCheckerType.MESH, world_collision_checker=None, pose_weight=[1, 1, 1, 1])
Parameters:
  • robot_config (RobotConfig | str) –

  • world_model (None | str | Dict | WorldConfig | List[WorldConfig] | List[str]) –

  • tensor_args (TensorDeviceType) –

  • n_envs (int) –

  • n_meshes (int) –

  • n_cuboids (int) –

  • collision_activation_distance (float) –

  • self_collision_activation_distance (float) –

  • max_collision_distance (float) –

  • collision_checker_type (CollisionCheckerType) –

  • world_collision_checker (WorldCollision | None) –

  • pose_weight (List[float]) –

class curobo.wrap.model.robot_world.RobotWorld(config)

Bases: RobotWorldConfig

Parameters:

config (RobotWorldConfig) –

get_kinematics(q)
Parameters:

q (Tensor) –

Return type:

CudaRobotModelState

update_world(world_config)
Parameters:

world_config (WorldConfig) –

get_collision_distance(x_sph, env_query_idx=None)

Get collision distance

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

  • env_query_idx (Tensor | None) –

Returns:

_description_

Return type:

torch.Tensor

get_collision_constraint(x_sph, env_query_idx=None)

Get collision distance

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

  • env_query_idx (Tensor | None) –

Returns:

_description_

Return type:

torch.Tensor

get_self_collision_distance(x_sph)
Parameters:

x_sph (Tensor) –

Return type:

Tensor

get_self_collision(x_sph)
Parameters:

x_sph (Tensor) –

Return type:

Tensor

get_collision_vector(x_sph, env_query_idx=None)

NOTE: This function is not differentiable

Parameters:
  • x_sph (Tensor) –

  • env_query_idx (Tensor | None) –

get_world_self_collision_distance_from_joints(q, env_query_idx=None)

q : batch, dof

Parameters:
  • q (Tensor) –

  • env_query_idx (Tensor | None) –

Return type:

Tuple[Tensor, Tensor]

get_world_self_collision_distance_from_joint_trajectory(q, env_query_idx=None)

q : batch, horizon, dof

Parameters:
  • q (Tensor) –

  • env_query_idx (Tensor | None) –

Return type:

Tuple[Tensor, Tensor]

get_bound(q)
Parameters:

q (Tensor) –

Return type:

Tensor

sample(n, mask_valid=True, env_query_idx=None)

This does not support batched environments, use sample_trajectory instead.

Parameters:
  • n (int) –

  • mask_valid (bool) –

  • env_query_idx (Tensor | None) –

validate(q, env_query_idx=None)

This does not support batched environments, use validate_trajectory instead

Parameters:
  • q (Tensor) –

  • env_query_idx (Tensor | None) –

sample_trajectory(batch, horizon, mask_valid=True, env_query_idx=None)
Parameters:
  • batch (int) –

  • horizon (int) –

  • mask_valid (bool) –

  • env_query_idx (Tensor | None) –

validate_trajectory(q, env_query_idx=None)

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

Parameters:
  • q (Tensor) –

  • env_query_idx (Tensor | None) –

pose_distance(x_des, x_current)
Parameters:
get_point_robot_distance(points, q)

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

Parameters:
  • points (Tensor) – [b,n,3]

  • q (Tensor) – [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_active_js(full_js)
Parameters:

full_js (JointState) –