1. Open Pycharm
2. Click "Pycharm" menu

3. Click "Preferences"

4. Project -> Project Structure -> Add Content Root -> Go to "Application/Webots.app/lib/controller/python37"
5. Project -> Project Interpreter -> Setting ( In my case, the project interpreter is used in Anaconda environment. )


6. Click "Run" menu -> Configuration -> click "+(add)" -> python -> Setting "script path" and "environment variables" in configuration.

Script path :
/Users/Desktop/project_name/controllers/project_controller/controller.py
environment variables : PYTHONUNBUFFERED=1;DYLD_LIBRARY_PATH =/Applications/Webots.app/lib/controller ;PYTHONPATH=/Applications/Webots.app/lib/controller/python37
7. open the webots
8. controller setting -> <extern>

The Webots Python API depends on the Webots CPP API, therefore, the path need to be modifed to include the Webots lib directory.
This can be done from the Run / Edit Configurations menu.
In the Run Configurations windows,
-> press the + button and then select Python
-> in the Script path, set the path to point to your python file
-> in the Environment variables, define the path variable (i.e. DYLD_LIBRARY_PATH on macOS) to point to WEBOTS_HOME/lib/controller.
-> On Windows, you should also add WEBOTS_HOME/msys64/mingw64/bin to your PATH environment variable. If you are using other libraries (e.g., the vehicle libraries, DARwIn-OP library, etc.), the path to the corresponding shared libraries should be added as well.
https://cyberbotics.com/doc/guide/using-your-ide?tab-language=python

'AI > python or ros_Webot' 카테고리의 다른 글
Webots - Python ( PyCharm ), SSH, External Controller (0) | 2020.07.13 |
---|---|
Webots Tutorial 8 - Using ROS ( 60 minutes ) (0) | 2020.06.10 |
Webots Tutorial 7 - Your First PROTO (0) | 2020.02.20 |
Webots Tutorial 6 - 4-Wheels Robot (0) | 2020.02.20 |
Webots Tutorial 5 - Compound Solid and Physics Attributes (0) | 2020.02.19 |
댓글