From a9ad1b528710a5f15e17c05ad6d7361c70c8676f Mon Sep 17 00:00:00 2001 From: Hongyi Zhou Date: Mon, 21 Nov 2022 10:17:56 +0100 Subject: [PATCH] minor update: create local variables for current pos/vel --- fancy_gym/black_box/black_box_wrapper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fancy_gym/black_box/black_box_wrapper.py b/fancy_gym/black_box/black_box_wrapper.py index 7fb085c..9d41615 100644 --- a/fancy_gym/black_box/black_box_wrapper.py +++ b/fancy_gym/black_box/black_box_wrapper.py @@ -162,7 +162,9 @@ class BlackBoxWrapper(gym.ObservationWrapper): self.plan_steps += 1 for t, (pos, vel) in enumerate(zip(position, velocity)): - step_action = self.tracking_controller.get_action(pos, vel, self.current_pos, self.current_vel) + current_pos = self.current_pos + current_vel = self.current_vel + step_action = self.tracking_controller.get_action(pos, vel, current_pos, current_vel) c_action = np.clip(step_action, self.env.action_space.low, self.env.action_space.high) obs, c_reward, done, info = self.env.step(c_action) rewards[t] = c_reward @@ -179,7 +181,7 @@ class BlackBoxWrapper(gym.ObservationWrapper): if self.render_kwargs: self.env.render(**self.render_kwargs) - if done or self.replanning_schedule(self.current_pos, self.current_vel, obs, c_action, + if done or self.replanning_schedule(current_pos, current_vel, obs, c_action, t + 1 + self.current_traj_steps): if self.max_planning_times is not None and self.plan_steps >= self.max_planning_times: