curobo.curobolib.kinematics module
- curobo.curobolib.kinematics.rotation_matrix_to_quaternion(in_mat, out_quat)
- class curobo.curobolib.kinematics.KinematicsFusedFunction(*args, **kwargs)
Bases:
Function
- static _call_cuda(link_pos_out, link_quat_out, robot_sphere_out, global_cumul_mat, angle, fixed_transform, robot_spheres, link_map, joint_map, joint_map_type, store_link_map, link_sphere_map)
- static _call_backward_cuda(grad_out, link_pos_out, link_quat_out, robot_sphere_out, global_cumul_mat, angle, fixed_transform, robot_spheres, link_map, joint_map, joint_map_type, store_link_map, link_sphere_map, link_chain_map, sparsity_opt=True)
- static forward(ctx, link_pos, link_quat, b_robot_spheres, global_cumul_mat, joint_seq, fixed_transform, robot_spheres, link_map, joint_map, joint_map_type, store_link_map, link_sphere_map, link_chain_map, grad_out)
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:
link_pos (Tensor) –
link_quat (Tensor) –
b_robot_spheres (tensor) –
global_cumul_mat (Tensor) –
joint_seq (Tensor) –
fixed_transform (tensor) –
robot_spheres (tensor) –
link_map (tensor) –
joint_map (Tensor) –
joint_map_type (Tensor) –
store_link_map (Tensor) –
link_sphere_map (Tensor) –
link_chain_map (Tensor) –
grad_out (Tensor) –
- static backward(ctx, grad_out_link_pos, grad_out_link_quat, grad_out_spheres)
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
KinematicsFusedFunctionBackward
- class curobo.curobolib.kinematics.KinematicsFusedGlobalCumulFunction(*args, **kwargs)
Bases:
Function
- static _call_cuda(link_pos_out, link_quat_out, robot_sphere_out, global_cumul_mat, angle, fixed_transform, robot_spheres, link_map, joint_map, joint_map_type, store_link_map, link_sphere_map)
- static _call_backward_cuda(grad_out, link_pos_out, link_quat_out, robot_sphere_out, global_cumul_mat, angle, fixed_transform, robot_spheres, link_map, joint_map, joint_map_type, store_link_map, link_sphere_map, link_chain_map, sparsity_opt=True)
- static forward(ctx, link_pos, link_quat, b_robot_spheres, global_cumul_mat, joint_seq, fixed_transform, robot_spheres, link_map, joint_map, joint_map_type, store_link_map, link_sphere_map, link_chain_map, grad_out)
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:
link_pos (Tensor) –
link_quat (Tensor) –
b_robot_spheres (tensor) –
global_cumul_mat (Tensor) –
joint_seq (Tensor) –
fixed_transform (tensor) –
robot_spheres (tensor) –
link_map (tensor) –
joint_map (Tensor) –
joint_map_type (Tensor) –
store_link_map (Tensor) –
link_sphere_map (Tensor) –
link_chain_map (Tensor) –
grad_out (Tensor) –
- static backward(ctx, grad_out_link_pos, grad_out_link_quat, grad_out_spheres)
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
KinematicsFusedGlobalCumulFunctionBackward
- curobo.curobolib.kinematics.get_cuda_kinematics(link_pos_seq, link_quat_seq, batch_robot_spheres, global_cumul_mat, q_in, fixed_transform, link_spheres_tensor, link_map, joint_map, joint_map_type, store_link_map, link_sphere_idx_map, link_chain_map, grad_out_q, use_global_cumul=True)
- Parameters:
use_global_cumul (bool) –