-
-
Notifications
You must be signed in to change notification settings - Fork 9
Setup (Pycharm)
Jason Wang edited this page May 24, 2022
·
31 revisions
- 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)
- 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
- Use the System Intepretor
- Go to File > Setting > Project:xxxx > Project Interpreter > (Click on the Gear) > Add > System Intepreter and choose /usr/bin/python3.8
- 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 (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.8
- 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
/usr/lib/python3.8 /usr/local/lib/python3.8/dist-packages /usr/lib/python3/dist-packages /opt/ros/noetic/lib/python3/dist-packages /root/catkin_ws/devel/lib/python3/dist-packages
- Under path mappings, add the path mapping
/home/$USER/catkin_ws -> /root/catkin_ws
- Go to File > Setting > Project:xxxx > Project Interpreter > (Click on the Gear) > Add > Docker Compose
- 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 12
def 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