본문 바로가기
AI/python or ros_Webot

How to connect between Pycharm and Webots?

by 몽돌리스트 2020. 6. 10.
반응형

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

https://www.cyberbotics.com/doc/guide/running-extern-robot-controllers?tab-os=macos&tab-language=python

반응형

댓글