Skip to content

Commit d9375d1

Browse files
author
ipuch
committed
fix(dof names in pinocchio models interface)
1 parent 338f7fc commit d9375d1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pyorerun/model_interfaces/pinocchio_model_interface.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ def mesh_path(self) -> list[str]:
6363
".mesh",
6464
".ply",
6565
]:
66-
if self._mesh_dir and not os.path.isabs(mesh_path_str):
67-
mesh_path_str = str(self._mesh_dir / mesh_path_str)
6866
mesh_paths.append(mesh_path_str)
6967
return mesh_paths
7068

@@ -275,8 +273,21 @@ def nb_q(self) -> int:
275273
def dof_names(self) -> tuple[str, ...]:
276274
"""
277275
Returns the names of all degrees of freedom.
276+
277+
Notes
278+
-----
279+
We need to skip the first joint (universe) as it has no DoFs.
280+
Joint DoFs can have individual names if they have multiple DoFs (e.g., a 3-DoF joint).
278281
"""
279-
return tuple(self.model.names[1:]) # Skip universe/world
282+
dof_names = []
283+
for joint, name in zip(self.model.joints[1:], self.model.names[1:]):
284+
if joint.nq == 0:
285+
continue
286+
287+
for k in range(joint.nq):
288+
dof_names.append(f"{name}_{k}")
289+
290+
return tuple(dof_names)
280291

281292
@cached_property
282293
def q_ranges(self) -> tuple[tuple[float, float], ...]:

0 commit comments

Comments
 (0)