Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge devel in main #1

Merged
merged 39 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
77d99d1
First version of Computation class
Giulero May 26, 2021
e8210cd
Adding install structure
Giulero May 26, 2021
03a806a
Adding tests
Giulero May 26, 2021
830b4c7
Adding iCub urdf model
Giulero May 26, 2021
8129833
Adding jupyter example file
Giulero May 26, 2021
9d03cbd
Update .gitignore
Giulero May 26, 2021
b78017e
Update readme
Giulero May 27, 2021
0e91269
Adding more infos
Giulero May 27, 2021
cd1651c
Formatting with pep8
Giulero May 27, 2021
b5215b7
Update tests
Giulero May 27, 2021
e659901
Fix typo
Giulero May 27, 2021
60db00f
Update readme
Giulero May 27, 2021
9cca2a6
Remove useless comment
Giulero May 27, 2021
fc9be15
Add github action
Giulero May 27, 2021
1e1c841
Fix action
Giulero May 27, 2021
1ee338f
Update .gitignore
Giulero Jun 4, 2021
419d16e
Restructure project
Giulero Jun 4, 2021
f0227f5
Fix setup
Giulero Jun 4, 2021
80330b9
Update tests.yml
Giulero Jun 4, 2021
47bdd7c
Update tests
Giulero Jun 4, 2021
483873d
Update example
Giulero Jun 4, 2021
62f4fc8
Fix github action
Giulero Jun 4, 2021
5f1af76
Fix missing dependency
Giulero Jun 4, 2021
672a209
Remove urdf (replaced using gym-ignition)
Giulero Jun 4, 2021
5936520
Format with black and move jit option in the constructor
Giulero Jun 4, 2021
24b33e9
raise NotImplementedError
Giulero Jun 4, 2021
b2a90d6
Adding logging module to show the robot structure
Giulero Jun 4, 2021
8fc856a
Update README
Giulero Jun 4, 2021
03300e8
Fix dataclasses usage
Giulero Jun 4, 2021
76ad23d
Changing fun generation option
Giulero Jun 4, 2021
6234757
Update example
Giulero Jun 7, 2021
4192e10
Update readme
Giulero Jun 7, 2021
719b0b7
Add action also on push
Giulero Jun 7, 2021
18d8576
Fix indentation in .cfg
Giulero Jun 7, 2021
9075496
Revomove useless rw property
Giulero Jun 7, 2021
d0a13c7
Change mutable types pattern in Tree dataclass
Giulero Jun 7, 2021
35779ae
Prune gh action commands
Giulero Jun 7, 2021
9630f2f
Cleanup
Giulero Jun 7, 2021
0137451
Small cleanup
Giulero Jun 8, 2021
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
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Adam

on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install idyntree
pip install gym-ignition
pip install .
- name: Test with pytest
run: |
pytest
139 changes: 139 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
**.vscode
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
86 changes: 85 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,86 @@
# ADAM
Automatic Differentiation for rigid body dynamics algorithMs

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

This library implements kinematics and dynamics algorithms 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)).

ADAM employs [CasADi](https://web.casadi.org/), which embeds the computed kinematics and dynamics quantities in expression graphs and provides if needed, gradients, Jacobians, and Hessians. This approach enables the design of optimal control strategies in robotics. Using its `CodeGenerator`, CasADi enables also the generation of C-code - usable also in `Matlab` or `C++`.

Adam is based on Roy Featherstone's Rigid Body Dynamics Algorithms.

This work is still at an early stage and bugs could jump out!
PRs are welcome! :rocket:

## :hammer: Dependencies

- [`python3`](https://wiki.python.org/moin/BeginnersGuide)

Other requisites are:

- `urdf_parser_py`
- `casadi`

They will be installed in the installation step!

## :floppy_disk: Installation

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

```bash
sudo apt install python3.8
```

Clone the repo and install the library:

```bash
git clone https://github.com/dic-iit/ADAM.git
cd ADAM
pip install .
```

preferably in a [virtual environment](https://docs.python.org/3/library/venv.html#venv-def): for example:

```bash
pip install virtualenv
python3 -m venv your_virtual_env
```

## :rocket: Usage

```python
from adam.core.computations import KinDynComputations
import gym_ignition_models
import numpy as np

# if you want to use gym-ignition https://github.com/robotology/gym-ignition to retrieve the urdf
model_path = gym_ignition_models.get_model_file("iCubGazeboV2_5")
# The joint list
joints_name_list = [
'torso_pitch', 'torso_roll', 'torso_yaw', 'l_shoulder_pitch',
'l_shoulder_roll', 'l_shoulder_yaw', 'l_elbow', 'r_shoulder_pitch',
'r_shoulder_roll', 'r_shoulder_yaw', 'r_elbow', 'l_hip_pitch', 'l_hip_roll',
'l_hip_yaw', 'l_knee', 'l_ankle_pitch', 'l_ankle_roll', 'r_hip_pitch',
'r_hip_roll', 'r_hip_yaw', 'r_knee', 'r_ankle_pitch', 'r_ankle_roll'
]
# Specify the root link
root_link = 'root_link'
kinDyn = KinDynComputations(urdf_path, joints_name_list, root_link)
w_H_b = np.eye(4)
joints = np.ones(len(joints_name_list))
M = kinDyn.mass_matrix_fun()
print(M(w_H_b, joints))
```

## Todo

- [x] Center of Mass position
- [x] Jacobians
- [x] Forward kinematics
- [x] Mass Matrix via CRBA
- [x] Centroidal Momentum Matrix via CRBA
- [ ] Recursive Newton-Euler algorithm
- [ ] Articulated Body algorithm

---

The structure of the library is inspired by the module [urdf2casadi](https://github.com/mahaarbo/urdf2casadi/blob/master/README.md), which generates kinematic and dynamics quantities using CasADi. Please check their interesting work!
2 changes: 2 additions & 0 deletions adam/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import core
from . import geometry
1 change: 1 addition & 0 deletions adam/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import computations
Loading