Ask Your Question
2

How to debug ROS porgrams?

asked 2016-08-27 07:24:18 -0500

niubc gravatar image

I have learned ros for two weeks and I konw how to create a package. I can write some programs on windows.Now I want write nodes on my own, but I find I can't debug programs, which is very different from windows programs. I am used to press "build" button to know if there are mistakes in my program.Maybe some tools can finish this work?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

answered 2016-08-27 14:38:12 -0500

ahendrix gravatar image

It's not entirely clear what you're asking, so I'll explain the differences and give two methods:

Debugging refers specifically to running your program in a debugger, which can catch run-time errors, and which allows you to stop your program at any point and inspect the variables and the call stack while the program is running.

The "build" button that you refer to sounds like it compiles your program and reports any errors; these are compile errors and happen before you can run your program.

It sounds like you're used to use an IDE (Integrated Development Environment) that hides these details from you. ROS, and general software development on Linux, does not try to hide this process.

To build your ROS program, you must first tell the system which files you want to build by writing the CMakeLists.txt file (examples are covered in the tutorials). You then build your program with the catkin_make command.

To run, you use rosrun. You can use the --prefix option to rosrun to run your program in a debugger such as gdb, or in a memory check program such as valgrind.

There are also a number of IDEs that have some integration with ROS, but they may not provide all of the features you expect: http://wiki.ros.org/IDEs (I haven't tried any of them, but I know other people like them).

edit flag offensive delete link more

Comments

Thank you so much !!!

niubc gravatar image niubc  ( 2016-10-08 23:51:17 -0500 )edit
1

answered 2018-06-14 06:37:42 -0500

Marc_Chen gravatar image

I am new to ROS and trying to set up the develop environment for myself and the team. I think all ros nodes are just started by the ros framework and run as normal executable, so if we switch the context and change the question to "how to I debug any running C++ executable" and start searching using that keywords, you will be able to find tutorials.

I wrote a blog post and uploaded a project on github, see if it helps

https://github.com/weihangChen/ros_de...

https://medium.com/@weihang.che/ros-n...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-27 07:24:18 -0500

Seen: 9,908 times

Last updated: Aug 27 '16