Skip to content

Commit

Permalink
change orientation of the com properties to principle axes of inertia
Browse files Browse the repository at this point in the history
  • Loading branch information
jtigue-bdai committed Oct 8, 2024
1 parent 8d8c82b commit d93a307
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,7 @@ def update(self, dt: float):
"""Joint stiffness provided to simulation. Shape is (num_instances, num_joints)."""

joint_damping: torch.Tensor = None
"""Joint damping provided to simulation. Shape is (num_instances, num_joints)."""

joint_armature: torch.Tensor = None
"""Joint armature provided to simulation. Shape is (num_instances, num_joints)."""

joint_friction: torch.Tensor = None
"""Joint friction provided to simulation. Shape is (num_instances, num_joints)."""
"""Joint damping provided to simulation. Shape is (num_instanbody_state_wnstances, num_joints)."""

joint_limits: torch.Tensor = None
"""Joint limits provided to simulation. Shape is (num_instances, num_joints, 2)."""
Expand Down Expand Up @@ -293,9 +287,12 @@ def root_com_state_w(self):
orientation of the principle inertia.
"""
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, :])
# adjust pose to center of mass
pos, quat = math_utils.combine_frame_transforms(state[:,:3],
state[:,3:7],
self.com_pos_b[:,0,:],
self.com_quat_b[:,0,:])
state[:, :7] += torch.cat((pos,quat),dim=-1)
return state

@property
Expand Down Expand Up @@ -341,9 +338,12 @@ def body_com_state_w(self):
principle inertia.
"""
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)
# adjust pose to center of mass
pos, quat = math_utils.combine_frame_transforms(state[:,:3],
state[:,3:7],
self.com_pos_b,
self.com_quat_b)
state[..., :7] += torch.cat((pos,quat),dim=-1)
return state

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ def root_com_state_w(self):
"""Root state ``[pos, quat, lin_vel, ang_vel]`` in simulation world frame. Shape is (num_instances, 13).
The position, quaternion, and linear/angular velocity are of the rigid body's center of mass frame
relative to the world. Center of mass frame is assumed to be the same orientation as the link rather than the
orientation of the principle inertia.
relative to the world. Center of mass frame is the orientation principle axes of inertia.
"""
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)
pos, quat = math_utils.combine_frame_transforms(state[:,:3],
state[:,3:7],
self.com_pos_b,
self.com_quat_b)
state[:, :7] += torch.cat((pos,quat),dim=-1)
return state

@property
Expand Down

0 comments on commit d93a307

Please sign in to comment.