Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying SoftContactSphere #60

Merged
merged 6 commits into from
Oct 21, 2021
Merged
Changes from 1 commit
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
67 changes: 34 additions & 33 deletions bioviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,30 +282,30 @@ def _get_data_from_casadi(self, Q=None, compute_kin=True):

class Viz:
def __init__(
self,
model_path=None,
loaded_model=None,
show_meshes=True,
patch_color=(0.89, 0.855, 0.788),
show_global_center_of_mass=True,
show_segments_center_of_mass=True,
segments_center_of_mass_size=0.005,
show_global_ref_frame=True,
show_local_ref_frame=True,
show_markers=True,
experimental_markers_color=(1, 1, 1),
markers_size=0.010,
show_contacts=True,
contacts_size=0.010,
show_soft_contacts=True,
soft_contacts_color=(0.11, 0.63, 0.95),
show_muscles=True,
show_wrappings=True,
show_analyses_panel=True,
background_color=(0.5, 0.5, 0.5),
force_wireframe=False,
experimental_forces_colors=(85, 78, 0),
**kwargs,
self,
model_path=None,
loaded_model=None,
show_meshes=True,
patch_color=(0.89, 0.855, 0.788),
show_global_center_of_mass=True,
show_segments_center_of_mass=True,
segments_center_of_mass_size=0.005,
show_global_ref_frame=True,
show_local_ref_frame=True,
show_markers=True,
experimental_markers_color=(1, 1, 1),
markers_size=0.010,
show_contacts=True,
contacts_size=0.010,
show_soft_contacts=True,
soft_contacts_color=(0.11, 0.63, 0.95),
show_muscles=True,
show_wrappings=True,
show_analyses_panel=True,
background_color=(0.5, 0.5, 0.5),
force_wireframe=False,
experimental_forces_colors=(85, 78, 0),
**kwargs,
):
"""
Class that easily shows a biorbd model
Expand Down Expand Up @@ -334,14 +334,14 @@ def __init__(
show_contacts = False
show_muscles = False
show_wrappings = False
show_soft_contact = False,
show_soft_contact = (False,)
pariterre marked this conversation as resolved.
Show resolved Hide resolved

# Create the plot
self.vtk_window = VtkWindow(background_color=background_color)
self.vtk_markers_size = markers_size

# soft_contact sphere sizes
radius =[]
radius = []
for i in range(self.model.nbSoftContacts()):
c = self.model.softContact(i)
if c.typeOfNode() == biorbd.SOFT_CONTACT_SPHERE:
Expand Down Expand Up @@ -860,7 +860,7 @@ def __move_avatar_from_sliders(self):
self.set_q(self.Q)

def __update_muscle_analyses_graphs(
self, skip_muscle_length, skip_moment_arm, skip_passive_forces, skip_active_forces
self, skip_muscle_length, skip_moment_arm, skip_passive_forces, skip_active_forces
):
# Adjust muscle analyses if needed
if self.active_analyses_widget == self.analyses_muscle_widget:
Expand Down Expand Up @@ -1021,7 +1021,8 @@ def load_experimental_markers(self, data, auto_start=True, ignore_animation_warn
)

self.vtk_model_markers = VtkModel(
self.vtk_window, markers_color=self.experimental_markers_color, markers_size=self.vtk_markers_size)
self.vtk_window, markers_color=self.experimental_markers_color, markers_size=self.vtk_markers_size
)

self.__set_movement_slider()
self.show_experimental_markers = True
Expand All @@ -1032,7 +1033,7 @@ def load_experimental_markers(self, data, auto_start=True, ignore_animation_warn
self.__start_stop_animation()

def load_experimental_forces(
self, data, segments=None, normalization_ratio=0.2, auto_start=True, ignore_animation_warning=True
self, data, segments=None, normalization_ratio=0.2, auto_start=True, ignore_animation_warning=True
):
if isinstance(data, (np.ndarray, xr.DataArray)):
self.experimental_forces = data if isinstance(data, xr.DataArray) else xr.DataArray(data)
Expand Down Expand Up @@ -1070,7 +1071,7 @@ def __set_markers_from_q(self):
def __set_experimental_markers_from_frame(self):
t_slider = self.movement_slider[0].value() - 1
t = t_slider if t_slider < self.experimental_markers.shape[2] else self.experimental_markers.shape[2] - 1
self.vtk_model_markers.update_markers(self.experimental_markers[:, :, t: t + 1].isel(time=[0]))
self.vtk_model_markers.update_markers(self.experimental_markers[:, :, t : t + 1].isel(time=[0]))

def __set_experimental_forces_from_frame(self):
segment_names = []
Expand Down Expand Up @@ -1105,7 +1106,7 @@ def __set_experimental_forces_from_frame(self):
t_slider = self.movement_slider[0].value() - 1
t = t_slider if t_slider < self.experimental_forces.shape[2] else self.experimental_forces.shape[2] - 1
self.vtk_model.update_force(
segment_jcs, self.experimental_forces[:, :, t: t + 1], max_forces, self.force_normalization_ratio
segment_jcs, self.experimental_forces[:, :, t : t + 1], max_forces, self.force_normalization_ratio
)

def __set_contacts_from_q(self):
Expand Down Expand Up @@ -1152,8 +1153,8 @@ def __set_wrapping_from_q(self):
if self.model.muscle(i).pathModifier().object(j).typeOfNode() == biorbd.WRAPPING_HALF_CYLINDER:
rt = (
biorbd.WrappingHalfCylinder(self.model.muscle(i).pathModifier().object(j))
.RT(self.model, self.Q)
.to_array()
.RT(self.model, self.Q)
.to_array()
)
self.wraps_current[i][j][0:3, :, 0] = np.dot(rt, wrap[:, :, 0])[0:3, :]
else:
Expand Down