Skip to content

Commit 4e19516

Browse files
authored
Merge pull request #85 from Ipuch/main
fix: live animation for any model
2 parents d205120 + f2dd207 commit 4e19516

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pyorerun/live_animation.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class LiveModelAnimation:
1818
A counter to keep track of the number of updates.
1919
model : BiorbdModel
2020
The biorbd model to animate.
21-
biorbd_model : biorbd.Model
22-
The underlying biorbd model.
2321
q : np.ndarray
2422
The current joint angles.
2523
dof_sliders : list
@@ -45,9 +43,8 @@ def __init__(self, model_updater: ModelUpdater, with_q_charts: bool = False):
4543
self.counter = 0
4644
self.model_updater = model_updater
4745
self.model = self.model_updater.model
48-
self.biorbd_model = self.model.model
4946

50-
self.q = np.zeros(self.biorbd_model.nbQ())
47+
self.q = np.zeros(self.model.nb_q)
5148
self.dof_sliders = []
5249
self.dof_slider_values = []
5350
self.update_functions = []
@@ -89,16 +86,16 @@ def update_model(self, q: np.ndarray):
8986
self.model_updater.to_rerun(q)
9087

9188
def update_trajectories(self, q: np.ndarray):
92-
q_ranges = [q_range for segment in self.biorbd_model.segments() for q_range in segment.QRanges()]
89+
q_ranges = self.model.q_ranges
9390
dof_names = self.model.dof_names
94-
for joint_idx in range(self.biorbd_model.nbQ()):
91+
for joint_idx in range(self.model.nb_q):
9592
name = f"q{joint_idx} - {dof_names[joint_idx]}"
9693
rr.log(f"{name}/min", rr.SeriesLines(colors=[255, 0, 0], names="min", widths=0.5))
9794
rr.log(f"{name}/max", rr.SeriesLines(colors=[255, 0, 0], names="max", widths=0.5))
9895
rr.log(f"{name}/value", rr.SeriesLines(colors=[0, 255, 0], names="q", widths=0.5))
9996

10097
q_range = q_ranges[joint_idx]
101-
self.to_serie_line(name=name, min=q_range.min(), max=q_range.max(), val=q[joint_idx])
98+
self.to_serie_line(name=name, min=q_range[0], max=q_range[-1], val=q[joint_idx])
10299

103100
def to_serie_line(self, name: str, min: float, max: float, val: float):
104101
rr.log(f"{name}/min", rr.Scalars(min))
@@ -115,7 +112,7 @@ def create_window_with_sliders(self):
115112
root = tk.Tk()
116113
root.title("Degree of Freedom q Sliders")
117114

118-
for i in range(self.model.model.nbQ()):
115+
for i in range(self.model.nb_q):
119116
self.update_functions.append(lambda event, idx=i: self.update_viewer(event, idx))
120117
dof_slider_label = ttk.Label(root, text=f"q{i} - {self.model.dof_names[i]}: ", anchor="w")
121118
dof_slider_label.grid(row=i, column=0, padx=10, pady=5, sticky="w")

0 commit comments

Comments
 (0)