Skip to content

Commit

Permalink
[adroit ]Minor Cleanup: assignment of goal_achieved (#205)
Browse files Browse the repository at this point in the history
* Update adroit_door.py

* Update adroit_hammer.py

* Update adroit_pen.py

* Update adroit_relocate.py

* Update adroit_pen.py
  • Loading branch information
Kallinteris-Andreas authored Jan 15, 2024
1 parent 3fd43b0 commit 50c8019
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gymnasium_robotics/envs/adroit_hand/adroit_door.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def step(self, a):

# compute the sparse reward variant first
goal_distance = self.data.qpos[self.door_hinge_addrs]
goal_achieved = True if goal_distance >= 1.35 else False
goal_achieved = goal_distance >= 1.35
reward = 10.0 if goal_achieved else -0.1

# override reward if not sparse reward
Expand Down
2 changes: 1 addition & 1 deletion gymnasium_robotics/envs/adroit_hand/adroit_hammer.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def step(self, a):

# compute the sparse reward variant first
goal_distance = np.linalg.norm(nail_pos - goal_pos)
goal_achieved = True if goal_distance < 0.01 else False
goal_achieved = goal_distance < 0.01
reward = 10.0 if goal_achieved else -0.1

# override reward if not sparse reward
Expand Down
4 changes: 1 addition & 3 deletions gymnasium_robotics/envs/adroit_hand/adroit_pen.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ def step(self, a):
# compute the sparse reward variant first
goal_distance = np.linalg.norm(obj_pos - desired_loc)
orien_similarity = np.dot(obj_orien, desired_orien)
goal_achieved = (
True if (goal_distance < 0.075 and orien_similarity > 0.95) else False
)
goal_achieved = goal_distance < 0.075 and orien_similarity > 0.95
reward = 10.0 if goal_achieved else -0.1

# goal_failed = obj_pos[2] < 0.075
Expand Down
2 changes: 1 addition & 1 deletion gymnasium_robotics/envs/adroit_hand/adroit_relocate.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def step(self, a):

# compute the sparse reward variant first
goal_distance = float(np.linalg.norm(obj_pos - target_pos))
goal_achieved = True if goal_distance < 0.1 else False
goal_achieved = goal_distance < 0.1
reward = 10.0 if goal_achieved else -0.1

# override reward if not sparse reward
Expand Down

0 comments on commit 50c8019

Please sign in to comment.