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

Shape error related to the pyomeca update again #16

Merged
merged 2 commits into from
Aug 16, 2019
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
24 changes: 12 additions & 12 deletions BiorbdViz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def __init__(self, model_path=None, loaded_model=None,

# Load and store the model
if loaded_model is not None:
if not isinstance(loaded_model, biorbd.s2mMusculoSkeletalModel):
raise TypeError("loaded_model should be of a biorbd.s2mMusculoSkeletalModel type")
if not isinstance(loaded_model, biorbd.Model):
raise TypeError("loaded_model should be of a biorbd.Model type")
self.model = loaded_model
elif model_path is not None:
self.model = biorbd.s2mMusculoSkeletalModel(model_path)
self.model = biorbd.Model(model_path)
else:
raise ValueError("loaded_model or model_path must be provided")

Expand Down Expand Up @@ -82,13 +82,13 @@ def __init__(self, model_path=None, loaded_model=None,
for group_idx in range(self.model.nbMuscleGroups()):
for muscle_idx in range(self.model.muscleGroup(group_idx).nbMuscles()):
musc_tp = self.model.muscleGroup(group_idx).muscle(muscle_idx)
muscle_type = biorbd.s2mMusculoSkeletalModel.getMuscleType(musc_tp)
muscle_type = biorbd.Model.getMuscleType(musc_tp).getString()
if muscle_type == "Hill":
musc = biorbd.s2mMuscleHillType(musc_tp)
musc = biorbd.HillType(musc_tp)
elif muscle_type == "HillThelen":
musc = biorbd.s2mMuscleHillTypeThelen(musc_tp)
musc = biorbd.HillTypeThelen(musc_tp)
elif muscle_type == "HillSimple":
musc = biorbd.s2mMuscleHillTypeSimple(musc_tp)
musc = biorbd.HillTypeSimple(musc_tp)
tp = np.ndarray((3, len(musc.position().musclesPointsInGlobal()), 1))
for k, pts in enumerate(musc.position().musclesPointsInGlobal()):
tp[:, k, 0] = pts.get_array()
Expand Down Expand Up @@ -148,7 +148,7 @@ def set_q(self, Q, refresh_window=True):
raise TypeError(f"Q should be a {self.nQ} column vector")
self.Q = Q

self.model.UpdateKinematicsCustom(self.model, biorbd.s2mGenCoord(self.Q))
self.model.UpdateKinematicsCustom(self.model, biorbd.GeneralizedCoordinates(self.Q))
if self.show_muscles:
self.__set_muscles_from_q()
if self.show_rt:
Expand Down Expand Up @@ -500,13 +500,13 @@ def __set_muscles_from_q(self):
for group_idx in range(self.model.nbMuscleGroups()):
for muscle_idx in range(self.model.muscleGroup(group_idx).nbMuscles()):
musc_tp = self.model.muscleGroup(group_idx).muscle(muscle_idx)
muscle_type = biorbd.s2mMusculoSkeletalModel.getMuscleType(musc_tp)
muscle_type = biorbd.Model.getMuscleType(musc_tp).getString()
if muscle_type == "Hill":
musc = biorbd.s2mMuscleHillType(musc_tp)
musc = biorbd.HillType(musc_tp)
elif muscle_type == "HillThelen":
musc = biorbd.s2mMuscleHillTypeThelen(musc_tp)
musc = biorbd.HillTypeThelen(musc_tp)
elif muscle_type == "HillSimple":
musc = biorbd.s2mMuscleHillTypeSimple(musc_tp)
musc = biorbd.HillTypeSimple(musc_tp)
for k, pts in enumerate(musc.position().musclesPointsInGlobal()):
self.muscles.get_frame(0)[idx][0:3, k] = pts.get_array()
idx += 1
Expand Down
10 changes: 5 additions & 5 deletions BiorbdViz/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(self, parent, main_window, background_color=(.5, .5, .5)):
for group in range(self.model.nbMuscleGroups()):
for mus in range(self.model.muscleGroup(group).nbMuscles()):
# Map the name to the right numbers
name = biorbd.s2mMuscleHillType.getRef(self.model.muscleGroup(group).muscle(mus)).name()
name = biorbd.HillType.getRef(self.model.muscleGroup(group).muscle(mus)).name().getString()
self.muscle_mapping[name] = (group, mus, cmp_mus)

# Add the CheckBox
Expand Down Expand Up @@ -212,7 +212,7 @@ def __get_muscle_lengths(self, q_idx, mus_group_idx, mus_idx, _):
x_axis, all_q = self.__generate_x_axis(q_idx)
length = np.ndarray(x_axis.shape)
for i, q_mod in enumerate(all_q):
length[i] = biorbd.s2mMuscleHillType.getRef(
length[i] = biorbd.HillType.getRef(
self.model.muscleGroup(mus_group_idx).muscle(mus_idx)).length(self.model, q_mod)
return x_axis, length

Expand All @@ -224,7 +224,7 @@ def __get_moment_arms(self, q_idx, _, __, mus_idx):
return x_axis, moment_arm

def __get_passive_forces(self, q_idx, mus_group_idx, mus_idx, _):
mus = biorbd.s2mMuscleHillType.getRef(self.model.muscleGroup(mus_group_idx).muscle(mus_idx))
mus = biorbd.HillType.getRef(self.model.muscleGroup(mus_group_idx).muscle(mus_idx))
x_axis, all_q = self.__generate_x_axis(q_idx)
passive_forces = np.ndarray(x_axis.shape)
for i, q_mod in enumerate(all_q):
Expand All @@ -233,8 +233,8 @@ def __get_passive_forces(self, q_idx, mus_group_idx, mus_idx, _):
return x_axis, passive_forces

def __get_active_forces(self, q_idx, mus_group_idx, mus_idx, _):
mus = biorbd.s2mMuscleHillType.getRef(self.model.muscleGroup(mus_group_idx).muscle(mus_idx))
emg = biorbd.s2mMuscleStateActual(0, self.active_forces_slider.value()/100)
mus = biorbd.HillType.getRef(self.model.muscleGroup(mus_group_idx).muscle(mus_idx))
emg = biorbd.StateDynamics(0, self.active_forces_slider.value()/100)
x_axis, all_q = self.__generate_x_axis(q_idx)
active_forces = np.ndarray(x_axis.shape)
for i, q_mod in enumerate(all_q):
Expand Down
6 changes: 3 additions & 3 deletions BiorbdViz/biorbd_vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,9 @@ def update_rt(self, all_rt):
# Update the end points of the axes and the origin
pts = vtkPoints()
pts.InsertNextPoint(rt.translation())
pts.InsertNextPoint(rt.translation() + rt[0:3, 0] * self.rt_length)
pts.InsertNextPoint(rt.translation() + rt[0:3, 1] * self.rt_length)
pts.InsertNextPoint(rt.translation() + rt[0:3, 2] * self.rt_length)
pts.InsertNextPoint(rt.translation() + rt[0:3, 0, :] * self.rt_length)
pts.InsertNextPoint(rt.translation() + rt[0:3, 1, :] * self.rt_length)
pts.InsertNextPoint(rt.translation() + rt[0:3, 2, :] * self.rt_length)

# Update polydata in mapper
lines_poly_data = self.rt_actors[i].GetMapper().GetInput()
Expand Down