This guide explains how to configure the necessary Python environment and run the Webots simulation.
- Webots (R2025a or later recommended)
- Python 3.11.9
- Git
-
Clone the Repository
git clone https://github.com/andrebellu/echoarm.git cd echoarm -
Create the Virtual Environment (
venv)This project requires Python 3.11.9 specifically. A virtual environment ensures that all dependencies are isolated and managed correctly.
# Check your current Python version python --version # It should show: Python 3.11.9
If you have multiple Python versions installed, create the virtual environment explicitly with Python 3.11:
- On Windows:
py -3.11 -m venv robot_venv
- On macOS/Linux:
python3.11 -m venv robot_venv
If Python 3.11.9 is already your default version, you can simply run:
python -m venv robot_venv
⚠️ Important: Make sure you're using Python 3.11.9 to create the virtual environment, as other versions may cause compatibility issues. -
Activate the Virtual Environment
-
On Windows (cmd or PowerShell):
.\robot_venv\Scripts\activate
-
On macOS/Linux:
source robot_venv/bin/activate(You should see
(robot_venv)at the beginning of your terminal prompt.)
-
-
Verify Python Version in Virtual Environment
With the
(robot_venv)active, check the Python version:python --version
This should show:
Python 3.11.9 -
Install Required Packages
pip install -r requirements.txt
-
Verify Installation
To ensure everything is set up correctly, run:
python -c "import mediapipe, cv2, numpy, ikpy; print('All packages are installed correctly.')"If no errors appear, the installation was successful.
You must configure Webots to use the Python interpreter from your new virtual environment; otherwise, it won’t find the installed libraries.
- Open Webots.
- Go to the top menu:
Tools→Preferences.... - In the General tab, find the python command field.
- Click Select....
- Navigate to your project folder →
robot_venv→- Windows:
robot_venv\Scripts\python.exe - macOS/Linux:
robot_venv/bin/python
- Windows:
- Click OK or Apply.
- Restart Webots for the change to take effect.
⚠️ Note: In some cases, Webots may request the absolute path to the Python executable.
Make sure to provide the full path to thepython.exeinside your virtual environment (e.g.
C:\Users\<username>\Documents\webots\echoarm\robot_venv\Scripts\python.exe).
The system consists of two parts: the Webots Simulator (Server) and the Python GUI (Client). Follow this specific order to establish the connection.
-
Launch Webots.
-
Go to File → Open World....
-
Select simulation.wbt located in the worlds/ directory.
-
Pause the simulation if it starts automatically.
-
Open a terminal/command prompt.
-
Activate the virtual environment (see Section 2).
-
Run the GUI script
python gui.py
-
The GUI window will open. The status indicator should show "DISCONNECTED" (or Red) because the simulation is not running yet.
-
Return to the Webots window.
-
Click the Play button (▶) in the top toolbar.
-
Watch the GUI window:
-
Within a few seconds, the status indicator should turn GREEN / "CONNECTED".
-
The Webots console output should display: >>> GUI connected.
-
Scan Phase: Wait for the robot camera to scan the patient (watch the percentage overlay in the 3D view).
-
Command: Once the scan is complete, click a button on the GUI (e.g., "TESTA" or "BRACCIO_DX").
-
Action:
-
The GUI log will confirm: Target sent: ...
-
The robot in Webots will perform the desired movement
-
- Verify Webots is using the correct Python from your virtual environment
- Restart Webots after changing the Python path
- Use absolute paths instead of relative paths
- Make sure the virtual environment is activated when checking the Python path
- This means Webots is using the wrong Python interpreter.
- Double-check Section 3 and ensure the path points to
robot_venvand not the system Python. - Restart Webots after changing the path.
This error occurs when launching gui.py if the system-level Tkinter library is missing (required by CustomTkinter).