Skip to content
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
42ec0f0
Simplify urdf_remove_sensors_tags by returning the modified XML strin…
Giulero Jan 15, 2025
91b4a6e
Refactor CasadiLike operations constraining operations just between C…
Giulero Jan 22, 2025
7020662
Refactor RBDAlgorithms to use _convert_to_arraylike for input handlin…
Giulero Jan 22, 2025
4dcac43
Refactor StdJoint to build the numeric properties directly with Array…
Giulero Jan 22, 2025
896f657
Refactor StdLink to set inertia properties using a dedicated method a…
Giulero Jan 22, 2025
2bb351b
Enhance ArrayLike class with length, representation, and list convers…
Giulero Jan 22, 2025
0a46df7
use directly inertia matrix in the spatial inertia method
Giulero Jan 22, 2025
0492671
Add wrapping methods for array-like in SpatialMath class. We need to …
Giulero Jan 22, 2025
b792865
Refactor Pose and Inertia classes to ArrayLike types directly. Add st…
Giulero Jan 22, 2025
196d46b
Add Inertia to abc_factories import in model module
Giulero Jan 22, 2025
81de461
Update mass calculation to use ArrayLike.array
Giulero Jan 22, 2025
dd31e3a
Update usual copyright information
Giulero Jan 22, 2025
198fac6
Refactor TorchLike and SpatialMath methods to streamline array handli…
Giulero Jan 22, 2025
f4af98a
Refactor JaxLike and SpatialMath methods to remove type checks and st…
Giulero Jan 22, 2025
4df03a7
Refactor NumpyLike and SpatialMath methods to eliminate type checks a…
Giulero Jan 22, 2025
ae80ccc
Update tests to use SpatialMath.array for random quantity generation
Giulero Jan 22, 2025
9f45fd7
Add Array API support with ArrayAPILike and ArrayAPIFactory classes
Giulero Aug 28, 2025
e32b849
Rename array method to asarray and enhance type handling in CasadiLik…
Giulero Aug 28, 2025
b27cded
Refactor JaxLike and JaxLikeFactory to inherit from ArrayAPILike and …
Giulero Aug 28, 2025
cdf640b
Refactor TorchLike and TorchLikeFactory to inherit from ArrayAPILike …
Giulero Aug 28, 2025
b2989f8
Refactor NumpyLike and NumpyLikeFactory to inherit from ArrayAPILike …
Giulero Aug 28, 2025
9e8c74f
Rename array method to asarray and update references in SpatialMath, …
Giulero Aug 28, 2025
bb81414
Rename array method to asarray in RBDAlgorithms class for consistency
Giulero Aug 28, 2025
a951335
Refactor tests_setup to replace SpatialMath with scipy's Rotation for…
Giulero Aug 28, 2025
8688479
Remove unused import of SpatialMath from tests/conftest.py
Giulero Sep 3, 2025
e663f48
Remove commented-out methods in TorchLike and TorchLikeFactory classes
Giulero Sep 3, 2025
cddade0
Update setup_test fixture to use CPU device and increase sample size …
Giulero Sep 3, 2025
83c8f83
Make methods batch compatible and avoid item assignement
Giulero Sep 3, 2025
4edfb0b
Refactor Array API math functions
Giulero Sep 3, 2025
da01536
Commit working modified (and batched methods)
Giulero Sep 3, 2025
029692f
Refactor KinDynComputationsBatch to remove unnecessary function wrapp…
Giulero Sep 3, 2025
383b112
Refactor H_revolute_joint and inertia matrix computation
Giulero Sep 4, 2025
0352301
Return vector in motion subspace for fixed joints
Giulero Sep 4, 2025
15cfb2d
Fix spatial inertia
Giulero Sep 5, 2025
4261158
Add crba implementation. It needs to be adapted to batched operations
Giulero Sep 5, 2025
01d9ced
crba working for batched inputs
Giulero Sep 5, 2025
4098fb2
Fix jacobian and jacobian dot
Giulero Sep 5, 2025
e971eec
Add batched rnea function
Giulero Sep 5, 2025
bcbed21
Fix method
Giulero Sep 5, 2025
b9a430f
Enhance spec_from_reference to handle JAX compatibility and add unsqu…
Giulero Sep 5, 2025
f79af54
Refactor KinDynComputations to use spec_from_reference for SpatialMat…
Giulero Sep 5, 2025
bffd539
Remove unused function definitions
Giulero Sep 5, 2025
fb0ace8
Remove unused methods and streamline initialization with ArraySpec su…
Giulero Sep 5, 2025
2905de7
Remove commented-out methods and streamline initialization with Array…
Giulero Sep 5, 2025
275a47f
Fix motion_subspace method to return correct dimensions for fixed and…
Giulero Sep 5, 2025
4c4ea2c
Fix some methods
Giulero Sep 6, 2025
6474152
Improve (?) matrix operations and output dimensions
Giulero Sep 6, 2025
aa116be
Reshaping in RNEA calculations for consistency
Giulero Sep 6, 2025
ef1ef69
Comment out jax2torch and add array-api-compat as dependency
Giulero Sep 6, 2025
6e48f36
Uncomment jax2torch in setup configuration for dependencies
Giulero Sep 6, 2025
e8ef3f5
Refactor tau stacking in RBDAlgorithms
Giulero Sep 6, 2025
c1a2b25
Use more explicit naming
Giulero Sep 8, 2025
b9ce1c0
Update batch size calculation to use base_transform for consistency i…
Giulero Sep 8, 2025
ce08e48
Working implentation of casadi class.Need to refactor
Giulero Sep 8, 2025
9936704
Remove reference implementations of CRBA and RNEA
Giulero Sep 8, 2025
e547916
Refactor batching of xyz, rpy, and axis in H_revolute_joint to use ar…
Giulero Sep 8, 2025
5109d0d
Tentative of clean up. Still not totally satisfactory
Giulero Sep 8, 2025
4287abe
Remove unnecessary device argument in zeros_like and ones_like
Giulero Sep 8, 2025
c766326
Remove default dtype setting and fix concatenation in jacobian_dot test
Giulero Sep 8, 2025
94c2014
Refactor tests to support comparison with batch of idyntree data
Giulero Sep 8, 2025
e98735c
Add tests for jax batched computations
Giulero Sep 8, 2025
bb3ec3a
Clean up unused code
Giulero Sep 8, 2025
2bec3a0
Remove unused unsqueeze method and clean up
Giulero Sep 8, 2025
42a0e31
Remove unnecessary unsqueeze operation
Giulero Sep 8, 2025
cfb90db
Cleanup code and document concatenate
Giulero Sep 8, 2025
cceb48d
Remove unused squeeze
Giulero Sep 8, 2025
cb4abb8
Refactor to use _to_sequence and _to_scalar to align to new implement…
Giulero Sep 8, 2025
240336f
Remove commented-out __setitem__ method from ArrayLike class
Giulero Sep 8, 2025
1e9e050
Refactor spatial_inertial_with_parameter
Giulero Sep 8, 2025
394a2a0
Remove unnecessary reshaping of base_velocity and zero arrays
Giulero Sep 9, 2025
1f1390c
Fix method name spatial_inertial_with_parameters to spatial_inertia_w…
Giulero Sep 9, 2025
87144c9
Refactor CasadiLikeFactory to initialize with a default CasADi type a…
Giulero Sep 9, 2025
99952d3
Fix total mass assertion in test_total_mass to use cs.DM
Giulero Sep 9, 2025
b747215
Enable 64-bit precision in JAX tests
Giulero Sep 9, 2025
fac6bf1
Fix vertical concatenation
Giulero Sep 9, 2025
4f81179
Fix eye to device
Giulero Sep 9, 2025
339103f
Improve handling of CasADi types in _to_sequence and _to_scalar funct…
Giulero Sep 9, 2025
0e4d9b8
Fix total mass assertion in test_total_mass to use cs.DM
Giulero Sep 9, 2025
08dff0e
Remove blanck lines
Giulero Sep 9, 2025
6ca29e2
Use set_axis and set_limits methods
Giulero Sep 9, 2025
fb3eef4
Add Pose handling, refactor mass and inertia calculations
Giulero Sep 9, 2025
62459e5
Refactor tensor conversion to numpy in tests if tensor is on cuda device
Giulero Sep 9, 2025
bce3853
Refactor KinDynComputationsBatch class documentation and change dtype…
Giulero Sep 9, 2025
c6b3c84
Refactor tests
Giulero Sep 9, 2025
7394336
Use dtype parameter for array initializations
Giulero Sep 9, 2025
794ab05
Remove jax2torch dependency from configuration files
Giulero Sep 9, 2025
d078fcb
Fix array-api-compat dependency naming in CI environment files
Giulero Sep 9, 2025
c7a3747
Update README to replace jax2torch with array-api-compat
Giulero Sep 9, 2025
8a0aaba
Remove references to jax2torch and related notes from documentation
Giulero Sep 9, 2025
20e8729
Change tensor data type from float32 to float64
Giulero Sep 9, 2025
9e47cb6
Remove leftover comments
Giulero Sep 9, 2025
2d4503d
Update src/adam/core/array_api_math.py
Giulero Sep 9, 2025
d829afa
Merge branch 'main' into array-api-compat
Giulero Sep 9, 2025
385f29b
Apply black
Giulero Sep 9, 2025
e39ee46
Update readme
Giulero Sep 9, 2025
90c4bff
Remove duplicated __rmatmul__ method
Giulero Sep 10, 2025
6ad8393
Ensure array be on same device when having also grandient
Giulero Sep 10, 2025
f819e14
Refactor tensor conversion to handle CUDA devices in tests
Giulero Sep 10, 2025
828259d
Make dataclasses frozen and use slots for tentative increased efficie…
Giulero Sep 10, 2025
ea12f46
Refactor tests to utilize shared to_numpy function and device fixture…
Giulero Sep 10, 2025
70fadb4
move import torch to device() fixture
Giulero Sep 10, 2025
c956015
Refactor limit setting to use joint type for bounds (inf for prismati…
Giulero Sep 10, 2025
cc6078d
Remove wrapping on already wrapped quantities
Giulero Sep 10, 2025
8513e37
Remove and cleanup comments
Giulero Sep 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@

### Table of contents

- [🐍 Dependencies](#-dependencies)
- [💾 Installation](#-installation)
- [🐍 Installation with pip](#-installation-with-pip)
- [📦 Installation with conda](#-installation-with-conda)
- [Installation from conda-forge package](#installation-from-conda-forge-package)
- [🔨 Installation from repo](#-installation-from-repo)
- [🚀 Usage](#-usage)
- [Jax interface](#jax-interface)
- [CasADi interface](#casadi-interface)
- [PyTorch interface](#pytorch-interface)
- [PyTorch Batched interface](#pytorch-batched-interface)
- [🦸‍♂️ Contributing](#️-contributing)
- [Todo](#todo)
- [adam](#adam)
- [Table of contents](#table-of-contents)
- [🐍 Dependencies](#-dependencies)
- [💾 Installation](#-installation)
- [🐍 Installation with pip](#-installation-with-pip)
- [📦 Installation with conda](#-installation-with-conda)
- [Installation from conda-forge package](#installation-from-conda-forge-package)
- [🔨 Installation from repo](#-installation-from-repo)
- [🚀 Usage](#-usage)
- [Jax interface](#jax-interface)
- [CasADi interface](#casadi-interface)
- [PyTorch interface](#pytorch-interface)
- [PyTorch Batched interface](#pytorch-batched-interface)
- [Inverse Kinematics](#inverse-kinematics)
- [🦸‍♂️ Contributing](#️-contributing)
- [Todo](#todo)

## 🐍 Dependencies

Expand All @@ -43,7 +46,7 @@ Other requisites are:
- `casadi`
- `pytorch`
- `numpy`
- `jax2torch`
- `array-api-compat`

They will be installed in the installation step!

Expand Down Expand Up @@ -145,25 +148,25 @@ Install in a conda environment the required dependencies:
- **Jax** interface dependencies:

```bash
conda create -n adamenv -c conda-forge jax numpy lxml prettytable matplotlib urdfdom-py
conda create -n adamenv -c conda-forge jax numpy lxml prettytable matplotlib urdfdom-py array-api-compat
```

- **CasADi** interface dependencies:

```bash
conda create -n adamenv -c conda-forge casadi numpy lxml prettytable matplotlib urdfdom-py
conda create -n adamenv -c conda-forge casadi numpy lxml prettytable matplotlib urdfdom-py array-api-compat
```

- **PyTorch** interface dependencies:

```bash
conda create -n adamenv -c conda-forge pytorch numpy lxml prettytable matplotlib urdfdom-py jax2torch
conda create -n adamenv -c conda-forge pytorch numpy lxml prettytable matplotlib urdfdom-py array-api-compat
```

- **ALL** interfaces dependencies:

```bash
conda create -n adamenv -c conda-forge jax casadi pytorch numpy lxml prettytable matplotlib urdfdom-py jax2torch
conda create -n adamenv -c conda-forge jax casadi pytorch numpy lxml prettytable matplotlib urdfdom-py array-api-compat
```

Activate the environment, clone the repo and install the library:
Expand Down Expand Up @@ -316,8 +319,6 @@ print(M)

### PyTorch Batched interface

> [!NOTE]
> When using this interface, note that the first call of the jitted function can be slow, since JAX needs to compile the function. Then it will be faster!

```python
import adam
Expand Down
2 changes: 1 addition & 1 deletion ci_env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ dependencies:
- idyntree >=11.0.0
- jax<=0.6.0
- pytorch
- jax2torch
- requests
- array-api-compat
- liecasadi
1 change: 1 addition & 0 deletions ci_env_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ dependencies:
- idyntree >=11.0.0
- requests
- liecasadi
- array-api-compat
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ adam


**adam** employs the automatic differentiation capabilities of these frameworks to compute, if needed, gradients, Jacobian, Hessians of rigid-body dynamics quantities. This approach enables the design of optimal control and reinforcement learning strategies in robotics.
Thanks to the `jax.vmap`-ing and `jax.jit`-ing capabilities, the algorithms can be run on batches of inputs, which are possibly converted to PyTorch using the `jax2torch` conversion functions.


**adam** is based on **Roy Featherstone's Rigid Body Dynamics Algorithms**.
Expand Down
13 changes: 1 addition & 12 deletions docs/modules/pytorch_batched.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
PyTorch Batched interface
=========================

This module implements the batched version of the Rigid Body Dynamics algorithms using PyTorch.
This module uses Jax under the hood, then the functions are ``jax.vmap``-ed and ``jax.jit``-ed to run on batches of inputs, which are ultimately converted to PyTorch using the ``jax2torch`` conversion functions.

.. note::

The first time you run a function from this module, it will take a bit longer to execute as they are being compiled by Jax.


.. note::

If the GPU support for ``JAX`` is needed, follow the instructions in the `Jax documentation <https://jax.readthedocs.io/en/latest/installation.html#conda-community-supported>`_.

This module implements the batched version of the Rigid Body Dynamics algorithms using PyTorch.

----------------

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ dependencies = [
"casadi>=3.6",
"prettytable",
"urdfdom-py",
"array-api-compat",
]

[project.optional-dependencies]
jax = ["jax<=0.6.0", "jaxlib"]
casadi = ["casadi"]
pytorch = ["torch", "jax", "jaxlib", "jax2torch"]
pytorch = ["torch", "jax", "jaxlib"]
test = [
"jax<=0.6.0",
"jaxlib",
Expand All @@ -46,12 +47,11 @@ test = [
"idyntree",
"icub-models",
"black",
"jax2torch",
"requests",
"liecasadi",
]
conversion = ["idyntree"]
all = ["jax", "jaxlib", "casadi>=3.6", "torch", "jax2torch"]
all = ["jax", "jaxlib", "casadi>=3.6", "torch"]

[project.urls]
"Documentation" = "https://adam-robotics.readthedocs.io/en/latest/"
Expand Down
Loading
Loading