updates
This commit is contained in:
@@ -35,7 +35,6 @@ class HoleReacher(gym.Env):
|
||||
self._angle_velocity = None
|
||||
self.start_pos = np.hstack([[np.pi/2], np.zeros(self.num_links - 1)])
|
||||
self.start_vel = np.zeros(self.num_links)
|
||||
self.weight_matrix_scale = 50 # for the holereacher, the dmp weights become quite large compared to the values of the goal attractor. this scaling is to ensure they are on similar scale for the optimizer
|
||||
|
||||
self.dt = 0.01
|
||||
self.time_limit = 2
|
||||
@@ -68,6 +67,9 @@ class HoleReacher(gym.Env):
|
||||
def end_effector(self):
|
||||
return self._joints[self.num_links].T
|
||||
|
||||
def configure(self, context):
|
||||
pass
|
||||
|
||||
def reset(self):
|
||||
self._joint_angles = self.start_pos
|
||||
self._angle_velocity = self.start_vel
|
||||
|
||||
@@ -62,7 +62,8 @@ def make_holereacher_env(rank, seed=0):
|
||||
learn_goal=True,
|
||||
alpha_phase=2,
|
||||
start_pos=_env.start_pos,
|
||||
policy_type="velocity"
|
||||
policy_type="velocity",
|
||||
weights_scale=100,
|
||||
)
|
||||
_env.seed(seed + rank)
|
||||
return _env
|
||||
|
||||
@@ -71,10 +71,10 @@ class BallInACupReward(alr_reward_fct.AlrReward):
|
||||
dist_ctxt = self.dists_ctxt[-1]
|
||||
|
||||
# cost = self._get_stage_wise_cost(ball_in_cup, min_dist, dist_final, dist_ctxt)
|
||||
cost = 2 * (0.33 * min_dist + 0.33 * dist_final + 0.33 * dist_ctxt)
|
||||
cost = 2 * (0.5 * min_dist + 0.5 * dist_final + 0.1 * dist_ctxt)
|
||||
reward = np.exp(-1 * cost) - 1e-4 * action_cost
|
||||
stop_sim = True
|
||||
success = dist_final < 0.05 and ball_in_cup
|
||||
success = dist_final < 0.05 and dist_ctxt < 0.05
|
||||
else:
|
||||
reward = - 1e-4 * action_cost
|
||||
success = False
|
||||
|
||||
@@ -86,8 +86,6 @@ class DmpEnvWrapper(gym.Wrapper):
|
||||
def rollout(self, params, context=None, render=False):
|
||||
""" This function generates a trajectory based on a DMP and then does the usual loop over reset and step"""
|
||||
goal_pos, weight_matrix = self.goal_and_weights(params)
|
||||
if hasattr(self.env, "weight_matrix_scale"):
|
||||
weight_matrix = weight_matrix * self.env.weight_matrix_scale
|
||||
self.dmp.set_weights(weight_matrix, goal_pos)
|
||||
trajectory, velocity = self.dmp.reference_trajectory(self.t)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user