Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,4 @@ cython_debug/
sandbox/

.DS_Store
.aider*
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ And also animate biorbd models from the pyomeca organization.

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

# Rerun .c3d - As simple as that

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

if you want to use the BioBuddy, you also need to install separately:
```conda install -c conda-forge biobuddy=0.2.0``` or
```pip install biobuddy==0.2.0```

Then, ensure it is accessible in your Python environment by installing the package:

``` pip install . ``` or ``` python setup.py install ```
Expand Down
45 changes: 45 additions & 0 deletions examples/biobuddy/from_biobuddy_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
To run this example, you need to install biobuddy:
`pip install biobuddy == 0.2.0`
or
`conda-forge install -c conda-forge biobuddy=0.2.0`
"""

import numpy as np
import biobuddy

from pyorerun import PhaseRerun, BiobuddyModel, DisplayModelOptions


def main():

# building some time components
nb_frames = 50
nb_seconds = 1
t_span = np.linspace(0, nb_seconds, nb_frames)

# Creating the model
model_path = "../biorbd/models/Wu_Shoulder_Model_kinova_scaled_adjusted_2.bioMod"
biobuddy_model = biobuddy.BiomechanicalModelReal().from_biomod(model_path)
biobuddy_model.change_mesh_directories("../biorbd/models/Geometry_cleaned")
display_options = DisplayModelOptions()
prr_model = BiobuddyModel.from_biobuddy_object(biobuddy_model, options=display_options)

# building some generalized coordinates
q = np.zeros((biobuddy_model.nb_q, nb_frames))
q[10, :] = np.linspace(0, np.pi / 8, nb_frames)
q[12, :] = np.linspace(0, np.pi / 3, nb_frames)
q[11, :] = np.linspace(0, np.pi / 4, nb_frames)
q[13, :] = np.linspace(0, np.pi / 8, nb_frames)
q[14, :] = np.linspace(0, np.pi / 8, nb_frames)
q[15, :] = np.linspace(0, np.pi / 8, nb_frames)

# Animate the model
viz = PhaseRerun(t_span)
viz.add_animated_model(prr_model, q)
# viz.rerun("msk_model")
viz.rerun_by_frame("msk_model")


if __name__ == "__main__":
main()
13 changes: 12 additions & 1 deletion pyorerun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
from .model_components.model_display_options import DisplayModelOptions
from .model_components.model_updapter import ModelUpdater

# Opensim
try:
from .model_interfaces import (
OsimModel,
OsimModelNoMesh,
)
except ImportError:
# OpenSim n'est pas installé, ces classes ne seront pas disponibles
# OpenSim is not installed, these classes will not be available
pass

# biobuddy
try:
from .model_interfaces import (
BiobuddyModel,
BiobuddyModelNoMesh,
)
except ImportError:
# BioBuddy is not installed, these classes will not be available
pass

from .model_interfaces import (
Expand Down
10 changes: 9 additions & 1 deletion pyorerun/model_interfaces/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from .abstract_model_interface import AbstractSegment, AbstractModel, AbstractModelNoMesh
from .biorbd_model_interface import BiorbdModelNoMesh, BiorbdModel

# Opensim
try:
from .osim_model_interface import OsimModelNoMesh, OsimModel
except ImportError:
# OpenSim n'est pas installé, ces classes ne seront pas disponibles
# OpenSim is not installed, these classes will not be available
pass

# Biobuddy
try:
from .biobuddy_model_interface import BiobuddyModelNoMesh, BiobuddyModel
except ImportError:
# BioBuddy is not installed, these classes will not be available
pass

from .available_interfaces import model_from_file
Loading
Loading