Skip to content

Commit 3b601e7

Browse files
authored
Merge pull request #77 from EveCharbie/biobuddy
[RTR] BioBuddy interface
2 parents a90569c + e17def4 commit 3b601e7

File tree

6 files changed

+389
-2
lines changed

6 files changed

+389
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,4 @@ cython_debug/
168168
sandbox/
169169

170170
.DS_Store
171+
.aider*

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ And also animate biorbd models from the pyomeca organization.
66

77
``` conda install -c conda-forge pyorerun rerun-sdk=0.24.1```
88
``` conda install opensim-org::opensim # not a mandatory dependency```
9+
``` conda install -c conda-forge biobuddy=0.2.0 # not a mandatory dependency```
910

1011
# Rerun .c3d - As simple as that
1112

@@ -62,6 +63,10 @@ animation.rerun()
6263
if you want to use the OpenSim, you also need to install separately:
6364
```conda install -c opensim-org::opensim```
6465

66+
if you want to use the BioBuddy, you also need to install separately:
67+
```conda install -c conda-forge biobuddy=0.2.0``` or
68+
```pip install biobuddy==0.2.0```
69+
6570
Then, ensure it is accessible in your Python environment by installing the package:
6671

6772
``` pip install . ``` or ``` python setup.py install ```
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""
2+
To run this example, you need to install biobuddy:
3+
`pip install biobuddy == 0.2.0`
4+
or
5+
`conda-forge install -c conda-forge biobuddy=0.2.0`
6+
"""
7+
8+
import numpy as np
9+
import biobuddy
10+
11+
from pyorerun import PhaseRerun, BiobuddyModel, DisplayModelOptions
12+
13+
14+
def main():
15+
16+
# building some time components
17+
nb_frames = 50
18+
nb_seconds = 1
19+
t_span = np.linspace(0, nb_seconds, nb_frames)
20+
21+
# Creating the model
22+
model_path = "../biorbd/models/Wu_Shoulder_Model_kinova_scaled_adjusted_2.bioMod"
23+
biobuddy_model = biobuddy.BiomechanicalModelReal().from_biomod(model_path)
24+
biobuddy_model.change_mesh_directories("../biorbd/models/Geometry_cleaned")
25+
display_options = DisplayModelOptions()
26+
prr_model = BiobuddyModel.from_biobuddy_object(biobuddy_model, options=display_options)
27+
28+
# building some generalized coordinates
29+
q = np.zeros((biobuddy_model.nb_q, nb_frames))
30+
q[10, :] = np.linspace(0, np.pi / 8, nb_frames)
31+
q[12, :] = np.linspace(0, np.pi / 3, nb_frames)
32+
q[11, :] = np.linspace(0, np.pi / 4, nb_frames)
33+
q[13, :] = np.linspace(0, np.pi / 8, nb_frames)
34+
q[14, :] = np.linspace(0, np.pi / 8, nb_frames)
35+
q[15, :] = np.linspace(0, np.pi / 8, nb_frames)
36+
37+
# Animate the model
38+
viz = PhaseRerun(t_span)
39+
viz.add_animated_model(prr_model, q)
40+
# viz.rerun("msk_model")
41+
viz.rerun_by_frame("msk_model")
42+
43+
44+
if __name__ == "__main__":
45+
main()

pyorerun/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,24 @@
33
from .model_components.model_display_options import DisplayModelOptions
44
from .model_components.model_updapter import ModelUpdater
55

6+
# Opensim
67
try:
78
from .model_interfaces import (
89
OsimModel,
910
OsimModelNoMesh,
1011
)
1112
except ImportError:
12-
# OpenSim n'est pas installé, ces classes ne seront pas disponibles
13+
# OpenSim is not installed, these classes will not be available
14+
pass
15+
16+
# biobuddy
17+
try:
18+
from .model_interfaces import (
19+
BiobuddyModel,
20+
BiobuddyModelNoMesh,
21+
)
22+
except ImportError:
23+
# BioBuddy is not installed, these classes will not be available
1324
pass
1425

1526
from .model_interfaces import (
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
from .abstract_model_interface import AbstractSegment, AbstractModel, AbstractModelNoMesh
22
from .biorbd_model_interface import BiorbdModelNoMesh, BiorbdModel
33

4+
# Opensim
45
try:
56
from .osim_model_interface import OsimModelNoMesh, OsimModel
67
except ImportError:
7-
# OpenSim n'est pas installé, ces classes ne seront pas disponibles
8+
# OpenSim is not installed, these classes will not be available
9+
pass
10+
11+
# Biobuddy
12+
try:
13+
from .biobuddy_model_interface import BiobuddyModelNoMesh, BiobuddyModel
14+
except ImportError:
15+
# BioBuddy is not installed, these classes will not be available
816
pass
917

1018
from .available_interfaces import model_from_file

0 commit comments

Comments
 (0)