Skip to content

Commit 2316e3b

Browse files
authored
Merge pull request #48 from ami-iit/add-velocity-representations
Add velocity representations
2 parents 6cc8e24 + b1bc5e0 commit 2316e3b

24 files changed

+1809
-515
lines changed

Diff for: README.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

8-
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:
8+
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:
99

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

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

46-
### Installation with pip
46+
### 🐍 Installation with pip
4747

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

@@ -99,7 +99,7 @@ cd ADAM
9999
pip install .[selected-interface]
100100
```
101101

102-
### Installation with conda
102+
### 📦 Installation with conda
103103

104104
#### Installation from conda-forge package
105105

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

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

112-
#### Installation from repo
112+
### 🔨 Installation from repo
113113

114114
Install in a conda environment the required dependencies:
115115

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

156156
```python
157+
import adam
157158
from adam.jax import KinDynComputations
158159
import icub_models
159160
import numpy as np
@@ -171,6 +172,10 @@ joints_name_list = [
171172
# Specify the root link
172173
root_link = 'root_link'
173174
kinDyn = KinDynComputations(model_path, joints_name_list, root_link)
175+
# choose the representation, if you want to use the body fixed representation
176+
kinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)
177+
# or, if you want to use the mixed representation (that is the default)
178+
kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)
174179
w_H_b = np.eye(4)
175180
joints = np.ones(len(joints_name_list))
176181
M = kinDyn.mass_matrix(w_H_b, joints)
@@ -180,6 +185,7 @@ print(M)
180185
### CasADi interface
181186

182187
```python
188+
import adam
183189
from adam.casadi import KinDynComputations
184190
import icub_models
185191
import numpy as np
@@ -197,6 +203,10 @@ joints_name_list = [
197203
# Specify the root link
198204
root_link = 'root_link'
199205
kinDyn = KinDynComputations(model_path, joints_name_list, root_link)
206+
# choose the representation you want to use the body fixed representation
207+
kinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)
208+
# or, if you want to use the mixed representation (that is the default)
209+
kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)
200210
w_H_b = np.eye(4)
201211
joints = np.ones(len(joints_name_list))
202212
M = kinDyn.mass_matrix_fun()
@@ -206,6 +216,7 @@ print(M(w_H_b, joints))
206216
### PyTorch interface
207217

208218
```python
219+
import adam
209220
from adam.pytorch import KinDynComputations
210221
import icub_models
211222
import numpy as np
@@ -223,6 +234,10 @@ joints_name_list = [
223234
# Specify the root link
224235
root_link = 'root_link'
225236
kinDyn = KinDynComputations(model_path, joints_name_list, root_link)
237+
# choose the representation you want to use the body fixed representation
238+
kinDyn.set_frame_velocity_representation(adam.Representations.BODY_FIXED_REPRESENTATION)
239+
# or, if you want to use the mixed representation (that is the default)
240+
kinDyn.set_frame_velocity_representation(adam.Representations.MIXED_REPRESENTATION)
226241
w_H_b = np.eye(4)
227242
joints = np.ones(len(joints_name_list))
228243
M = kinDyn.mass_matrix(w_H_b, joints)

Diff for: src/adam/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Copyright (C) 2021 Istituto Italiano di Tecnologia (IIT). All rights reserved.
22
# This software may be modified and distributed under the terms of the
33
# GNU Lesser General Public License v2.1 or any later version.
4+
5+
from adam.core import Representations

Diff for: src/adam/casadi/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# This software may be modified and distributed under the terms of the
33
# GNU Lesser General Public License v2.1 or any later version.
44

5-
from .computations import KinDynComputations
65
from .casadi_like import CasadiLike
6+
from .computations import KinDynComputations

Diff for: src/adam/casadi/casadi_like.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def array(*x) -> "CasadiLike":
128128
Returns:
129129
CasadiLike: Vector wrapping *x
130130
"""
131-
return CasadiLike(cs.DM(*x))
131+
return CasadiLike(cs.SX(*x))
132132

133133

134134
class SpatialMath(SpatialMath):

0 commit comments

Comments
 (0)