diff --git a/fancy_gym/envs/mujoco/__init__.py b/fancy_gym/envs/mujoco/__init__.py index 7e4be42..4afdcce 100644 --- a/fancy_gym/envs/mujoco/__init__.py +++ b/fancy_gym/envs/mujoco/__init__.py @@ -10,8 +10,7 @@ from .walker_2d_jump.walker_2d_jump import Walker2dJumpEnv from .box_pushing.box_pushing_env import BoxPushingDense, BoxPushingTemporalSparse, BoxPushingTemporalSpatialSparse from .table_tennis.table_tennis_env import TableTennisEnv, TableTennisWind, TableTennisGoalSwitching -from .air_hockey.air_hockey_env_wrapper import AirHockeyEnv try: from .air_hockey.air_hockey_env_wrapper import AirHockeyEnv -except: +except ModuleNotFoundError: print("[FANCY GYM] Air Hockey not available (depends on mushroom-rl, dmc, mujoco)") \ No newline at end of file diff --git a/fancy_gym/envs/mujoco/air_hockey/air_hockey_env_wrapper.py b/fancy_gym/envs/mujoco/air_hockey/air_hockey_env_wrapper.py index 8f73cdf..f4f34b3 100644 --- a/fancy_gym/envs/mujoco/air_hockey/air_hockey_env_wrapper.py +++ b/fancy_gym/envs/mujoco/air_hockey/air_hockey_env_wrapper.py @@ -45,10 +45,11 @@ class AirHockeyEnv(Environment): self.base_env = env_dict[env_mode](interpolation_order=interpolation_order, **kwargs) self.env_name = env_mode self.env_info = self.base_env.env_info + single_robot_obs_size = len(self.base_env.info.observation_space.low) if env_mode == "tournament": - self.observation_space = spaces.Box(low=-np.inf, high=np.inf, shape=(2,23), dtype=np.float64) + self.observation_space = spaces.Box(low=-np.inf, high=np.inf, shape=(2,single_robot_obs_size), dtype=np.float64) else: - self.observation_space = spaces.Box(low=-np.inf, high=np.inf, shape=(20,), dtype=np.float64) + self.observation_space = spaces.Box(low=-np.inf, high=np.inf, shape=(single_robot_obs_size,), dtype=np.float64) robot_info = self.env_info["robot"] if env_mode != "tournament": diff --git a/fancy_gym/envs/mujoco/air_hockey/seven_dof/defend.py b/fancy_gym/envs/mujoco/air_hockey/seven_dof/defend.py index f029c8f..0ffdf66 100644 --- a/fancy_gym/envs/mujoco/air_hockey/seven_dof/defend.py +++ b/fancy_gym/envs/mujoco/air_hockey/seven_dof/defend.py @@ -24,7 +24,7 @@ class AirHockeyDefend(AirHockeySingle): puck_vel = np.zeros(3) puck_vel[0] = -np.cos(angle) * lin_vel puck_vel[1] = np.sin(angle) * lin_vel - puck_vel[2] = np.random.uniform(-10, 10, 1) + puck_vel[2] = np.random.uniform(-10, 10) self._write_data("puck_x_pos", puck_pos[0]) self._write_data("puck_y_pos", puck_pos[1]) diff --git a/fancy_gym/envs/mujoco/air_hockey/seven_dof/env_single.py b/fancy_gym/envs/mujoco/air_hockey/seven_dof/env_single.py index bc28e26..accfc83 100644 --- a/fancy_gym/envs/mujoco/air_hockey/seven_dof/env_single.py +++ b/fancy_gym/envs/mujoco/air_hockey/seven_dof/env_single.py @@ -94,7 +94,7 @@ class AirHockeySingle(AirHockeyBase): for i in range(7): self._data.joint("iiwa_1/joint_" + str(i + 1)).qpos = self.init_state[i] self.q_pos_prev[i] = self.init_state[i] - self.q_vel_prev[i] = self._data.joint("iiwa_1/joint_" + str(i + 1)).qvel + self.q_vel_prev[i] = self._data.joint("iiwa_1/joint_" + str(i + 1)).qvel[0] self.universal_joint_plugin.reset() diff --git a/fancy_gym/envs/mujoco/air_hockey/seven_dof/hit.py b/fancy_gym/envs/mujoco/air_hockey/seven_dof/hit.py index 5c28590..59386d5 100644 --- a/fancy_gym/envs/mujoco/air_hockey/seven_dof/hit.py +++ b/fancy_gym/envs/mujoco/air_hockey/seven_dof/hit.py @@ -40,7 +40,7 @@ class AirHockeyHit(AirHockeySingle): puck_vel = np.zeros(3) puck_vel[0] = -np.cos(angle) * lin_vel puck_vel[1] = np.sin(angle) * lin_vel - puck_vel[2] = np.random.uniform(-2, 2, 1) + puck_vel[2] = np.random.uniform(-2, 2) self._write_data("puck_x_vel", puck_vel[0]) self._write_data("puck_y_vel", puck_vel[1]) diff --git a/fancy_gym/envs/mujoco/air_hockey/three_dof/defend.py b/fancy_gym/envs/mujoco/air_hockey/three_dof/defend.py index 7030f2c..1f1224f 100644 --- a/fancy_gym/envs/mujoco/air_hockey/three_dof/defend.py +++ b/fancy_gym/envs/mujoco/air_hockey/three_dof/defend.py @@ -27,7 +27,7 @@ class AirHockeyDefend(AirHockeySingle): puck_vel = np.zeros(3) puck_vel[0] = -np.cos(angle) * lin_vel puck_vel[1] = np.sin(angle) * lin_vel - puck_vel[2] = np.random.uniform(-10, 10, 1) + puck_vel[2] = np.random.uniform(-10, 10) self._write_data("puck_x_pos", puck_pos[0]) self._write_data("puck_y_pos", puck_pos[1]) diff --git a/fancy_gym/envs/mujoco/air_hockey/three_dof/env_single.py b/fancy_gym/envs/mujoco/air_hockey/three_dof/env_single.py index 99089d0..4dfa117 100644 --- a/fancy_gym/envs/mujoco/air_hockey/three_dof/env_single.py +++ b/fancy_gym/envs/mujoco/air_hockey/three_dof/env_single.py @@ -71,7 +71,7 @@ class AirHockeySingle(AirHockeyBase): for i in range(3): self._data.joint("planar_robot_1/joint_" + str(i + 1)).qpos = self.init_state[i] self.q_pos_prev[i] = self.init_state[i] - self.q_vel_prev[i] = self._data.joint("planar_robot_1/joint_" + str(i + 1)).qvel + self.q_vel_prev[i] = self._data.joint("planar_robot_1/joint_" + str(i + 1)).qvel[0] mujoco.mj_fwdPosition(self._model, self._data) super().setup(state)