(译自PyBullet官方英文文档)
pip3 install pybullet, tensorflow, gym (用于安装PyBullet、tensorflow、gym等环境及框架,如果出现安装错误,多是因为用户权限问题,可使用pip3 install --user pybullet, tensorflow, gym)。
python -m pybullet_envs.examples.enjoy_TF_HumanoidBulletEnv_v0_2017may (运行bullet3/examples/pybullet/gym/pybullet_envs/examples目录下的enjoy_TF_HumanoidBulletEnv_v0_2017may.py文件,-m表示将脚本以模块模式运行,和直接运行程序的区别在于加载的系统路径不同,程序的主入口也不同)。
python -m pybullet_envs.examples.kukaGymEnvTest (运行bullet3/examples/pybullet/gym/pybullet_envs/examples/目录下的kukaCamGymEnvTest.py文件)。
git clone https://github.com/openai/baselines.git
cd baselines
pip3 install -e .
import pybullet
import pybullet_data
datapath=pybullet_data.getDataPath()
pybullet.connect(pybullet.GUI)
pybullet.setAdditionalSearchPath(datapath)
pybullet.loadURDF("r2d2.urdf",[0,0,1])
或者手动将路径附加到加载URDF/SDF命令中的文件名中去
事实上,新版的Roboschool environments已经移植到PyBullet上,Roboschool 环境比以往的MuJoCo Gym环境更加丰富,也更加具有挑战性。
python -m pybullet_envs.baselines.train_pybullet_cartpole (运行bullet3/examples/pybullet/gym/pybullet_envs/baselines目录下的train_pybullet_cartpole.py文件)
python -m pybullet_envs.baselines.train_pybullet_racecar (运行bullet3/examples/pybullet/gym/pybullet_envs/baselines目录下的train_pybullet_racecar.py文件)
当模型得到改进时,OpenAI Baselines将会以指定的时间间隔保存一个.PKL文件。以下脚本会使用到这个.PKL文件:
python -m pybullet_envs.baselines.enjoy_pybullet_cartpole
python -m pybullet_envs.baselines.enjoy_pybullet_racecar
python -m pybullet_envs.examples.enjoy_TF_AntBulletEnv_v0_2017may
python -m pybullet_envs.examples.enjoy_TF_HalfCheetahBulletEnv_v0_2017may
python -m pybullet_envs.examples.enjoy_TF_AntBulletEnv_v0_2017may
python -m pybullet_envs.examples.enjoy_TF_HopperBulletEnv_v0_2017may
python -m pybullet_envs.examples.enjoy_TF_HumanoidBulletEnv_v0_2017may
python -m pybullet_envs.examples.enjoy_TF_InvertedDoublePendulumBulletEnv_v0_2017may
python -m pybullet_envs.examples.enjoy_TF_InvertedPendulumBulletEnv_v0_2017may
python -m pybullet_envs.examples.enjoy_TF_InvertedPendulumSwingupBulletEnv_v0_2017may
python -m pybullet_envs.examples.enjoy_TF_Walker2DBulletEnv_v0_2017may
pip3 install gym,tensorflow,agents,pybullet,ruamel.yaml
python -m pybullet_envs.agents.train_ppo --config=pybullet_pendulum --logdir=pendulum
pybullet_pendulum
pybullet_doublependulum
pybullet_pendulumswingup
pybullet_cheetah
pybullet_ant
pybullet_racecar
pybullet_minitaur
tensorboard --logdir=pendulum --port=2222 (启动tensorflow下的tensorboard工具,将目标文件夹下的日志文件可视化,在本地服务器的port端口中以服务器模式运行,可被浏览器访问)
python -m pybullet_envs.agents.visualize_ppo --logdir=pendulum/xxxxx --outdir=pendulum_video
有关在PyBullet环境中使用进化策略的说明详见 David Ha(hardmaru)的博客文章
官方文档目前还没有使用PyTorch训练PyBullet的说明。但有一个git repository使用了PyTorch训练了Pybullet环境。