Skip to content

Commit

Permalink
add additional observation for gripper quat
Browse files Browse the repository at this point in the history
  • Loading branch information
yukezhu committed Jun 1, 2018
1 parent 91acd8b commit 7d43195
Show file tree
Hide file tree
Showing 3 changed files with 1,948 additions and 1 deletion.
10 changes: 9 additions & 1 deletion MujocoManip/environments/sawyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from MujocoManip.environments.base import MujocoEnv
from MujocoManip.models import SawyerRobot, gripper_factory
import MujocoManip.miscellaneous.utils as U
import MujocoManip.miscellaneous.transformations as T


class SawyerEnv(MujocoEnv):
Expand All @@ -21,7 +22,7 @@ def __init__(self,
# setup mocap stuff if necessary
if self.use_eef_ctrl:
self._setup_mocap()

def _setup_mocap(self):
U.mjpy_reset_mocap_welds(self.sim)
self.sim.forward()
Expand Down Expand Up @@ -196,6 +197,13 @@ def _right_hand_pose(self):
"""
return self.pose_in_base_from_name('right_hand')

@property
def _right_hand_quat(self):
"""
Returns eef pose in base frame of robot.
"""
return T.quaternion_from_matrix(self._right_hand_pose)

@property
def _right_hand_total_velocity(self):
"""
Expand Down
4 changes: 4 additions & 0 deletions MujocoManip/environments/sawyer_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,15 @@ def _get_observation(self):
di['cubeB_pos'] = cubeB_pos
di['cubeB_quat'] = cubeB_quat

# relative positions between gripper and cubes
gripper_site_pos = np.array(self.sim.data.site_xpos[self.eef_site_id])
di['gripper_to_cubeA'] = gripper_site_pos - cubeA_pos
di['gripper_to_cubeB'] = gripper_site_pos - cubeB_pos
di['cubeA_to_cubeB'] = cubeA_pos - cubeB_pos

# gripper orientation
di['gripper_quat'] = self._right_hand_quat

# proprioception
di['proprio'] = np.concatenate([
np.sin(di['joint_pos']),
Expand Down
Loading

0 comments on commit 7d43195

Please sign in to comment.