|
| 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() |
0 commit comments