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
11 changes: 8 additions & 3 deletions bionc/vizualization/pyorerun_interface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from pyorerun.biorbd_components.model_display_options import DisplayModelOptions
from ..bionc_numpy import NaturalVector
from ..bionc_numpy import NaturalVector, NaturalCoordinates
from ..bionc_numpy.joints import Joint
from ..protocols.biomechanical_model import GenericBiomechanicalModel

Expand Down Expand Up @@ -51,6 +51,10 @@ def nb_segments(self) -> int:
def segments(self) -> tuple["BioncSegment", ...]:
return tuple(BioncSegment(s, i) for i, s in enumerate(self.model.segments.values()))

@property
def segment_names_with_mass(self) -> tuple[str, ...]:
return tuple([segment.name for segment in self.model.segments.values() if segment.mass > 0])

def segment_homogeneous_matrices_in_global(self, q: np.ndarray, segment_index: int) -> np.ndarray:
"""
Returns a biorbd object containing the roto-translation matrix of the segment in the global reference frame.
Expand All @@ -63,11 +67,12 @@ def segment_homogeneous_matrices_in_global(self, q: np.ndarray, segment_index: i

return transform

def center_of_mass(self, q: np.ndarray) -> np.ndarray:
def centers_of_mass(self, q: np.ndarray) -> np.ndarray:
"""
Returns the position of the center of mass in the global reference frame
"""
pass
Q = NaturalCoordinates(q[:, None])
return self.model.center_of_mass_position(Q).squeeze().T

@property
def nb_ligaments(self) -> int:
Expand Down
19 changes: 10 additions & 9 deletions examples/play_with_joints/two_constant_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ def main(initial_pose: str = "hanged", show_results: bool = True):
all_states=all_states,
dynamics=dynamics,
)

# animation
from pyorerun import PhaseRerun
from bionc.vizualization.pyorerun_interface import BioncModelNoMesh

prr = PhaseRerun(t_span=time_steps)
model_interface = BioncModelNoMesh(model)
prr.add_animated_model(model_interface, NaturalCoordinates(all_states[: (12 * model.nb_segments), :]))
prr.rerun()

# plot results

import matplotlib.pyplot as plt
Expand All @@ -196,15 +206,6 @@ def main(initial_pose: str = "hanged", show_results: bool = True):
plt.legend()
plt.show()

# animation
from pyorerun import PhaseRerun
from bionc.vizualization.pyorerun_interface import BioncModelNoMesh

prr = PhaseRerun(t_span=time_steps)
model_interface = BioncModelNoMesh(model)
prr.add_animated_model(model_interface, NaturalCoordinates(all_states[: (12 * model.nb_segments), :]))
prr.rerun()


if __name__ == "__main__":
# main("hanged", show_results=True)
Expand Down
37 changes: 24 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,31 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
- numpy
- packaging
"numpy",
"packaging",
# "ezc3d", # Not yet available on pypi, use `conda install -c conda-forge ezc3d`
- plotly
- pyorerun
- python >=3.9
- casadi
- dill
- mesa-libgl-devel-cos7-x86_64
- pyomeca
- numba
"plotly",
"pyorerun",
"python >=3.9",
"casadi",
"dill",
"mesa-libgl-devel-cos7-x86_64",
"pyomeca",
"numba",
# "biorbd" # Not yet available on pypi, use `conda install -c conda-forge biorbd`
]
keywords = ["inverse-kinematics", "biomechanics", "multibody-dynamics", "mechanics motion-analysis", "kinesiology", "inverse-dynamics, "cartesian-coordinates", "forward-dynamics", "holonomic-constraints", "natural-coordinates"]

]
keywords = [
"inverse-kinematics",
"biomechanics",
"multibody-dynamics",
"mechanics",
"motion-analysis",
"kinesiology",
"inverse-dynamics",
"cartesian-coordinates",
"forward-dynamics",
"holonomic-constraints",
"natural-coordinates"
]
[project.urls]
homepage = "http://github.com/Ipuch/bionc"
Loading