Add interface for envs controlable by a PD Controller and add more infos to mp_wrapper info return value
This commit is contained in:
@@ -7,7 +7,9 @@ from gym import error, spaces
|
||||
from gym.utils import seeding
|
||||
import numpy as np
|
||||
from os import path
|
||||
import gym
|
||||
|
||||
from alr_envs.utils.mps.alr_env import AlrEnv
|
||||
from alr_envs.utils.positional_env import PositionalEnv
|
||||
|
||||
try:
|
||||
import mujoco_py
|
||||
@@ -33,7 +35,7 @@ def convert_observation_to_space(observation):
|
||||
return space
|
||||
|
||||
|
||||
class AlrMujocoEnv(gym.Env):
|
||||
class AlrMujocoEnv(PositionalEnv, AlrEnv):
|
||||
"""
|
||||
Superclass for all MuJoCo environments.
|
||||
"""
|
||||
@@ -44,7 +46,7 @@ class AlrMujocoEnv(gym.Env):
|
||||
Args:
|
||||
model_path: path to xml file
|
||||
n_substeps: how many steps mujoco does per call to env.step
|
||||
use_servo: use actuator defined in xml, use False for direct torque control
|
||||
apply_gravity_comp: Whether gravity compensation should be active
|
||||
"""
|
||||
if model_path.startswith("/"):
|
||||
fullpath = model_path
|
||||
@@ -73,10 +75,6 @@ class AlrMujocoEnv(gym.Env):
|
||||
|
||||
self._set_action_space()
|
||||
|
||||
# action = self.action_space.sample()
|
||||
# observation, _reward, done, _info = self.step(action)
|
||||
# assert not done
|
||||
|
||||
observation = self._get_obs() # TODO: is calling get_obs enough? should we call reset, or even step?
|
||||
|
||||
self._set_observation_space(observation)
|
||||
@@ -204,7 +202,7 @@ class AlrMujocoEnv(gym.Env):
|
||||
|
||||
try:
|
||||
self.sim.step()
|
||||
except mujoco_py.builder.MujocoException as e:
|
||||
except mujoco_py.builder.MujocoException:
|
||||
error_in_sim = True
|
||||
|
||||
return error_in_sim
|
||||
|
||||
@@ -16,8 +16,6 @@ class ALRBallInACupEnv(alr_mujoco_env.AlrMujocoEnv, utils.EzPickle):
|
||||
self._q_vel = []
|
||||
# self.weight_matrix_scale = 50
|
||||
self.max_ctrl = np.array([150., 125., 40., 60., 5., 5., 2.])
|
||||
self.p_gains = 1 / self.max_ctrl * np.array([200, 300, 100, 100, 10, 10, 2.5])
|
||||
self.d_gains = 1 / self.max_ctrl * np.array([7, 15, 5, 2.5, 0.3, 0.3, 0.05])
|
||||
|
||||
self.j_min = np.array([-2.6, -1.985, -2.8, -0.9, -4.55, -1.5707, -2.7])
|
||||
self.j_max = np.array([2.6, 1.985, 2.8, 3.14159, 1.25, 1.5707, 2.7])
|
||||
|
||||
Reference in New Issue
Block a user