Skip to content

Commit

Permalink
fix com_pos_b references
Browse files Browse the repository at this point in the history
  • Loading branch information
jtigue-bdai committed Oct 8, 2024
1 parent 1244516 commit 8d8c82b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ def __init__(self, root_physx_view: physx.ArticulationView, device: str):
self._joint_acc = TimestampedBuffer()
self._joint_vel = TimestampedBuffer()

# Link center of mass
self._com_pos_b, _ = self._root_physx_view.get_coms().to(self.device).split([3, 4], dim=-1)

def update(self, dt: float):
# update the simulation timestamp
self._sim_timestamp += dt
Expand Down Expand Up @@ -283,7 +280,7 @@ def root_link_state_w(self):
quat = state[:, 3:7]
# adjust linear velocity to link
state[:, 7:10] += torch.linalg.cross(
state[:, 10:13], math_utils.quat_rotate(quat, -self._com_pos_b[:, 0, :]), dim=-1
state[:, 10:13], math_utils.quat_rotate(quat, -self.com_pos_b[:, 0, :]), dim=-1
)
return state

Expand All @@ -298,7 +295,7 @@ def root_com_state_w(self):
state = self.root_state_w.clone()
quat = state[:, 3:7]
# adjust position to center of mass
state[:, :3] += math_utils.quat_rotate(quat, self._com_pos_b[:, 0, :])
state[:, :3] += math_utils.quat_rotate(quat, self.com_pos_b[:, 0, :])
return state

@property
Expand Down Expand Up @@ -330,7 +327,7 @@ def body_link_state_w(self):
quat = state[..., 3:7]
# adjust linear velocity to link
state[..., 7:10] += torch.linalg.cross(
state[..., 10:13], math_utils.quat_rotate(quat, -self._com_pos_b), dim=-1
state[..., 10:13], math_utils.quat_rotate(quat, -self.com_pos_b), dim=-1
)
return state

Expand All @@ -346,7 +343,7 @@ def body_com_state_w(self):
state = self.body_state_w.clone()
quat = state[..., 3:7]
# adjust position to center of mass
state[..., :3] -= math_utils.quat_rotate(quat, self._com_pos_b)
state[..., :3] -= math_utils.quat_rotate(quat, self.com_pos_b)
return state

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ def __init__(self, root_physx_view: physx.RigidBodyView, device: str):
self._root_state_w = TimestampedBuffer()
self._body_acc_w = TimestampedBuffer()

# Link center of mass
# com_pos_b, _ = self._root_physx_view.get_coms().to(self.device).split([3, 4], dim=-1)
self._com_pos_b, _ = self._root_physx_view.get_coms().to(self.device).split([3, 4], dim=-1)

def update(self, dt: float):
"""Updates the data for the rigid object.
Expand Down Expand Up @@ -131,7 +127,7 @@ def root_link_state_w(self):
state = self.root_state_w.clone()
quat = state[:, 3:7]
# adjust linear velocity to link
state[:, 7:10] += torch.linalg.cross(state[:, 10:13], math_utils.quat_rotate(quat, -self._com_pos_b), dim=-1)
state[:, 7:10] += torch.linalg.cross(state[:, 10:13], math_utils.quat_rotate(quat, -self.com_pos_b), dim=-1)
return state

@property
Expand All @@ -145,7 +141,7 @@ def root_com_state_w(self):
state = self.root_state_w.clone()
quat = state[:, 3:7]
# adjust position to center of mass
state[:, :3] += math_utils.quat_rotate(quat, self._com_pos_b)
state[:, :3] += math_utils.quat_rotate(quat, self.com_pos_b)
return state

@property
Expand Down

0 comments on commit 8d8c82b

Please sign in to comment.