in sim_agent.py [0:0]
def set_pose(self, pose, vel=None):
'''
Velocity should be represented w.r.t. local frame
'''
# Root joint
T = pose.get_transform(
self._char_info.bvh_map[self._char_info.ROOT],
local=False)
Q, p = conversions.T2Qp(T)
p *= self._ref_scale
v, w = None, None
if vel is not None:
# Here we give a root orientation to get velocities represeted in world frame.
R = conversions.Q2R(Q)
w = vel.get_angular(
self._char_info.bvh_map[self._char_info.ROOT], False, R)
v = vel.get_linear(
self._char_info.bvh_map[self._char_info.ROOT], False, R)
v *= self._ref_scale
bu.set_base_pQvw(self._pb_client, self._body_id, p, Q, v, w)
# Other joints
indices = []
state_pos = []
state_vel = []
for j in self._joint_indices:
joint_type = self._joint_type[j]
# When the target joint do not have dof, we simply ignore it
if joint_type == self._pb_client.JOINT_FIXED:
continue
# When there is no matching between the given pose and the simulated character,
# the character just tries to hold its initial pose
if self._char_info.bvh_map[j] is None:
state_pos.append(self._joint_pose_init[j])
state_vel.append(self._joint_vel_init[j])
else:
T = pose.get_transform(self._char_info.bvh_map[j], local=True)
if joint_type == self._pb_client.JOINT_SPHERICAL:
Q, p = conversions.T2Qp(T)
w = np.zeros(3) if vel is None else vel.get_angular(self._char_info.bvh_map[j], local=True)
state_pos.append(Q)
state_vel.append(w)
elif joint_type == self._pb_client.JOINT_REVOLUTE:
joint_axis = self.get_joint_axis(j)
R, p = conversions.T2Rp(T)
w = np.zeros(3) if vel is None else vel.get_angular(self._char_info.bvh_map[j], local=True)
state_pos.append([math.project_rotation_1D(R, joint_axis)])
state_vel.append([math.project_angular_vel_1D(w, joint_axis)])
else:
raise NotImplementedError()
indices.append(j)
bu.set_joint_pv(self._pb_client, self._body_id, indices, state_pos, state_vel)