mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-09-05 09:58:36 +00:00
variable timestep for deepmimic env
This commit is contained in:
@@ -21,6 +21,7 @@ class InitializationStrategy(Enum):
|
||||
class PyBulletDeepMimicEnv(Env):
|
||||
|
||||
def __init__(self, arg_parser=None, enable_draw=False, pybullet_client=None,
|
||||
time_step=1./240,
|
||||
init_strategy=InitializationStrategy.RANDOM):
|
||||
super().__init__(arg_parser, enable_draw)
|
||||
self._num_agents = 1
|
||||
@@ -28,6 +29,7 @@ class PyBulletDeepMimicEnv(Env):
|
||||
self._isInitialized = False
|
||||
self._useStablePD = True
|
||||
self._arg_parser = arg_parser
|
||||
self.timeStep = time_step
|
||||
self._init_strategy = init_strategy
|
||||
print("Initialization strategy: {:s}".format(init_strategy))
|
||||
self.reset()
|
||||
@@ -62,7 +64,7 @@ class PyBulletDeepMimicEnv(Env):
|
||||
motionPath = pybullet_data.getDataPath() + "/" + motion_file[0]
|
||||
#motionPath = pybullet_data.getDataPath()+"/motions/humanoid3d_backflip.txt"
|
||||
self._mocapData.Load(motionPath)
|
||||
timeStep = 1. / 240.
|
||||
timeStep = self.timeStep
|
||||
useFixedBase = False
|
||||
self._humanoid = humanoid_stable_pd.HumanoidStablePD(self._pybullet_client, self._mocapData,
|
||||
timeStep, useFixedBase, self._arg_parser)
|
||||
@@ -278,6 +280,7 @@ class PyBulletDeepMimicEnv(Env):
|
||||
#print("pybullet_deep_mimic_env:update timeStep=",timeStep," t=",self.t)
|
||||
self._pybullet_client.setTimeStep(timeStep)
|
||||
self._humanoid._timeStep = timeStep
|
||||
self.timeStep = timeStep
|
||||
|
||||
for i in range(1):
|
||||
self.t += timeStep
|
||||
@@ -329,7 +332,7 @@ class PyBulletDeepMimicEnv(Env):
|
||||
|
||||
def check_valid_episode(self):
|
||||
#could check if limbs exceed velocity threshold
|
||||
return true
|
||||
return True
|
||||
|
||||
def getKeyboardEvents(self):
|
||||
return self._pybullet_client.getKeyboardEvents()
|
||||
|
||||
@@ -33,12 +33,14 @@ class HumanoidDeepBulletEnv(gym.Env):
|
||||
metadata = {'render.modes': ['human', 'rgb_array'], 'video.frames_per_second': 50}
|
||||
|
||||
def __init__(self, renders=False, arg_file='', test_mode=False,
|
||||
time_step=1./240,
|
||||
rescale_actions=True,
|
||||
rescale_observations=True):
|
||||
"""
|
||||
Args:
|
||||
test_mode (bool): in test mode, the `reset()` method will always set the mocap clip time
|
||||
to 0.
|
||||
time_step (float): physics time step.
|
||||
"""
|
||||
self._arg_parser = ArgParser()
|
||||
Logger.print2("===========================================================")
|
||||
@@ -50,7 +52,7 @@ class HumanoidDeepBulletEnv(gym.Env):
|
||||
assert succ, Logger.print2('Failed to load args from: ' + arg_file)
|
||||
|
||||
self._p: Optional[BulletClient] = None
|
||||
self._time_step = 1./240.
|
||||
self._time_step = time_step
|
||||
self._internal_env: Optional[PyBulletDeepMimicEnv] = None
|
||||
self._renders = renders
|
||||
self._discrete_actions = False
|
||||
@@ -177,6 +179,7 @@ class HumanoidDeepBulletEnv(gym.Env):
|
||||
else:
|
||||
init_strat = InitializationStrategy.RANDOM
|
||||
self._internal_env = PyBulletDeepMimicEnv(self._arg_parser, self._renders,
|
||||
time_step=self._time_step,
|
||||
init_strategy=init_strat)
|
||||
|
||||
self._internal_env.reset()
|
||||
|
||||
Reference in New Issue
Block a user