Skip to content
Michal Staniaszek edited this page Oct 14, 2020 · 6 revisions

C++

If launching with ROS, just use launch-prefix="gdb --args" as one of the node parameters.

With vscode, the debugging process can be made more pleasant using a debug config which looks something like

        {
            "name": "anymal sim director debug",
            "type": "cppdbg",
            "request": "launch",
            "program": "/home/michal/robots/drs_space/catkin_ws/devel/.private/director/lib/director/director",
            "args": ["--startup", "/home/michal/robots/drs_space/drs/director_drs/src/director_drs/runstartup.py", "--robot-config", "/home/michal/robots/drs_space/drs/director_drs/config/anymal_sim/director_config.yaml"],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },

In order for this configuration to work correctly, you may need to source your catkin workspace in the "Terminal" tab at the bottom, where you will see the output of the command.

Python

Debugging is done with pdb. Include

import pdb
pdb.set_trace()

Somewhere in the code where you want to enter the debugger. By default the interaction with pdb will take place in the python console which can be brought up with F8 in the director window. However, if you want to debug something which happens before the initialisation is complete, you must add

import sys
sys.stdin = sys.__stdin__
import pdb
pdb.set_trace()

pdb will then be accessible from the terminal in which director was started.

It appears not to be possible to debug with PyCharm as the built in debugger cannot attach to the process. Further investigation required.

Clone this wiki locally