This commit is contained in:
Erwin Coumans
2019-07-28 17:24:37 -07:00
2 changed files with 9 additions and 4 deletions

View File

@@ -19,9 +19,11 @@ jointFrictionForce = 0
class HumanoidStablePD(object): class HumanoidStablePD(object):
def __init__(self, pybullet_client, mocap_data, timeStep, useFixedBase=True): def __init__( self, pybullet_client, mocap_data, timeStep,
useFixedBase=True, arg_parser=None):
self._pybullet_client = pybullet_client self._pybullet_client = pybullet_client
self._mocap_data = mocap_data self._mocap_data = mocap_data
self._arg_parser = arg_parser
print("LOADING humanoid!") print("LOADING humanoid!")
self._sim_model = self._pybullet_client.loadURDF( self._sim_model = self._pybullet_client.loadURDF(
@@ -135,7 +137,10 @@ class HumanoidStablePD(object):
self._jointDofCounts = [4, 4, 4, 1, 4, 4, 1, 4, 1, 4, 4, 1] self._jointDofCounts = [4, 4, 4, 1, 4, 4, 1, 4, 1, 4, 4, 1]
#only those body parts/links are allowed to touch the ground, otherwise the episode terminates #only those body parts/links are allowed to touch the ground, otherwise the episode terminates
self._allowed_body_parts = [5, 11] fall_contact_bodies = []
if self._arg_parser is not None:
fall_contact_bodies = self._arg_parser.parse_ints("fall_contact_bodies")
self._fall_contact_body_parts = fall_contact_bodies
#[x,y,z] base position and [x,y,z,w] base orientation! #[x,y,z] base position and [x,y,z,w] base orientation!
self._totalDofs = 7 self._totalDofs = 7
@@ -704,7 +709,7 @@ class HumanoidStablePD(object):
part = p[3] part = p[3]
if (p[2] == self._sim_model): if (p[2] == self._sim_model):
part = p[4] part = p[4]
if (part >= 0 and part not in self._allowed_body_parts): if (part >= 0 and part in self._fall_contact_body_parts):
#print("terminating part:", part) #print("terminating part:", part)
terminates = True terminates = True

View File

@@ -55,7 +55,7 @@ class PyBulletDeepMimicEnv(Env):
timeStep = 1. / 240. timeStep = 1. / 240.
useFixedBase = False useFixedBase = False
self._humanoid = humanoid_stable_pd.HumanoidStablePD(self._pybullet_client, self._mocapData, self._humanoid = humanoid_stable_pd.HumanoidStablePD(self._pybullet_client, self._mocapData,
timeStep, useFixedBase) timeStep, useFixedBase, self._arg_parser)
self._isInitialized = True self._isInitialized = True
self._pybullet_client.setTimeStep(timeStep) self._pybullet_client.setTimeStep(timeStep)