This course uses the robotic simulator CoppeliasSim, the programming language Python and the Python package PyRep, which wrapes CoppeliaSim's API and provides a high-level interface between CoppeliaSim and Python. High-fidelity 3D objects are provided by the YCB Dataset and WTM's YCB API,
On Ubuntu 18.04, run the following commands to install CoppeliaSim in your home directory:
Alternatively, you can download the Edu verion for CoppeliaSim from here and extract the archive manually.
Verify installation:
This should start CoppeliaSim and open an empty scene. You might get prompted to install aditional video compression libraries, if so, install them with sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
.
For this course, you will be using the programming language Python. Python is pre-installed on Ubuntu verify that you have it: python3 --version
This will likely output Python 3.6.9
, if you have Python3 installed.
However, there are a few packages that you should install to ensure a complete development environment. Paste the following into your terminal:
We prepared a repository with PyRep and the YCB dataset for you, to streamline the setup process. The below steps clone that repository, install PyRep and download the YCB models.
Below, we setup the environment variables needef for PyRep to interact with CoppeliaSim, create a virtual environment and install PyRep (and its requirements) in that venv.
Keep in mind that everytime you restart your shell, you will have to activate the virtual environment again!
If you just followed the guide, you can just run the below command directly:
Otherwise, first source the virtual environment then set the working directory of your terminal to the examples
inside the PyRep
folder.
In the folder ycb-objects-sim
, you find tools to use the YCB objects dataset in CoppeliaSim. However, the models have to be downloaded first and some configuration is due:
<project_root>/ycb-objects-sim/src/config.py
so that it points to the folder data
in <project_root>/ycb-objects-sim/src/
. This specifies the location where the object will be downloaded to (~3GB).ycb-objects-sim
folder to the PYTHONPATH
: For this, edit the script activate.bash
in ycb-objects-sim
source activate.bash
ycb-objects-sim
:If you get an SSL certificate error (urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)>
), run the following two commands to refresh your certificates:
simAddOnScript_remoteSDFImp.lua
from ycb-objects-sim/RemoteSDFImp
to the installation folder of CoppeliaSim. You can either copy and paste the file by hand, or run the below command:If everything worked, you can now run the script example_coppelia.py
located in ycb-objects-sim
. If you restarted your terminal or are using a different session, you will have to run activate.bash
again, so that the ycb-objects-sim
folder is added to your PYTHONPATH
. Then, run: python3 example_coppelia.py
This should open CoppeliaSim and spawn a few of the downloaded objects in the scene.
As IDE, we will be using PyCharm. You can install it via SNAP/ or from the Ubuntu Software app. As a student, you can get a one-year professional key. Alternatively, install the community or EDU edition.
To make PyCharm work with PyRep and CoppeliaSim, you have to do two things:
Set the virtual environment, that we created earlier, as interpreter for your PyCharm project under Settings
-> Project ...
->Python Interpreter
-> Show All...
-> +
Existing environment
-> ...
-> <PATH-TO-VENV>
(eg /home/finn/uni/venv/bin/python3
)
For the Python file that interacts with the CoppeliaSim, set the following environment variables. Of course, adjust the paths to your system (if you followed this guide, you just have to replace "finn" with the ouput of the whoami
command)
Alternatively, if you get something like: ModuleNotFoundError: No module named 'pyrep'
(especially when using a virtualenv), make sure PyRep installed correctly and that is is on the PYTHONPATH
(check here).
qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
: Check your your environment variables! Maybe typo in QT_QPA_PLATFORM_PLUGIN_PATH=/home/finn/CoppeliaSim_Edu_V4_1_0_Ubuntu18_04/
?
ModuleNotFoundError: No module named 'wheel'
: Install Python wheel
and setuptools
in virtual environment: python3 -m pip install wheel setuptools
ModuleNotFoundError: No module named 'pyrep.backend._sim_cffi'
: You are likely trying to import PyRep while your workind directory is set to PyRep's root directory. In this case, the imports fail, because Python tries to import from the folders instead of the installed packages. Change your working example (for example cd examples
) and try again.