Skip to content

Commit

Permalink
Merge pull request #1 from Gepetto/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
nmansard authored Jan 11, 2024
2 parents c39f3f8 + 6fe05fd commit 5cc2659
Show file tree
Hide file tree
Showing 20 changed files with 1,404 additions and 1,974 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv
18 changes: 5 additions & 13 deletions .github/workflows/gepetuto_test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: check with gepetuto

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: pipx install poetry && poetry install
- name: check with gepetuto
run: poetry run gepetuto -vvca all
python-version: "3.11"
- run: pip install .
- run: gepetuto -vvca all
2 changes: 1 addition & 1 deletion 0-introduction_to_numerical_robotics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions 1-forward_geom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"From (Laitenberger, M., Raison, M., Périé, D., & Begon, M. (2015). Refinement of the upper limb joint kinematics and dynamics using a subject-specific closed-loop forearm model. Multibody System Dynamics, 33(4), 413-438)."
"From (Laitenberger, M., Raison, M., P\u00e9ri\u00e9, D., & Begon, M. (2015). Refinement of the upper limb joint kinematics and dynamics using a subject-specific closed-loop forearm model. Multibody System Dynamics, 33(4), 413-438)."
]
},
{
Expand Down Expand Up @@ -687,7 +687,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
FROM python:3.10
FROM python:3.11

RUN useradd -m user
USER user
WORKDIR /home/user/tp
ENV PATH /home/user/.local/bin:$PATH
CMD jupyter lab --no-browser --ip='*'

ADD --chown=user requirements.txt .
ADD --chown=user . .
RUN git remote set-url origin https://github.com/gepetto/supaero2024
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/home/user/.cache \
python -m pip install --user -U pip \
&& python -m pip install --user -r requirements.txt

ADD --chown=user . .
&& python -m pip install --user .
95 changes: 41 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,96 +6,90 @@ The notebooks are in Python and based on the software [Pinocchio](https://github

## Set up

### Linux, Python 3, PyPI
### Default setup

On a Linux system with Python 3, you can get the dependencies directly with +[pip (see installation procedure and update below)](#installing-pip):
This setup should work on Linux / MacOS / WSL2.

You **must** use a [virtualenv](https://docs.python.org/3/library/venv.html) or a similar.

For example on Debian/Ubuntu, you can get started with:
```bash
python3 -m pip install -r requirements.txt
sudo apt install python-is-python3 python3-pip python3-venv
```

To create a virtual environment and activate it:
```bash
python -m venv .venv
source .venv/bin/activate
```

NB: you should consider using a [virtualenv](https://docs.python.org/3/library/venv.html)
**Once in your virtual environment**, install this package:
```bash
pip install -U pip
pip install .
```

Once you have the dependencies, you can start the server with `jupyter notebook`
After that, you can start the server with `jupyter notebook`

### Docker

On other systems, use use the virtualization provided by +Docker. A Docker image is provided, and can be started with:
If the default setup is not working for you, as a backup solution, a Docker image is provided, and can be started with:

```bash
sudo docker run --rm -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 8888:8888 -v data:/home/user/tp -it gepetto/supaero
docker run --rm -p 7000:7000 -p 7001:7001 -p 7002:7002 -p 7003:7003 -p 7004:7004 -p 8888:8888 -v data:/home/user/tp -it gepetto/supaero2024
```

On Linux host systems, you may simply start the Docker with:

```bash
sudo docker run --rm --net host -v data:/home/user/tp -it gepetto/supaero
docker run --rm --net host -v data:/home/user/tp -it gepetto/supaero
```

In case of big update, you must update the docker:
```bash
sudo docker pull gepetto/supaero
docker pull gepetto/supaero2024
```

## Use

### Update the notebooks

If the repository changes (for example when new tutorials are pushes), you need to update your local
version by "pulling" it from the repository.
On a native installation, just go in the folder containing the tutorials and execute ```git pull```
On a native installation, just go in the folder containing the tutorials and execute `git pull`

With a docker, execute the following:
```bash
sudo docker run --rm -v data:/home/user/tp -it gepetto/supaero git remote set-url origin https://github.com/gepetto/supaero2024
```
Then
```bash
sudo docker run --rm -v data:/home/user/tp -it gepetto/supaero git pull --rebase origin main
docker run --rm -v data:/home/user/tp -it gepetto/supaero git pull --rebase origin main
```

To avoid conflict when pulling a new version, you should better to your modifications in copy of the original files,
To avoid conflict when pulling a new version, you should better do your modifications in copy of the original files,
not directly in the original files itself.

## Side notes

### Installing pip

Pip is a tool for installing and managing Python packages. You can install it with

```bash
sudo apt install python3-pip
```

The default version of +pip installed by +apt is not up to date, so upgrade it with
```bash
python3 -m pip install --upgrade --user
```
### Installing docker

In general, running +pip is likely to run an alias on +pip in /usr, so either run it through python3 as explained above, or make sure your path select the right pip executable in your ~/.local. The option --user is kind of optional for recent +pip version, but removing it should work with a warning.
See [how to get Docker](https://docs.docker.com/get-docker/).

### Installing docker
## Docker as normal user

On linux, install docker with +apt (or see https://docs.docker.com/engine/install/ubuntu/).
To avoid the need to run `sudo docker`:

```bash
sudo apt install docker.io
sudo usermod -aG docker nmansard
newgrp docker
```
On other OS, see [how to get Docker](https://docs.docker.com/get-docker/).


# Join me on \[Matrix\]

[\[Matrix\]](https://matrix.org/) is a distributed chat system that will be used during the class. Consider [creating an account](https://app.element.io/#/register) and join [the classroom channel](https://matrix.to/#/#supaero-robotics-2024:laas.fr).

## Join me on \[Matrix\]

# Set up of the system ... for admin only
[\[Matrix\]](https://matrix.org/) is a distributed chat system that will be used during the class. Consider [creating
an account](https://app.element.io/#/register) and join [the classroom
channel](https://matrix.to/#/#supaero-robotics-2024:laas.fr).

## Compile the code snipets
## Set up of the system ... for admin only

run ```python utils/generate.py```. The directories to be generated are listed in plain code (line 54).
This script take the tp*/*py and produces tp*/generated/* files following the "# %jupyter_snippet" /
"# %end_jupyter_snippet" hashtag in the code.

## Build and push the docker
### Build and push the docker

Build the docker as specified in Dockerfile. You need the buildkit for that. The following file +/etc/docker/deamon_json+ should contain:
```json
Expand All @@ -108,7 +102,7 @@ export DOCKER_BUILDKIT=1
```
Then build:
```bash
docker build . -t gepetto/supaero
docker build -t gepetto/supaero2024 .
```
Log to Docker-hub using your credentials.
```bash
Expand All @@ -117,12 +111,5 @@ docker login
Use the login corresponding to +https://hub.docker.com/+.
And push it to the Gepetto repository of Docker-hub.
```bash
docker build -t gepetto/supaero
```

## Docker as normal user

```bash
sudo usermod -aG docker nmansard
newgrp docker
docker push gepetto/supaero2024
```
4 changes: 2 additions & 2 deletions next/2-inv_geom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
"metadata": {},
"outputs": [],
"source": [
"from supaero2023.meshcat_viewer_wrapper import MeshcatVisualizer, colors # noqa: E402\n",
"from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer, colors # noqa: E402\n",
"\n",
"viz = MeshcatVisualizer(robot)"
]
Expand Down Expand Up @@ -702,7 +702,7 @@
"metadata": {},
"outputs": [],
"source": [
"from supaero2023. load_ur5_parallel import load_ur5_parallel # noqa: E402\n",
"from supaero2024. load_ur5_parallel import load_ur5_parallel # noqa: E402\n",
"\n",
"robot = load_ur5_parallel()"
]
Expand Down
2 changes: 1 addition & 1 deletion next/3-invkine.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"from numpy.linalg import pinv,inv,norm,svd,eig\n",
"from tp3.tiago_loader import loadTiago\n",
"import matplotlib.pylab as plt\n",
"from supaero2023.meshcat_viewer_wrapper import MeshcatVisualizer\n",
"from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer\n",
"import unittest\n"
]
},
Expand Down
2 changes: 1 addition & 1 deletion next/4-dynamics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"import matplotlib.pylab as plt\n",
"import quadprog\n",
"from tp4.robot_hand import RobotHand\n",
"from supaero2023.meshcat_viewer_wrapper import MeshcatVisualizer"
"from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion next/5-2_controlopt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"source": [
"# %load tp5/generated/arm_example_viz\n",
"# Configure viewer\n",
"from supaero2023.meshcat_viewer_wrapper import MeshcatVisualizer\n",
"from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer\n",
"viz = MeshcatVisualizer(robot)\n",
"viz.display(robot_model.q0)\n",
"viz.addBox('world/box',[.1,.1,.1], [1.,0,0,1])\n",
Expand Down
4 changes: 2 additions & 2 deletions next/tp2/generated/parallel_robots_0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from supaero2023.load_ur5_parallel import load_ur5_parallel
from supaero2023.meshcat_viewer_wrapper import MeshcatVisualizer
from supaero2024.load_ur5_parallel import load_ur5_parallel
from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer

# Load 4 Ur5 robots, placed at 0.3m from origin in the 4 directions x,y,-x,-y.
robot = load_ur5_parallel()
Expand Down
2 changes: 1 addition & 1 deletion next/tp3/control_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import numpy as np
import pinocchio as pin
from numpy.linalg import norm, pinv
from tp3.tiago_loader import loadTiago

from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer
from tp3.tiago_loader import loadTiago

plt.ion()

Expand Down
2 changes: 1 addition & 1 deletion next/tp3/generated/inverse_kinematics_import
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import pinocchio as pin
from numpy.linalg import norm, pinv

from tp3.tiago_loader import loadTiago
from supaero2023.meshcat_viewer_wrapper import MeshcatVisualizer
from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer
2 changes: 1 addition & 1 deletion next/tp3/inverse_kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# %jupyter_snippet import
import pinocchio as pin
from numpy.linalg import norm, pinv
from tp3.tiago_loader import loadTiago

from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer
from tp3.tiago_loader import loadTiago

# %end_jupyter_snippet

Expand Down
2 changes: 1 addition & 1 deletion next/tp4/collision_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np
import pinocchio as pin
from tp4.robot_hand import RobotHand

from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer
from tp4.robot_hand import RobotHand


class CollisionWrapper:
Expand Down
2 changes: 1 addition & 1 deletion next/tp4/solution_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import numpy as np
import pinocchio as pin
from numpy.linalg import inv, norm
from tp4.robot_hand import RobotHand

from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer
from tp4.robot_hand import RobotHand

plt.ion()

Expand Down
2 changes: 1 addition & 1 deletion next/tp5/generated/arm_example_viz
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from supaero2023.meshcat_viewer_wrapper import MeshcatVisualizer # noqa E402
from supaero2024.meshcat_viewer_wrapper import MeshcatVisualizer # noqa E402

viz = MeshcatVisualizer(robot)
viz.display(robot_model.q0)
Expand Down
Loading

0 comments on commit 5cc2659

Please sign in to comment.