PyCharm with ROS Integration¶
Setup Package Path¶
When following these steps, ROS-packages will be added to your PYTHONPATH. This leads to PyCharm indexing them and thus you can use auto completion. If you use Source ROS, this is not necessary.
- Settings –> Project:bitbots_meta –> Project Interpreter
- Cog at the top right next to the Interpreter –> Show All
- Lowest button on the right side (“Show paths for the selected interpreter”)
- Add –> /opt/ros/melodic/lib/python3/dist-packages
- Add –> <catkin_ws>/devel/lib/python3/dist-packages
When using this method, ROS will be sourced when starting PyCharm. This means all ROS-commands and paths are known to PyCharm. This means PyCharm knows just as much as your Shell and can theoretically do the same things.
cp /usr/share/applications/pycharm-professional.desktop ~/.local/share/applications/pycharm-with-ros.desktop
Change the name, otherwise you overwrite the global PyCharm starter.
Exec=bash -c "source <catkin_ws>/devel/setup.bash; /usr/bin/pycharm %f"
To test/debug nodes in an efficient way with PyCharm, you can add the argument
depends_only to your launch-file.
This means, only the node you want to test will be started.
After you have started the node externally, using
roslaunch, PyCharm will be able to start this node and you can debug.