Skip to content

Latest commit

 

History

History
113 lines (87 loc) · 5.55 KB

robocomp-pyrep.md

File metadata and controls

113 lines (87 loc) · 5.55 KB

RoboComp Integration with CoppeliaSim Using PyRep

In many situations, a more robust simulator than RCIS is required to leverege the power of RoboComp in more physically complex scenes. Consequently, RoboComp needs to be integrated to more complex simulators and physics engines. The current choice for RoboComp is CoppeliaSim, previously known as V-REP.

The standard remote python API of CoppeliaSim is very slow, so we opt for PyRep which includes a fast and flexible API to connect with CoppeliaSim.

In this tutorial, we walk you through the setup procedure of CoppeliaSim and PyRep, along with some examples to try with RoboComp.

CoppeliaSim Installation

  • First, download CoppeliaSim EDU version (compatible with your system) from download page.

  • Extract it into your prefered directory.

  • Add the following to your ~/.bashrc file (changing the path) :

export COPPELIASIM_ROOT=PATH/TO/COPPELIASIM/INSTALL/DIR
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$COPPELIASIM_ROOT
export QT_QPA_PLATFORM_PLUGIN_PATH=$COPPELIASIM_ROOT
  • Source your ~/.bashrc file :
source ~/.bashrc

PyRep Installation

  • Check that you have installed libpython3-dev using apt
  • First, clone master branch of PyRep repo :958236
git clone https://github.com/stepjam/PyRep.git
  • Install PyRep dependencies and library LOCALLY (without sudo):
cd PyRep
pip3 install -r requirements.txt
pip3 install .
  • Comment out the last two lines just added in your ~/.bashrc file (changing the path) :
export COPPELIASIM_ROOT=PATH/TO/COPPELIASIM/INSTALL/DIR
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$COPPELIASIM_ROOT
#export QT_QPA_PLATFORM_PLUGIN_PATH=$COPPELIASIM_ROOT
  • Source your ~/.bashrc file again:
source ~/.bashrc

Testing your Installation

  • Make sure that you start the pub/sub Ice broker by running in any terminal: rcnode &

  • After completing the installation, you can make sure it's working correctly, by trying some of the examples in examples folder in PyRep repo.

  • Also, you can refer to Usage section in main README.md, for easy and fast code snippets to get started with.

Testing RoboComp Bridges

  • Now that everything is ready, you can start trying the currently-available RoboComp bridges.

  • The main RoboComp bridges that currently exists :

  • Make sure to follow the instructions for each one.

Current Known Issues

  • This application failed to start because no Qt platform plugin could be initialized :

    • This problem can appear when trying to start the component, due to compatibility issues with Qt version in OpenCV and VREP.
    • This problem is solved by installing opencv-python-headless :
      pip install opencv-python-headless
  • "NotImplementedError: Must be overridden" exception in pyrep/objects/object.py, when running viriatoPyrep :

    • Comment out the following lines in /home/xxxyour-userxxx/.local/lib/python3.6/site-packages/pyrep/objects/object.py :
      assert_type = self._get_requested_type()
      actual = ObjectType(sim.simGetObjectType(self._handle))
      if actual != assert_type:
          raise WrongObjectTypeError(
              'You requested object of type %s, but the actual type was '
              '%s' % (assert_type.name, actual.name))
  • __ Comment line 41 in file "/home/pbustos/.local/lib/python3.10/site-packages/pyrep/robots/mobiles/mobile_base.py"

  • Error when installing Pyrep. This error might occur if you do a global installation (with sudo) since PyRep won't find COPPELIASIM_ROOT:

    ERROR: Command errored out with exit status 1:
    command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-m9qd50yj/setup.py'"'"'; __file__='"'"'/tmp/pip-req-      build-m9qd50yj/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-w48qqfxo
        cwd: /tmp/pip-req-build-m9qd50yj/
    Complete output (7 lines):
    Traceback (most recent call last):
     File "<string>", line 1, in <module>
     File "/tmp/pip-req-build-m9qd50yj/setup.py", line 7, in <module>
       import cffi_build.cffi_build as cffi_build
     File "/tmp/pip-req-build-m9qd50yj/cffi_build/cffi_build.py", line 9, in <module>
       raise RuntimeError('COPPELIASIM_ROOT not defined.')
    RuntimeError: COPPELIASIM_ROOT not defined.
    ----------------------------------------
    WARNING: Discarding file:///home/robolab/software/PyRep. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.