diff --git a/examples/pybullet/gym/pybullet_envs/env_bases.py b/examples/pybullet/gym/pybullet_envs/env_bases.py index f9c51c051..9820ad4ff 100644 --- a/examples/pybullet/gym/pybullet_envs/env_bases.py +++ b/examples/pybullet/gym/pybullet_envs/env_bases.py @@ -26,7 +26,7 @@ class MJCFBaseBulletEnv(gym.Env): self.scene = None self.physicsClientId = -1 self.ownsPhysicsClient = 0 - self.camera = Camera() + self.camera = Camera(self) self.isRender = render self.robot = robot self.seed() @@ -160,11 +160,12 @@ class MJCFBaseBulletEnv(gym.Env): class Camera: - def __init__(self): + def __init__(self, env): + self.env = env pass def move_and_look_at(self, i, j, k, x, y, z): lookat = [x, y, z] distance = 10 yaw = 10 - self._p.resetDebugVisualizerCamera(distance, yaw, -20, lookat) + self.env._p.resetDebugVisualizerCamera(distance, yaw, -20, lookat) diff --git a/examples/pybullet/gym/pybullet_envs/gym_locomotion_envs.py b/examples/pybullet/gym/pybullet_envs/gym_locomotion_envs.py index cbf096600..f193bff62 100644 --- a/examples/pybullet/gym/pybullet_envs/gym_locomotion_envs.py +++ b/examples/pybullet/gym/pybullet_envs/gym_locomotion_envs.py @@ -125,7 +125,7 @@ class WalkerBaseBulletEnv(MJCFBaseBulletEnv): return state, sum(self.rewards), bool(done), {} def camera_adjust(self): - x, y, z = self.body_xyz + x, y, z = self.robot.body_xyz self.camera_x = 0.98 * self.camera_x + (1 - 0.98) * x self.camera.move_and_look_at(self.camera_x, y - 2.0, 1.4, x, y, 1.0)