-
-
Notifications
You must be signed in to change notification settings - Fork 9
Setup (Pycharm)
manx52 edited this page Sep 20, 2024
·
31 revisions
- Note: Do not install Pycharm using snap, it will give a different version of pycharm
- Get the Jetbrains student membership (https://www.jetbrains.com/student/) or use the UTRA account https://docs.google.com/document/d/1eJVmYDuQD8JyMIl4DCIleO53GXAQwRqBPCAXFO6W6mQ/edit
- Use Jetbrains installer (https://www.jetbrains.com/toolbox/app/) and install Pycharm Professional (or Pycharm Community if you don't have the license)
- Change the theme to the white theme
- Open Pycharm, go to File > Open and open the repository name (soccerbot)
(Optional) Auto Sync using settings repository
- Click File > Manage IDE Settings > Settings Repository
- If the option is disabled, you need to diable cloud sync File > Manage IDE Settings > IDE Settings Sync > Disable
- Set https://github.com/utra-robosoccer/soccerbot_pycharm_settings.git as the Upstream URL and then click Overwrite Local
- Note: Do not use the virtualenv intepreter (ROS uses the system intepreter and it will cause inconsistency when running the code
- Use the System Intepretor
- Go to File > Setting > Project:xxxx > Python Interpreter > Show All > Add > Add local intepreter > System Intepreter and choose /usr/bin/python3.8
- Click File > Setting > Project:xxxx > Python Interpreter > Show All > Python 3.8 > Show paths for the selected interpreter (5th button from the left) > Add the Intepreter Paths (Replace $USER with your computer user)
/opt/ros/noetic/lib/python3/dist-packages /home/$USER/catkin_ws/devel/lib/python3/dist-packages /home/$USER/catkin_ws/src/soccerbot/external/webots/lib/controller/python38
- OR Use the docker-compose Intepretor
- Go to File > Setting > Project:xxxx > Project Interpreter > (Click on the Gear) > Add > Docker Compose
- choose the docker-compose.yaml file
- choose service as friendly
- choose python interpreter path as
/usr/bin/python3
- Click on the gear > show all > Select python 3.8 > Show paths for the selected interpreter (5th button from the left) > Add the Intepreter Paths
- Install the *.launch file plugins. Look up duckietown/hatchery from the third party repositories in Preferences/Plugins
- Edit the file
/etc/sysctl.d/10-ptrace.conf
and change the linekernel.yama.ptrace_scope = 1
tokernel.yama.ptrace_scope = 0.
and then runsudo service procps restart
- Run > Attach to Process > Select the Process you want to attach to, you might want to rosnode info to identify it's PID. Add a breakpoint
- Run
sudo visudo
and add the lineshahryar ALL=NOPASSWD:/usr/bin/gdb
(replace shahryar with your name)- Edit the
~/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5080.212/plugins/python/helpers/pydev/pydevd_attach_to_process/add_code_to_python_process.py
line 470 and add the sudo to it so it looks like the following (Note:221.5080.212
folder might differ on your computer but follows the samenumber.number.number
format)cmd = [ 'sudo', 'gdb', '--nw', # no gui interface '--nh', # no ~/.gdbinit '--nx', # no .gdbinit # '--quiet', # no version number on startup '--pid', str(pid), '--batch', # '--batch-silent', ]
- Edit the
~/.local/share/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5080.212/plugins/python/helpers/pydev/pydevd_attach_to_process/attach_pydevd.py
line 470 and change the setup host to '172.17.0.1' on line 12def process_command_line(argv): setup = {} setup['port'] = 5678 # Default port for PyDev remote debugger setup['pid'] = 0 setup['host'] = '172.17.0.1' setup['protocol'] = ''
- Run > Attach to Process > Select the Process you want to attach to, you might want to rosnode info to identify it's PID. Add a breakpoint
Add this to Environmental Variables LD_LIBRARY_PATH=/usr/local/lib:/opt/ros/noetic/lib:/usr/local/bin/python3
Add -s to additional argumement
Add this to Environmental Variables LD_LIBRARY_PATH=/usr/local/lib:/opt/ros/noetic/lib:/usr/local/bin/python3
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ros/noetic/lib:/home/jonathan/catkin_ws/devel/lib
Add -s to additional arguments to print out stdout while pytest is running
add this to CMake options
-DCATKIN_DEVEL_PREFIX:PATH=/home/jonathan/catkin_ws/devel -DPYTHON_VERSION:STRING=3.8 -DCMAKE_PREFIX_PATH:PATH=/home/jonathan/catkin_ws/devel;/opt/ros/noetic