embodichain.learning#
Learning layers, shared models and reinforcement-learning systems.
Subpackages load on demand so standalone layers do not import RL or simulation.
Submodules
|
Simulation-independent differentiable robotics layers for Torch networks. |
General neural networks, normalization and network construction. |
|
On-policy reinforcement learning pipeline. |
|
|
Supervised learning (SL) for policies and learned state transitions. |
Reinforcement Learning#
On-policy reinforcement learning pipeline.
Algorithms (PPO/GRPO), rollout buffers, collectors, and the training entry point; rollout data flows as TensorDict objects.
Algorithm registry and construction helpers ( |
|
On-policy rollout buffer ( |
|
Collectors that step vectorized environments and assemble rollout data into a preallocated |
|
RL helper utilities: algorithm config, optimizers, and observation helpers. |
Differentiable layers#
learning.layers composes simulation-independent computation as Torch modules.
KinematicsLayer owns fixed TCP and limit buffers; its copied PK geometry follows
to(device/dtype). Reconstruct the same robot model before loading a checkpoint;
its geometry fingerprint is checked. DifferentiableIKLayer.forward returns joints
for network composition, while solve returns residuals and a success mask.
Both retain input gradients in training and evaluation mode. Callers own rollout
state, optimizers, and detach boundaries.
|
Expose FK and differentiable Jacobians as a reusable network layer. |
|
Compose fixed-step DLS with a differentiable kinematics module. |
Torch module interface to fixed robot geometry, independent of simulation.
Classes:
Expose FK and differentiable Jacobians as a reusable network layer. |
- class embodichain.learning.layers.kinematics.KinematicsLayer[source]#
Expose FK and differentiable Jacobians as a reusable network layer.
- Parameters:
model (
SerialChainKinematics) – Fixed kinematics model, copied so device moves are independent.tcp (
Tensor|None) – Optional flange-to-tool rigid transform.lower (
Tensor|None) – Optional physical lower limits; defaults to the chain limits.upper (
Tensor|None) – Optional physical upper limits; defaults to the chain limits.
Note
Geometry is configured, not trained. Checkpoints store TCP and limits and verify the identity of the model supplied at reconstruction time.
load_state_dict(assign=True)adopts checkpoint device and precision for both tensor buffers and fixed geometry, including nested loads.train()andeval()do not disable input gradients.Methods:
__init__(model[, tcp, lower, upper])Initialize internal Module state, shared by both nn.Module and ScriptModule.
Return bounded joint midpoints, or projected zero for unbounded joints.
evaluate(qpos)Return TCP transforms and root-frame geometric Jacobians.
forward(qpos)Return root-frame TCP transforms for
(..., dof)joints.Record fixed geometry identity alongside tensor buffers.
jacobian(qpos)Return differentiable TCP Jacobians, shape
(..., 6, dof).set_extra_state(state)Reject checkpoints belonging to a different kinematic model.
Attributes:
Number of movable joints in solver order.
- __init__(model, tcp=None, lower=None, upper=None)[source]#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- default_seed()[source]#
Return bounded joint midpoints, or projected zero for unbounded joints.
- Return type:
Tensor
- property dof: int#
Number of movable joints in solver order.
- evaluate(qpos)[source]#
Return TCP transforms and root-frame geometric Jacobians.
- Return type:
tuple[Tensor,Tensor]
- get_extra_state()[source]#
Record fixed geometry identity alongside tensor buffers.
- Return type:
dict[str,str]
A graph-preserving IK layer for supervised and policy learning.
Classes:
Compose fixed-step DLS with a differentiable kinematics module. |
- class embodichain.learning.layers.ik.DifferentiableIKLayer[source]#
Compose fixed-step DLS with a differentiable kinematics module.
- Parameters:
kinematics (
KinematicsLayer) – Model owning geometry, TCP and physical limit buffers.cfg (
DifferentiableIKCfg|None) – Numerical settings, copied at construction.
Note
There is no recurrent seed state or optimizer inside this module. The caller owns rollout state and backpropagation boundaries.
Methods:
__init__(kinematics[, cfg])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(target_xpos[, qpos_seed])Return joint positions while retaining target and seed gradients.
Save numerical settings with the module checkpoint.
set_extra_state(state)Restore and validate numerical settings.
solve(target_xpos[, qpos_seed])Return final joints, validity and differentiable TCP residuals.
- __init__(kinematics, cfg=None)[source]#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(target_xpos, qpos_seed=None)[source]#
Return joint positions while retaining target and seed gradients.
- Return type:
Tensor
- get_extra_state()[source]#
Save numerical settings with the module checkpoint.
- Return type:
dict[str,Any]
- solve(target_xpos, qpos_seed=None)[source]#
Return final joints, validity and differentiable TCP residuals.
- Parameters:
target_xpos (
Tensor) – Root-frame TCP transforms, shape(..., 4, 4).qpos_seed (
Tensor|None) –(dof,)or matching batch dimensions; None uses midpoints.
- Return type:
- Returns:
Result retaining the target’s leading batch dimensions.
Supervised learning#
Policies and learned dynamics share tensor-tree batches, objective-owned losses,
optimizer updates and committed-update recovery through learning.sl.