Installation
Linux
systems (Ubuntu22.04
) and Windows
systems.
Linux(Ubuntu22.04)
Ubuntu22.04
is that the simulation engine we use, webots2023b
, is compatible with the Linux system version Ubuntu22.04
.
If you have installed another version of Linux, you can refer to the webots code repository to download and configure the appropriate version.
Step1 Install the Webots simulation software
Download the deb package of webots 2023b version (e.g.,
webots-R2023b-x86-64.deb
) and the asset files (assets-R2023b.zip
) from webots, and install them using the following command:Webots Installation
## install sudo dpkg -i webots_2023b_amd64.deb ## run webotsAsset Decompression
mkdir -p ~/.cache/Cyberbotics/Webots/assets/ cp ~/Downloads/assets-R2023b.zip ~/.cache/Cyberbotics/Webots/assets/ ## unzip cd ~/.cache/Cyberbotics/Webots/assets/ && unzip ./assets-R2023b.zip
Step2 Creating a Virtual Environment and Installing Libraries
Virtual Environment Creation
conda create -n uav_follow311 python=3.11 conda activate uav_follow311Algorithm Side
## Alg requirements pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121 pip install numpy==1.25.0 pip install opencv-python==4.9.0.80 pip install gym==0.25.1 pip install setproctitle==1.3.3 pip install tensorboard pip install tqdm pip install stable-baselines3==2.3.0 pip install sb3_contrib==2.3.0 pip install gymnasium pip install wandb==0.17.6 pip install memory_profiler==0.61.0 pip install psutil==6.0.0 pip install pandas pip install openpyxl pip install tianshou==1.1.0Simulator Side
## Simulator requirements sudo apt-get install libeigen3-dev sudo apt-get install nlohmann-json3-dev sudo apt install sumo sumo-tools sumo-doc pip install lxml pyproj shapely webcolors configparser --user pip install transforms3d ## config gedit ~/.bashrc # Change dir according to your installation export SUMO_HOME=/usr/share/sumo export WEBOTS_HOME=/usr/local/webots
Step3 Modify the Python environment for running Webots
Since the environment we are using is different from Webots’ default Python environment, we need to create symbolic links for our new environment and configure it.
ln -s /root/miniconda3/envs/uav_follow311/bin/python3.11 /usr/bin/python311Next, open the webots software, go to
Tools
->Preferences
, and modify the optionPython command
as shown in the following image:
Windows
Step1 Install Webots Simulation Software
Download the webots 2023b version installer (
.exe
file) and the asset file (assets-R2023b.zip
) from webots.Copy the assets to the specified path:
C:/Users/<USER>/AppData/Local/Cyberbotics/Webots/cache/assets
Then open Webots. If the environment displays correctly during the tour guide stage for new users, the installation is complete.
Step2 Create Virtual Environment and Install Libraries
Virtual Environment Creation
conda create -n uav_follow311 python=3.11 conda activate uav_follow311Algorithm Side
## Alg requirements pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121 pip install numpy==1.25.0 pip install opencv-python==4.9.0.80 pip install gym==0.25.1 pip install setproctitle==1.3.3 pip install tensorboard pip install tqdm pip install stable-baselines3==2.3.0 pip install sb3_contrib==2.3.0 pip install gymnasium pip install wandb==0.17.6 pip install memory_profiler==0.61.0 pip install psutil==6.0.0 pip install pandas pip install openpyxl pip install tianshou==1.1.0Emulator Side
1. Installation of Python libraries## Simulator requirements conda activate uav_follow311 pip install lxml pyproj shapely webcolors configparser --user pip install transform3d2. C++ Library Installation (If recompilation of the C++ code is not needed, this can be ignored)
First, download the latest version of the
Eigen3
library from the official website eigen.Download and install the latest version of the
Eigen3
library. Eigen download linkDownload and install the latest version of the
nlohmann-json3
library. nlohmann-json3 download link3. Webots'makefile
configuration (can be ignored if the C++ part does not need to be recompiled)Paths of makefile files that need to be modified include:Webots_Simulation/traffic_project/controllers/drone_ctrl2/Makefile
Webots_Simulation/traffic_project/controllers/simpleCar_ctrl/Makefile
Since the Linux system generally does not require additional settings for include paths, a check for the Windows system has been made. If it is a Windows system, you need to manually modify the makefile of the drone_ctrl2 and simpleCar_ctrl controllers, adding the include paths for eigen and nlohmann_json.
null := space := $(null) $(null) WEBOTS_HOME_PATH?=$(subst $(space),\ ,$(strip $(subst \,/,$(WEBOTS_HOME)))) ifeq ($(OS),Windows_NT) INCLUDE += -I D:/cppLibrary/include/Eigen3/include/eigen3 INCLUDE += -I D:/cppLibrary/include/nlohmann_json/include endif include $(WEBOTS_HOME_PATH)/resources/Makefile.include
Among them,
INCLUDE += -I D:/cppLibrary/include/Eigen3/include/eigen3
needs to be configured as the path to theEigen3
library.
INCLUDE += -I D:/cppLibrary/include/nlohmann_json/include
needs to be configured to the path of thenlohmann-json3
library.After completing the above modifications, you can open the controller in the Webots editor and recompile it.
4. Installsumo
Follow the instructions in the sumo-interface.md document for installation.
5.webots
andsumo
environment variable configuration
First, press
WIN+R
to bring up the Run window, then typesysdm.cpl
to open the System Properties page. Next, select “Advanced” -> “Environment Variables” -> “System variables” -> “New”.Insert
SUMO_HOME
configured as shown in the following figure:Insert
WEBOTS_HOME
and configure it as shown in the figure below:
Step3 Modify the Python environment for running Webots
In Linux systems, the issue is resolved by adding a symbolic link, while in Windows, the running path is directly inserted into webots.
Enter the webots software, select
Tools
->Preferences
, and modify thePython command
option as shown in the figure below:
Docker
Step1 Download Webots and Create Docker Container to Run with GPU
Create Workspace and Download Webots
## Create Workspace mkdir Workspace cd Workspace/ git clone https://github.com/cyberbotics/webots-docker.git
Create Docker Container and Run with GPU
sudo docker run --gpus "device=0" --privileged=true -p 5900:5900 -p 7787:7787 -p 6006:6006 -it cyberbotics/webots:latest /bin/bash
Step2 Creating a Virtual Environment and Installing Libraries
Virtual Environment Creation:
conda create -n uav_follow311 python=3.11 conda activate uav_follow311
Algorithm Side:
## Alg requirements pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121 pip install numpy==1.25.0 pip install opencv-python==4.9.0.80 pip install gym==0.25.1 pip install setproctitle==1.3.3 pip install tensorboard pip install tqdm pip install stable-baselines3==2.3.0 pip install sb3_contrib==2.3.0 pip install gymnasium pip install wandb==0.17.6 pip install memory_profiler==0.61.0 pip install psutil==6.0.0 pip install pandas pip install openpyxl pip install tianshou==1.1.0
Simulator Side:
## Simulator requirements sudo apt-get install libeigen3-dev sudo apt-get install nlohmann-json3-dev sudo apt install sumo sumo-tools sumo-doc pip install lxml pyproj shapely webcolors configparser --user pip install transforms3d ## config gedit ~/.bashrc # Change dir according to your installation export SUMO_HOME=/usr/share/sumo export WEBOTS_HOME=/usr/local/webots
Add Python symbolic Links:
## Create symbolic link for algorithm side Python ln -s /root/miniconda3/envs/uav_follow_alg311/bin/python3.11 /usr/bin/python311 ## Create symbolic link for simulation side Python ln -s /root/miniconda3/envs/uav_follow311/bin/python3.11 /usr/bin/python311 mv /usr/bin/python3.10 /usr/
Step3 Configure Project Workspace
Download Project
## Clone project mkdir /usr/local/Github_Project cd /usr/local/Github_Project git clone ${github_link}
run webots simulation
## Run simulation initialization code, ensure the program completes initialization before proceeding conda activate uav_follow311 xvfb-run -a webots --stdout --stderr --no-rendering --batch --mode=fast ${map_file} ps aux | grep xvfb x11vnc -display :99 -auth ***
Configure Algorithm Side
cd /usr/local/Github_Project/UAV_Follow_Env/Alg_Base/DAT_Benchmark/ python311 ${main_path}Here, the path for ${main_path} can be found in: Introduction to the Algorithm Section