Skip to content

Commit

Permalink
remove density
Browse files Browse the repository at this point in the history
  • Loading branch information
jirenz committed Jun 1, 2018
1 parent 3efcfb6 commit cc8eec0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
50 changes: 25 additions & 25 deletions MujocoManip/environments/baxter_lift.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,37 +117,37 @@ def reward(self, action):
# When grippers are far away, tell them to be closer
l_gh_dist_xy = np.linalg.norm(l_gripper_to_handle)
r_gh_dist_xy = np.linalg.norm(r_gripper_to_handle)
if l_gh_dist_xy > 0.05:
reward += 1 - np.tanh(l_gh_dist_xy)
if r_gh_dist_xy > 0.05:
reward += 1 - np.tanh(r_gh_dist_xy)
# if l_gh_dist_xy > 0.05:
reward += 1 - np.tanh(l_gh_dist_xy)
# if r_gh_dist_xy > 0.05:
reward += 1 - np.tanh(r_gh_dist_xy)

l_gh_dist_xy = np.linalg.norm(l_gripper_to_handle[:2])
r_gh_dist_xy = np.linalg.norm(r_gripper_to_handle[:2])
# l_gh_dist_xy = np.linalg.norm(l_gripper_to_handle[:2])
# r_gh_dist_xy = np.linalg.norm(r_gripper_to_handle[:2])

l_gh_z_diff = l_gripper_to_handle[2]
r_gh_z_diff = r_gripper_to_handle[2]
# l_gh_z_diff = l_gripper_to_handle[2]
# r_gh_z_diff = r_gripper_to_handle[2]

handle_reward = 0
# handle_reward = 0

# When gripper is close and above, tell them to move away and down
# When gripper is close and below, tell them to move close and up
coef_z = 2
coef_xy = 1
if l_gh_z_diff > 0: # gripper below handle
handle_reward -= coef_z * l_gh_z_diff
handle_reward -= coef_xy * l_gh_dist_xy
else:
handle_reward += coef_z * l_gh_z_diff
handle_reward += coef_xy * min(0, -0.05 + l_gh_dist_xy) # force the gripper to move away a bit
if r_gh_z_diff > 0:
handle_reward -= coef_z * r_gh_z_diff
handle_reward -= coef_xy * r_gh_dist_xy
else:
handle_reward += coef_z * l_gh_z_diff
handle_reward += coef_xy * min(0, -0.05 + l_gh_dist_xy) # force the gripper to move away a bit

reward += handle_reward
# coef_z = 2
# coef_xy = 1
# if l_gh_z_diff > 0: # gripper below handle
# handle_reward -= coef_z * l_gh_z_diff
# handle_reward -= coef_xy * l_gh_dist_xy
# else:
# handle_reward += coef_z * l_gh_z_diff
# handle_reward += coef_xy * min(0, -0.05 + l_gh_dist_xy) # force the gripper to move away a bit
# if r_gh_z_diff > 0:
# handle_reward -= coef_z * r_gh_z_diff
# handle_reward -= coef_xy * r_gh_dist_xy
# else:
# handle_reward += coef_z * l_gh_z_diff
# handle_reward += coef_xy * min(0, -0.05 + l_gh_dist_xy) # force the gripper to move away a bit

# reward += handle_reward

contact_reward = 0.25
for contact in self.find_contacts(self.gripper_left.contact_geoms(),
Expand Down
7 changes: 3 additions & 4 deletions MujocoManip/models/mujoco_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,13 @@ class GeneratedPotObject(MujocoGeneratedObject):
def __init__(self,
body_half_size=None,
handle_radius=0.005,
handle_length=0.06,
handle_length=0.09,
handle_width=0.09,
rgba_body=None,
rgba_handle_1=None,
rgba_handle_2=None,
solid_handle=True,
density=3000, # 3 * water, 3 * mujoco default
density=3000, # 3 * water, 3 * mujoco default DEPRECATED for now
):
super().__init__()
if body_half_size:
Expand Down Expand Up @@ -460,8 +460,7 @@ def get_collision(self, name=None, site=None):
main_body.append(gen_geom(geom_type='box',
size=self.body_half_size,
rgba=self.rgba_body,
group=1,
density=str(self.density)))
group=1))
handle_z = self.body_half_size[2] - self.handle_radius
handle_1_center = [0,
self.body_half_size[1] + self.handle_length,
Expand Down

0 comments on commit cc8eec0

Please sign in to comment.