Files
bullet3/examples/pybullet/gym/kukaJointSpaceGymEnvTest.py
Erwin Coumans 21f9d1b816 refactor pybullet/gym to allow instantiating environments directly from a pybullet install:
work-in-progress (need to add missing data files, fix paths etc)

example:

pip install pybullet
pip install gym

python
import gym
import pybullet
import pybullet_envs
env = gym.make("HumanoidBulletEnv-v0")
2017-08-22 00:42:02 -07:00

24 lines
667 B
Python

from pybullet_envs.bullet.kukaGymEnv import KukaGymEnv
import time
environment = KukaGymEnv(renders=True)
environment._kuka.useInverseKinematics=0
motorsIds=[]
for i in range (len(environment._kuka.motorNames)):
motor = environment._kuka.motorNames[i]
motorJointIndex = environment._kuka.motorIndices[i]
motorsIds.append(environment._p.addUserDebugParameter(motor,-3,3,environment._kuka.jointPositions[i]))
while (True):
action=[]
for motorId in motorsIds:
action.append(environment._p.readUserDebugParameter(motorId))
state, reward, done, info = environment.step(action)
obs = environment.getExtendedObservation()
time.sleep(0.01)