-
Notifications
You must be signed in to change notification settings - Fork 1
Simulation Environment
simulation environments provide a physical environment where one can create a model of physical objects and agents (Thymio2 robots). A simulation environment is important to:
- proove desired behavior of robot agents under physical constraints
- proove desired control of the implemented controller algorithm
- acquire knowledge about the system in scenarios that are difficult to provide in reality (many robots, infinite space)
- infere knowledge about the effects of changes in the physical environment and prepare to real experiments accordingly
There are many simulation environments used in robotics on the market, such as Argos, ROS or WeBots. We chose to use WeBots as Thymio2 robot models are already implemented and ready to use here with an arbitrary controller that can be also written in python3.
In this step-by-step guide I show how to install webots and more importantly how to start an example siulation on your system using VisualSwarm robot models.
- Ubuntu
to install webots on an ubuntu system I suggest to use APT as stated in the step-by-step guide on webots' installation page.
- Windows
on a Windows system just download the installer as stated here and follow the installation wizard.
after installing WeBots choose a folder where you are going to install everything related to VisualSwarm (clone directory, create virtualenv, etc.). Then simply clone the project in this folder.
- Ubuntu
Install git if not yet installed and then use the following commands:
//creating new folder
mkdir Webots-VSWRM
cd Webots-VSWRM
//clone VSWRM
git clone https://github.com/mezdahun/VisualSwarm.git
- Windows
On windows you might need to install git and git bash to be able to use git features.
One can create a venv for WeBots according to this very nice description which I will also copy here.
- Ubuntu
//Installing virtualenv
sudo apt-get install python3.7-venv
//Create a new virtualenv for the project
python3.7 -m venv VSWRMenv
//Activate the environment
source VSWRMenv/bin/activate
//Check if the env is healthy
which python
after the last command you should see this: .../env/bin/python
- Windows
//Installing virtualenv
py -m pip install --user virtualenv
//Create a new virtualenv for the project
py -m venv VSWRMenv
//Activate the environment
.\VSWRMenv\Scripts\activate
//Check if the env is healthy
where python
after the last command you should see this: .../env/bin/python.exe
after activating the virtual environment we can install the package VisualSwarm in it locally. You can see if the venv is activated as (VSWRMenv)
is visible in your terminal in front of the command line.
- Ubuntu and Windows
Please be sure that your venv is active, otherwise you will install the package globally! Here I suppose you are in the directory that you created in the beginning in which you have the folder VisualSwarm
that is the result of cloning the project.
Currently the simulation-related changes are on a dedicated branch so first checkout to this branch with
cd VisualSwarm
git checkout feature/webots-simulation
As the simulation and the real robot version of the package is slightly different an additional setup_simulation.py
script is is now visible on this new branch. To install the simulation version, first delete the original setup.py
and rename setup_simulation.py
to setup.py
. After this step pip
will recognize this setup file and installs the correct simulation version instead of the other one that should only be installed on Raspberry Pis.
As you are about to install the package VisualSwarm on a non-Raspbian system, you need to use the following to install picamera module
export READTHEDOCS=True
Now go back to the parent directory and use the following to then install Visualswarm's simulation version:
cd ..
python -m pip install --upgrade pip
pip install VisualSwarm
If you get any dependency error during installing the package, please visit the installation page on the wiki and follow the step-by-step guide there to resolve these dependency problems.
after installation check if VisualSwarm is installed correctly by using
ENABLE_SIMULATION=1 vswrm-health
for which you should get an output INFO:visualswarm.app:VisualSwarm application OK!
Now we need to enable webots to use our created virtualenvironment in which we installed VisualSwarm. To do so, open webots and go to tools>>preferences
and set the python command
field to the following path: <absolute-path-to-created-virtualenv-parent-directory>/VSWRMenv/bin/python3.7
.
You can also set the startup mode
field to Pause
so that the simulations do not start automatically when webots open.
After configuring the python command now you can open the example .wbt
file in the cloned directory, by clicking on File>>Open World...
in webots. Browse into the folder where you cloned Visualswarm and see the wbt file under VisualSwarm/data/webots/VSWRM_WeBots_Project/worlds
.
You should be able to run this world file after which the robots start moving according to the implemented controller.
The interface code of the controller is in a python file under VisualSwarm/data/controllers/VSWRM-controller
. In this folder there are also configuration json files that allow the user or any other software to start the simulations with an arbitrary set of parameters.
More information about these parameters are provided in the controller code and will be further described on another wiki page soon.