ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

debugging a ros Python program

asked 2017-10-04 07:32:18 -0500

Younès gravatar image

Hi all

I have a python program which I run with rosrun

rosrun  node_example

I want to debug this program I know that there is a tool called pdb used for debuging, but I don't know how to use it with rosrun.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-10-05 07:49:20 -0500

Alberth gravatar image

noob, but afaik, rosrun just eliminates the need to go to the directory with the file in it. You can thus easily get around using rosrun by going to the "node_example" package manually, eg with "roscd node_example". There you should find the file, that you can start with pdb.

edit flag offensive delete link more


This will work, but rosrun (and roslaunch) does a little more than just cd $pkg && ./node_script: it also provides the node with its name, location of the logfile, private parameters (optional) and (topic) remappings.

gvdhoorn gravatar image gvdhoorn  ( 2017-10-05 09:37:30 -0500 )edit

It is working for me with rosrun node_example by adding import pdb and pdb.set_trace(). But, the program doen't stop in the breakpoint. It continues to run the callback functions ?

Younès gravatar image Younès  ( 2017-10-05 10:34:42 -0500 )edit

Never tried that, but suggests to add a set_trace in each thread. In any case, this would be a generic pdb-threading problem, rather than a ROS-specific problem. You might find better help in a generic Python forum/site.

Alberth gravatar image Alberth  ( 2017-10-09 03:37:39 -0500 )edit
Ruben Alves gravatar image Ruben Alves  ( 2017-10-09 07:56:15 -0500 )edit

It works for me when adding pdb.set_trace() at the beginning of each method I want to debug.

Younès gravatar image Younès  ( 2017-10-09 10:12:54 -0500 )edit

Question Tools



Asked: 2017-10-04 07:32:18 -0500

Seen: 3,879 times

Last updated: Oct 05 '17