curobo.curobolib.geom module
- curobo.curobolib.geom.get_self_collision_distance(out_distance, out_vec, sparse_index, robot_spheres, collision_offset, weight, coll_matrix, thread_locations, thread_size, b_size, nspheres, compute_grad, checks_per_thread=32, experimental_kernel=True)
- class curobo.curobolib.geom.SelfCollisionDistance(*args, **kwargs)
Bases:
Function
- static forward(ctx, out_distance, out_vec, sparse_idx, robot_spheres, sphere_offset, weight, coll_matrix, thread_locations, max_thread, checks_per_thread, experimental_kernel, return_loss=False)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
checks_per_thread (int) –
experimental_kernel (bool) –
return_loss (bool) –
- static backward(ctx, grad_out_distance)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
SelfCollisionDistanceBackward
- class curobo.curobolib.geom.SelfCollisionDistanceLoss(*args, **kwargs)
Bases:
SelfCollisionDistance
- static backward(ctx, grad_out_distance)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
SelfCollisionDistanceLossBackward
- curobo.curobolib.geom.get_pose_distance(out_distance, out_position_distance, out_rotation_distance, out_p_vec, out_q_vec, out_idx, current_position, goal_position, current_quat, goal_quat, vec_weight, weight, vec_convergence, run_weight, run_vec_weight, offset_waypoint, offset_tstep_fraction, batch_pose_idx, batch_size, horizon, mode=1, num_goals=1, write_grad=False, write_distance=False, use_metric=False, project_distance=True)
- curobo.curobolib.geom.get_pose_distance_backward(out_grad_p, out_grad_q, grad_distance, grad_p_distance, grad_q_distance, pose_weight, grad_p_vec, grad_q_vec, batch_size, use_distance=False)
- class curobo.curobolib.geom.PoseErrorDistance(*args, **kwargs)
Bases:
Function
- static forward(ctx, current_position, goal_position, current_quat, goal_quat, vec_weight, weight, vec_convergence, run_weight, run_vec_weight, offset_waypoint, offset_tstep_fraction, batch_pose_idx, out_distance, out_position_distance, out_rotation_distance, out_p_vec, out_r_vec, out_idx, out_p_grad, out_q_grad, batch_size, horizon, mode, num_goals, use_metric, project_distance)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.
- static backward(ctx, grad_out_distance, grad_g_dist, grad_r_err, grad_out_idx)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
PoseErrorDistanceBackward
- class curobo.curobolib.geom.PoseError(*args, **kwargs)
Bases:
Function
- static forward(ctx, current_position, goal_position, current_quat, goal_quat, vec_weight, weight, vec_convergence, run_weight, run_vec_weight, offset_waypoint, offset_tstep_fraction, batch_pose_idx, out_distance, out_position_distance, out_rotation_distance, out_p_vec, out_r_vec, out_idx, out_p_grad, out_q_grad, batch_size, horizon, mode, num_goals, use_metric, project_distance, return_loss)
Compute error in pose
_extended_summary_
- Parameters:
ctx – _description_
current_position (Tensor) – _description_
goal_position (Tensor) – _description_
current_quat (Tensor) – _description_
goal_quat – _description_
vec_weight – _description_
weight – _description_
vec_convergence – _description_
run_weight – _description_
run_vec_weight – _description_
offset_waypoint – _description_
offset_tstep_fraction – _description_
batch_pose_idx – _description_
out_distance – _description_
out_position_distance – _description_
out_rotation_distance – _description_
out_p_vec – _description_
out_r_vec – _description_
out_idx – _description_
out_p_grad – _description_
out_q_grad – _description_
batch_size – _description_
horizon – _description_
mode – _description_
num_goals – _description_
use_metric – _description_
project_distance – _description_
return_loss – _description_
- Returns:
_description_
- static backward(ctx, grad_out_distance)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
PoseErrorBackward
- class curobo.curobolib.geom.SdfSphereOBB(*args, **kwargs)
Bases:
Function
- static forward(ctx, query_sphere, out_buffer, grad_out_buffer, sparsity_idx, weight, activation_distance, box_accel, box_dims, box_pose, box_enable, n_env_obb, env_query_idx, max_nobs, batch_size, horizon, n_spheres, transform_back, compute_distance, use_batch_env, return_loss=False)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
return_loss (bool) –
- static backward(ctx, grad_output)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
SdfSphereOBBBackward
- class curobo.curobolib.geom.SdfSweptSphereOBB(*args, **kwargs)
Bases:
Function
- static forward(ctx, query_sphere, out_buffer, grad_out_buffer, sparsity_idx, weight, activation_distance, speed_dt, box_accel, box_dims, box_pose, box_enable, n_env_obb, env_query_idx, max_nobs, batch_size, horizon, n_spheres, sweep_steps, enable_speed_metric, transform_back, compute_distance, use_batch_env, return_loss=False)
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx: Any, *args: Any, **kwargs: Any) -> Any: pass
It must accept a context ctx as the first argument, followed by any number of arguments (tensors or other types).
See combining-forward-context for more details
Usage 2 (Separate forward and ctx):
@staticmethod def forward(*args: Any, **kwargs: Any) -> Any: pass @staticmethod def setup_context(ctx: Any, inputs: Tuple[Any, ...], output: Any) -> None: pass
The forward no longer accepts a ctx argument.
Instead, you must also override the
torch.autograd.Function.setup_context
staticmethod to handle setting up thectx
object.output
is the output of the forward,inputs
are a Tuple of inputs to the forward.See extending-autograd for more details
The context can be used to store arbitrary data that can be then retrieved during the backward pass. Tensors should not be stored directly on ctx (though this is not currently enforced for backward compatibility). Instead, tensors should be saved either with
ctx.save_for_backward
if they are intended to be used inbackward
(equivalently,vjp
) orctx.save_for_forward
if they are intended to be used for injvp
.- Parameters:
return_loss (bool) –
- static backward(ctx, grad_output)
Defines a formula for differentiating the operation with backward mode automatic differentiation (alias to the vjp function).
This function is to be overridden by all subclasses.
It must accept a context
ctx
as the first argument, followed by as many outputs as theforward
returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward
. Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_grad
as a tuple of booleans representing whether each input needs gradient. E.g.,backward
will havectx.needs_input_grad[0] = True
if the first input toforward
needs gradient computed w.r.t. the output.
- _backward_cls
alias of
SdfSweptSphereOBBBackward