Example #1
0
    def _build_humanoid(self):
        motion_file = self.argparser.parse_string("motion_file")

        mocap_data = load_mocap_data(motion_file)

        useFixedBase = False

        self._humanoid = humanoid_stable_pd.HumanoidStablePD(
            self._client, mocap_data, self.timestep, useFixedBase,
            self.argparser)
Example #2
0
    def initialize(self):
        if not self._isInitialized:
            if self.enable_draw:
                if self.render_mode == 'human' or self.render_mode == 'rgb_array':
                    self._pybullet_client = bullet_client.BulletClient(
                        connection_mode=p1.GUI)
                    self._build_camera()

                #disable 'GUI' since it slows down a lot on Mac OSX and some other platforms
                self._pybullet_client.configureDebugVisualizer(
                    self._pybullet_client.COV_ENABLE_GUI, 0)
            else:
                self._pybullet_client = bullet_client.BulletClient()

            self._pybullet_client.setAdditionalSearchPath(
                pybullet_data.getDataPath())
            z2y = self._pybullet_client.getQuaternionFromEuler(
                [-math.pi * 0.5, 0, 0])
            self._planeId = self._pybullet_client.loadURDF(
                "plane_implicit.urdf", [0, 0, 0],
                z2y,
                useMaximalCoordinates=True)
            #print("planeId=",self._planeId)
            self._pybullet_client.configureDebugVisualizer(
                self._pybullet_client.COV_ENABLE_Y_AXIS_UP, 1)
            self._pybullet_client.resetDebugVisualizerCamera(
                cameraDistance=3,
                cameraYaw=180,
                cameraPitch=-35,
                cameraTargetPosition=[0, 0, 0])
            self._pybullet_client.setGravity(0, -9.8, 0)

            self._pybullet_client.setPhysicsEngineParameter(
                numSolverIterations=10)
            self._pybullet_client.changeDynamics(self._planeId,
                                                 linkIndex=-1,
                                                 lateralFriction=0.9)

            self.set_timer_params()

            self._mocapData = motion_capture_data.MotionCaptureData()
            motion_file = self.arg_parser.parse_strings("motion_file")
            motionPath = pybullet_data.getDataPath() + "/" + motion_file[0]
            print("motion_file=", motion_file[0])

            self._mocapData.Load(motionPath)

            useFixedBase = False
            self._humanoid = humanoid_stable_pd.HumanoidStablePD(
                self._pybullet_client, self._mocapData, self.update_timestep,
                useFixedBase, self.arg_parser)
            self._isInitialized = True

            self._pybullet_client.setTimeStep(self.update_timestep)
            self._pybullet_client.setPhysicsEngineParameter(numSubSteps=1)

            self.reset()
            self._set_action_space()
            action = self.action_space.sample()
            observation, _reward, done, _info = self.step(action)
            assert not done
            self._set_observation_space(observation)
Example #3
0
#print("planeId=",planeId)

pybullet_client.configureDebugVisualizer(pybullet_client.COV_ENABLE_Y_AXIS_UP,
                                         1)
pybullet_client.setGravity(0, -9.8, 0)

pybullet_client.setPhysicsEngineParameter(numSolverIterations=10)

mocapData = motion_capture_data.MotionCaptureData()
#motionPath = pybullet_data.getDataPath()+"/data/motions/humanoid3d_walk.txt"
motionPath = pybullet_data.getDataPath(
) + "/data/motions/humanoid3d_backflip.txt"
mocapData.Load(motionPath)
timeStep = 1. / 600
useFixedBase = False
humanoid = humanoid_stable_pd.HumanoidStablePD(pybullet_client, mocapData,
                                               timeStep, useFixedBase)
isInitialized = True

pybullet_client.setTimeStep(timeStep)
pybullet_client.setPhysicsEngineParameter(numSubSteps=2)
timeId = pybullet_client.addUserDebugParameter("time", 0, 10, 0)


def isKeyTriggered(keys, key):
    o = ord(key)
    if o in keys:
        return keys[ord(key)] & pybullet_client.KEY_WAS_TRIGGERED
    return False


animating = False
Example #4
0
    def initialize(self):
        if not self._isInitialized:
            if self.enable_draw:
                self._pybullet_client = bullet_client.BulletClient(
                    connection_mode=p1.GUI)
                #disable 'GUI' since it slows down a lot on Mac OSX and some other platforms
                self._pybullet_client.configureDebugVisualizer(
                    self._pybullet_client.COV_ENABLE_GUI, 0)
            else:
                self._pybullet_client = bullet_client.BulletClient()

            self._pybullet_client.setAdditionalSearchPath(
                pybullet_data.getDataPath())
            z2y = self._pybullet_client.getQuaternionFromEuler(
                [-math.pi * 0.5, 0, 0])
            self._planeId = self._pybullet_client.loadURDF(
                "plane_implicit.urdf", [0, 0, 0],
                z2y,
                useMaximalCoordinates=True)
            #print("planeId=",self._planeId)
            self._pybullet_client.configureDebugVisualizer(
                self._pybullet_client.COV_ENABLE_Y_AXIS_UP, 1)
            self._pybullet_client.setGravity(0, -9.8, 0)

            self._pybullet_client.setPhysicsEngineParameter(
                numSolverIterations=10)
            self._pybullet_client.changeDynamics(self._planeId,
                                                 linkIndex=-1,
                                                 lateralFriction=0.9)

            self._mocapData = motion_capture_data.MotionCaptureData()

            motion_file = self._config["motion_file"]
            print("motion_file=", motion_file[0])

            motionPath = pybullet_data.getDataPath() + "/" + motion_file[0]
            #motionPath = pybullet_data.getDataPath()+"/motions/humanoid3d_backflip.txt"
            self._mocapData.Load(motionPath)
            timeStep = 1. / 240.
            useFixedBase = False

            self._humanoid = humanoid_stable_pd.HumanoidStablePD(
                self._pybullet_client, self._mocapData, timeStep, useFixedBase,
                self._config)
            self._isInitialized = True

            self._pybullet_client.setTimeStep(timeStep)
            self._pybullet_client.setPhysicsEngineParameter(numSubSteps=1)

            selfCheck = False
            if (selfCheck):
                curTime = 0
                while self._pybullet_client.isConnected():
                    self._humanoid.setSimTime(curTime)
                    state = self._humanoid.getState()
                    #print("state=",state)
                    pose = self._humanoid.computePose(
                        self._humanoid._frameFraction)
                    for i in range(10):
                        curTime += timeStep
                    #taus = self._humanoid.computePDForces(pose)
                    #self._humanoid.applyPDForces(taus)
                    #self._pybullet_client.stepSimulation()
                    time.sleep(timeStep)
        self.reset()