PyRep
PyRep 是用于机器人学习研究的工具包,建立在 CoppeliaSim(以前称为 V-REP)的基础上。
注意:V-REP 最近已更改为 CoppeliaSim。 如果安装了旧版本的 V-REP/PyRep,则应从 bashrc/zshrc 中删除所有 V-REP 引用(VREP_ROOT,LD_LIBRARY_PATH,QT_QPA_PLATFORM_PLUGIN_PATH),然后重新运行安装部分。
安装
除了 PyRep API,您还需要从下载页面下载最新版本的 CoppeliaSim。
下载 CoppeliaSim 之后,您可以从 git 中提取 PyRep:
git clone https://github.com/stepjam/PyRep.git cd PyRep
将以下内容添加到您的 ~/.bashrc 文件中:(注意:第一行中的“EDIT ME”)
export COPPELIASIM_ROOT=EDIT/ME/PATH/TO/COPPELIASIM/INSTALL/DIR export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$COPPELIASIM_ROOT export QT_QPA_PLATFORM_PLUGIN_PATH=$COPPELIASIM_ROOT
__请记住在此之后“source” 您的 bashrc(source ~/.bashrc)或zshrc(source ~/.zshrc)。
最后安装python库:
pip3 install -r requirements.txt python3 setup.py install --user
好了,现在万事俱备了!你可以尝试运行 examples/ 文件夹中的示例之一。
尽管您可以在任何平台上使用 CoppeliaSim,但目前仅在 Linux 上支持通过 PyRep 进行通信。
无头运行(Running Headless)
如果计划在无头计算机上运行,则还需要在虚拟帧缓冲区中运行。例如:
sudo apt-get install xvfb xvfb-run python3 my_pyrep_app.py # or if you are using jupyter # xvfb-run jupyter notebook
故障排除
以下是安装过程中可能会遇到的一些问题。 如果这些方法都不能解决您的问题,请提出问题。
ModuleNotFoundError:没有名为“pyrep.backend._v_rep_cffi”的模块
如果遇到此错误,请检查您是否不在项目根目录下运行解释器。 如果是这样,那么您的Python解释器将尝试导入这些文件,而不是已安装的文件。
错误:命令“ x86_64-linux-gnu-gcc”失败
您可能缺少构建python扩展所需的软件包。 尝试:sudo apt-get install python3-dev,然后重新运行安装。
入门
首先,查看“用法”和“ examples /”文件夹中的示例,以查看PyRep是否可以加速您的研究。
看看CoppeliaSim教程。
用法
了解PyRep如何为您的研究提供帮助的最好方法是查看examples /文件夹中的示例!
启动模拟
from pyrep import PyRep pr = PyRep() # Launch the application with a scene file in headless mode pr.launch('scene.ttt', headless=True) pr.start() # Start the simulation # Do some stuff pr.stop() # Stop the simulation pr.shutdown() # Close the application
修改场景
from pyrep.objects.shape import Shape from pyrep.const import PrimitiveShape object = Shape.create(type=PrimitiveShape.CYLINDER, color=[r,g,b], size=[w, h, d], position=[x, y, z]) object.set_color([r, g, b]) object.set_position([x, y, z])
使用机器人
机器人被设计成模块化;手臂和钳子分开处理。
使用在 robots/ttms 中定义的 robot ttm 文件。与 CoppeliaSim 随附的原始产品相比,这些产品已经稍作更改,可以直接用于运动计划中。机器人的“tip”可能不在您想要的位置,因此可以随意使用。
from pyrep import PyRep from pyrep.robots.arms.panda import Panda from pyrep.robots.end_effectors.panda_gripper import PandaGripper pr = PyRep() # Launch the application with a scene file that contains a robot pr.launch('scene_with_panda.ttt') pr.start() # Start the simulation arm = Panda() # Get the panda from the scene gripper = PandaGripper() # Get the panda gripper from the scene velocities = [.1, .2, .3, .4, .5, .6, .7] arm.set_joint_target_velocities(velocities) pr.step() # Step physics simulation done = False # Open the gripper halfway at a velocity of 0.04. while not done: done = gripper.actuate(0.5, velocity=0.04) pr.step() pr.stop() # Stop the simulation pr.shutdown() # Close the application
我们建议用字典或小型结构来构造你的机器人,例如:
class MyRobot(object): def __init__(self, arm, gripper): self.arm = arm self.gripper = gripper arm = Panda() # Get the panda from the scene gripper = PandaGripper() # Get the panda gripper from the scene # Create robot structure my_robot_1 = MyRobot(arm, gripper) # OR my_robot_2 = { 'arm': arm, 'gripper': gripper }
运行多个 PyRep 实例
每个 PyRep 实例都需要自己的进程。 这可以使用 Python 的多处理模块来实现。 这是一个简单的示例:
from multiprocessing import Process PROCESSES = 10 def run(): pr = PyRep() pr.launch('my_scene.ttt', headless=True) pr.start() # Do stuff... pr.stop() pr.shutdown() processes = [Process(target=run, args=()) for i in range(PROCESSES)] [p.start() for p in processes] [p.join() for p in processes]
支持的机器人
以下是 PyRep 当前支持的机器人列表:
Arms
- Kinova Mico
- Kinova Jaco
- Rethink Baxter
- Rethink Sawyer
- Franka Emika Panda
- Kuka LBR iiwa 7 R800
- Kuka LBR iiwa 14 R820
- Universal Robots UR3
- Universal Robots UR5
- Universal Robots UR10
Grippers
- Kinova Mico Hand
- Kinova Jaco Hand
- Rethink Baxter Gripper
- Franka Emika Panda Gripper
Mobile Robots
- Kuka YouBot
- Turtle Bot
- Line Tracer
随时发送对新机器人的拉取请求!
添加机器人
如果当前不支持所需的机器人,那么为什么不添加它呢!
计划的未来更新
- 支持 MuJoCo
- Sim-to-Real 的支持(例如域随机化)
贡献
我们希望使 PyRep 成为快速机器人学习研究的最佳工具。如果您想参与其中,请联系!
欢迎修复错误的拉请求!
使用PyRep的项目
如果您在工作中使用 PyRep,请与我们联系,我们可以将您添加到列表中!
- RLBench:机器人学习基准和学习环境,arxiv 2019
- 在没有人类的情况下,从人类那里学习一次性模仿,arxiv 2019
- 基于任务的模拟学习控制网络,CoRL 2018
- 将端到端可视电动机控制从仿真转移到现实世界,以完成多阶段任务,CoRL 2017
致谢
Georges Nomicos(伦敦帝国学院)用于增加移动平台。
V-REP 发生了什么?
Coppelia Robotics 停止了 V-REP 的开发。作为替代,他们现在将精力集中在 CoppeliaSim 上。 CoppeliaSim 与 V-REP 100% 兼容。在此处查看更多信息。
PyRep 与 V-REP 和 CoppeliaSim 完全兼容。
引文
@article{james2019pyrep, title={PyRep: Bringing V-REP to Deep Robot Learning}, author={James, Stephen and Freese, Marc and Davison, Andrew J.}, journal={arXiv preprint arXiv:1906.11176}, year={2019} }
(The first version translated by vz on 2020.07.26)