He, Peng

A Roboticist.

Robotic is the integration of all human knowledge, so far.

How to use PyCharm / Clion to debug on ROS

Abstract: First of all, this is a working setup tutorial. And that's all of it.

After years of dealing with ROS, I found the PyCharm or Clion from Jetbrain being my favourate IDE beside Sublime, and yes, I use Sublime most of the time.

What you will get from this

  • An IDE and detects all function block codes so you can navigate your project easily.
  • An debugger that let you set breakpoints in a python file. More specific, a python ROS node, such that you will be able to see the:
    • online variable values
    • function call orders
    • etc.

How To Setup?

  1. Download Pycharm CE with any version.
  2. Install the PyCharm by:
    1. Unpack the PyCharm, I usually create a folder ~/App/ and dump the program there.
    2. Open a console and cd into "{installation home}/bin" and type:
  3. Create a Desktop Entry, this option is only shown in the program when you run the ./pucharm.sh
  4. Import bash environment to the PyCharm launcher by: edit the launcher file in either /usr/share/applications or ~/.local/share/applications (depending on whether or not you installed PyCharm for all users).
    1. find this line Exec="/usr/lib/pycharm-community/bin/pycharm.sh" %f
    2. replace it with Exec=bash -i -c "/usr/lib/pycharm-community/bin/pycharm.sh" %f, double check the thing, basically you are adding bash -i -c after the =.
  5. Setup the ROS Python Interpreter, becareful, you need to setup the global(system) python 2.7 as the project interpreter, this is because the ROS uses it and all the message headers etc. are exported to this interpreter namespace. This PyCharm default one will not work also if you create a venv with python 2.7 will not work as well!
    1. It is very important that you launch the IDE from a terminal by doing:
      $ pycharm-community
    2. Go to File->Settings->Project Interpreter -> Python Interpreters, and select the Python2.7
    3. interpreter
  6. You are all set!

How to launch ?

You should be able to launch from the IDE shortcut icon, however I found it very confusing if you have a previous version's app icon also shown up in the launcher, so if you see two icons, try out them both and simply lock the one that works to your dashbar.

Alternatively, you can always launch the IDE from a terminal by doing:

$ pycharm-community

such that you has the bash env.

After that, you can do the regular making the run or debug config file on a python script or directly right click the file in project navigation to debug and script and setup break points.

Clion Version

Almost the same.

Set build paths to the catkin workspace

By default, CLion places build output in cmake-build-debug or cmake-build-release directory that is created automatically. For ROS development, it means that you will have two different builds in CLion and in the console where you run catkin_make.

To have a single build across the IDE and console, you need to set CLion build paths to the catkin workspace directories. For this, go to File | Settings (Ctrl+Alt+S) | Build, Execution, Deployment | CMake and change two fields:

In CMake options


In Generation Path,


Register launch files as XML

Go to File | Settings (Ctrl+Alt+S) | Editor | File Types and select XML from the list of Recognized File Types.

Add *.launch extension to the list of Registered Patterns.

To Make Clion work with ROS Python

You need to select the python interpreter as the system bin/2.7 one, if not existing, add a system type one to it.

Recent Posts

ROS TF, Whoever wrote the Python API, F**ked up the concepts.

Abstract: TF, is very useful when dealing with transformations in robot navigation. Unfortunately, t…

In ROS, Python, C++, TFRead More
Earlier Posts

ROS Import Python Module From Another Package

Abstract: This will be a fire to go blog. It is really not hard to do this but ROS wiki did a good j…

In ROS, Python, CMakeLIstsRead More
comments powered by Disqus