Skip to content

Commit

Permalink
Merge pull request #48 from ami-iit/add-velocity-representations
Browse files Browse the repository at this point in the history
Add velocity representations
  • Loading branch information
Giulero authored Oct 17, 2023
2 parents 6cc8e24 + b1bc5e0 commit 2316e3b
Show file tree
Hide file tree
Showing 24 changed files with 1,809 additions and 515 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

**Automatic Differentiation for rigid-body-dynamics AlgorithMs**

ADAM implements a collection of algorithms for calculating rigid-body dynamics for **floating-base** robots, in _mixed representation_ (see [Traversaro's A Unified View of the Equations of Motion used for Control Design of Humanoid Robots](https://www.researchgate.net/publication/312200239_A_Unified_View_of_the_Equations_of_Motion_used_for_Control_Design_of_Humanoid_Robots)) using:
ADAM implements a collection of algorithms for calculating rigid-body dynamics for **floating-base** robots, in _mixed_ and _base fixed representations_, also called _left trivialized_ representation (see [Traversaro's A Unified View of the Equations of Motion used for Control Design of Humanoid Robots](https://www.researchgate.net/publication/312200239_A_Unified_View_of_the_Equations_of_Motion_used_for_Control_Design_of_Humanoid_Robots)) using:

- [Jax](https://github.com/google/jax)
- [CasADi](https://web.casadi.org/)
Expand Down Expand Up @@ -43,7 +43,7 @@ They will be installed in the installation step!

The installation can be done either using the Python provided by apt (on Debian-based distros) or via conda (on Linux and macOS).

### Installation with pip
### 🐍 Installation with pip

Install `python3`, if not installed (in **Ubuntu 20.04**):

Expand Down Expand Up @@ -99,7 +99,7 @@ cd ADAM
pip install .[selected-interface]
```

### Installation with conda
### 📦 Installation with conda

#### Installation from conda-forge package

Expand All @@ -109,7 +109,7 @@ mamba create -n adamenv -c conda-forge adam-robotics

If you want to use `jax` or `pytorch`, just install the corresponding package as well.

#### Installation from repo
### 🔨 Installation from repo

Install in a conda environment the required dependencies:

Expand Down Expand Up @@ -154,6 +154,7 @@ Have also a look at te `tests` folder.
### Jax interface

```python
import adam
from adam.jax import KinDynComputations
import icub_models
import numpy as np
Expand All @@ -171,6 +172,10 @@ joints_name_list = [
# Specify the root link
root_link = 'root_link'
kinDyn = KinDynComputations(model_path, joints_name_list, root_link)
# choose the representation, if you want to use the body fixed representation
kinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)
# or, if you want to use the mixed representation (that is the default)
kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)
w_H_b = np.eye(4)
joints = np.ones(len(joints_name_list))
M = kinDyn.mass_matrix(w_H_b, joints)
Expand All @@ -180,6 +185,7 @@ print(M)
### CasADi interface

```python
import adam
from adam.casadi import KinDynComputations
import icub_models
import numpy as np
Expand All @@ -197,6 +203,10 @@ joints_name_list = [
# Specify the root link
root_link = 'root_link'
kinDyn = KinDynComputations(model_path, joints_name_list, root_link)
# choose the representation you want to use the body fixed representation
kinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)
# or, if you want to use the mixed representation (that is the default)
kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)
w_H_b = np.eye(4)
joints = np.ones(len(joints_name_list))
M = kinDyn.mass_matrix_fun()
Expand All @@ -206,6 +216,7 @@ print(M(w_H_b, joints))
### PyTorch interface

```python
import adam
from adam.pytorch import KinDynComputations
import icub_models
import numpy as np
Expand All @@ -223,6 +234,10 @@ joints_name_list = [
# Specify the root link
root_link = 'root_link'
kinDyn = KinDynComputations(model_path, joints_name_list, root_link)
# choose the representation you want to use the body fixed representation
kinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)
# or, if you want to use the mixed representation (that is the default)
kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)
w_H_b = np.eye(4)
joints = np.ones(len(joints_name_list))
M = kinDyn.mass_matrix(w_H_b, joints)
Expand Down
2 changes: 2 additions & 0 deletions src/adam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Copyright (C) 2021 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# GNU Lesser General Public License v2.1 or any later version.

from adam.core import Representations
2 changes: 1 addition & 1 deletion src/adam/casadi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# This software may be modified and distributed under the terms of the
# GNU Lesser General Public License v2.1 or any later version.

from .computations import KinDynComputations
from .casadi_like import CasadiLike
from .computations import KinDynComputations
2 changes: 1 addition & 1 deletion src/adam/casadi/casadi_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def array(*x) -> "CasadiLike":
Returns:
CasadiLike: Vector wrapping *x
"""
return CasadiLike(cs.DM(*x))
return CasadiLike(cs.SX(*x))


class SpatialMath(SpatialMath):
Expand Down
Loading

0 comments on commit 2316e3b

Please sign in to comment.