curobo.rollout.cost.pose_cost module

class curobo.rollout.cost.pose_cost.PoseErrorType(value)

Bases: Enum

An enumeration.

SINGLE_GOAL = 0

Distance will be computed to a single goal pose

BATCH_GOAL = 1

Distance will be computed pairwise between query batch and goal batch

GOALSET = 2

Shortest Distance will be computed to a goal set

BATCH_GOALSET = 3

Shortest Distance to a batch goal set

class curobo.rollout.cost.pose_cost.PoseCostConfig(weight: Union[torch.Tensor, float, List[float]], tensor_args: curobo.types.base.TensorDeviceType = None, distance_threshold: float = 0.0, classify: bool = False, terminal: bool = False, run_weight: Optional[float] = None, dof: int = 7, vec_weight: Union[torch.Tensor, List[float], float, NoneType] = None, max_value: Optional[float] = None, hinge_value: Optional[float] = None, vec_convergence: Optional[List[float]] = None, threshold_value: Optional[float] = None, return_loss: bool = False, cost_type: 'PoseErrorType' = <PoseErrorType.BATCH_GOAL: 1>, use_metric: 'bool' = False, project_distance: 'bool' = True, run_vec_weight: 'Optional[List[float]]' = None, use_projected_distance: 'bool' = True, offset_waypoint: 'List[float]' = None, offset_tstep_fraction: 'float' = -1.0)

Bases: CostConfig

Parameters:
  • weight (Tensor | float | List[float]) –

  • tensor_args (TensorDeviceType) –

  • distance_threshold (float) –

  • classify (bool) –

  • terminal (bool) –

  • run_weight (float | None) –

  • dof (int) –

  • vec_weight (Tensor | List[float] | float | None) –

  • max_value (float | None) –

  • hinge_value (float | None) –

  • vec_convergence (List[float] | None) –

  • threshold_value (float | None) –

  • return_loss (bool) –

  • cost_type (PoseErrorType) –

  • use_metric (bool) –

  • project_distance (bool) –

  • run_vec_weight (List[float] | None) –

  • use_projected_distance (bool) –

  • offset_waypoint (List[float]) –

  • offset_tstep_fraction (float) –

cost_type: PoseErrorType = 1
use_metric: bool = False
project_distance: bool = True
run_vec_weight: List[float] | None = None
use_projected_distance: bool = True
offset_waypoint: List[float] = None
offset_tstep_fraction: float = -1.0
class curobo.rollout.cost.pose_cost.PoseCostMetric(hold_partial_pose: 'bool' = False, release_partial_pose: 'bool' = False, hold_vec_weight: 'Optional[torch.Tensor]' = None, reach_partial_pose: 'bool' = False, reach_full_pose: 'bool' = False, reach_vec_weight: 'Optional[torch.Tensor]' = None, offset_position: 'Optional[torch.Tensor]' = None, offset_rotation: 'Optional[torch.Tensor]' = None, offset_tstep_fraction: 'float' = -1.0, remove_offset_waypoint: 'bool' = False)

Bases: object

Parameters:
  • hold_partial_pose (bool) –

  • release_partial_pose (bool) –

  • hold_vec_weight (Tensor | None) –

  • reach_partial_pose (bool) –

  • reach_full_pose (bool) –

  • reach_vec_weight (Tensor | None) –

  • offset_position (Tensor | None) –

  • offset_rotation (Tensor | None) –

  • offset_tstep_fraction (float) –

  • remove_offset_waypoint (bool) –

hold_partial_pose: bool = False
release_partial_pose: bool = False
hold_vec_weight: Tensor | None = None
reach_partial_pose: bool = False
reach_full_pose: bool = False
reach_vec_weight: Tensor | None = None
offset_position: Tensor | None = None
offset_rotation: Tensor | None = None
offset_tstep_fraction: float = -1.0
remove_offset_waypoint: bool = False
clone()
classmethod create_grasp_approach_metric(offset_position=0.5, linear_axis=2, tstep_fraction=0.6, tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32))

Enables moving to a pregrasp and then locked orientation movement to final grasp.

Since this is added as a cost, the trajectory will not reach the exact offset, instead it will try to take a blended path to the final grasp without stopping at the offset.

Parameters:
  • offset_position (float) – offset in meters.

  • linear_axis (int) – specifies the x y or z axis.

  • tstep_fraction (float) – specifies the timestep fraction to start activating this constraint.

  • tensor_args (TensorDeviceType) – cuda device.

Returns:

cost metric.

Return type:

PoseCostMetric

classmethod reset_metric()
Return type:

PoseCostMetric

class curobo.rollout.cost.pose_cost.PoseCost(config)

Bases: CostBase, PoseCostConfig

Initialize class

Parameters:
  • config (Optional[CostConfig], optional) – To initialize this class directly, pass a config.

  • class (If this is a base) –

  • CostConfig. (it's assumed that you will initialize the child class with) –

  • None. (Defaults to) –

update_metric(metric)
Parameters:

metric (PoseCostMetric) –

hold_partial_pose(run_vec_weight)
Parameters:

run_vec_weight (Tensor) –

release_partial_pose()
reach_partial_pose(vec_weight)
Parameters:

vec_weight (Tensor) –

reach_full_pose()
update_offset_waypoint(offset_position=None, offset_rotation=None, offset_tstep_fraction=0.75)
Parameters:
  • offset_position (Tensor | None) –

  • offset_rotation (Tensor | None) –

  • offset_tstep_fraction (float) –

remove_offset_waypoint()
update_run_weight(run_tstep_fraction=0.0, run_weight=None)
Parameters:
  • run_tstep_fraction (float) –

  • run_weight (float | None) –

update_batch_size(batch_size, horizon)
property goalset_index_buffer
_forward_goal_distribution(ee_pos_batch, ee_rot_batch, ee_goal_pos, ee_goal_rot)
_forward_single_goal(ee_pos_batch, ee_rot_batch, ee_goal_pos, ee_goal_rot)
_forward_pytorch(ee_pos_batch, ee_rot_batch, ee_goal_pos, ee_goal_rot)
_update_cost_type(ee_goal_pos, ee_pos_batch, num_goals)
forward_out_distance(ee_pos_batch, ee_rot_batch, goal, link_name=None)
Parameters:
  • goal (Goal) –

  • link_name (str | None) –

forward(ee_pos_batch, ee_rot_batch, goal, link_name=None)

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Parameters:
  • goal (Goal) –

  • link_name (str | None) –

forward_pose(goal_pose, query_pose, batch_pose_idx, mode=PoseErrorType.BATCH_GOAL)
Parameters: