Skip to content

Commit 6526901

Browse files
sbohezcopybara-github
authored andcommitted
Add AppendageFixer to regenerate the appendages entries in the trajectories.
PiperOrigin-RevId: 438307923 Change-Id: I9b8abeb2d4b87f1518c5e498d9507fb742fba0df
1 parent ebb0f89 commit 6526901

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

dm_control/locomotion/mocap/loader.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from dm_control.composer import variation
2222
from dm_control.locomotion.mocap import mocap_pb2
2323
from dm_control.locomotion.mocap import trajectory
24+
from dm_control.utils import transformations as tr
2425
import numpy as np
2526

2627
from google.protobuf import descriptor
@@ -232,3 +233,15 @@ def __call__(self, proto, random_state=None):
232233
for prop_pose in t.props:
233234
# shift prop position
234235
self._add_z_offset(prop_pose.position)
236+
237+
238+
class AppendageFixer:
239+
240+
def __call__(self, proto, random_state=None):
241+
for t in proto.timesteps:
242+
for walker_pose in t.walkers:
243+
xpos = np.asarray(walker_pose.position)
244+
xquat = np.asarray(walker_pose.quaternion)
245+
appendages = np.reshape(walker_pose.appendages, (-1, 3))
246+
xmat = tr.quat_to_mat(xquat)[:3, :3]
247+
walker_pose.appendages[:] = np.ravel((appendages - xpos) @ xmat)

0 commit comments

Comments
 (0)