Ask Your Question
0

Use gdb for ros control plugin

asked 2016-06-27 21:51:17 -0500

cangjiaxuan gravatar image

updated 2016-06-27 21:53:05 -0500

Hi all,

Somebody who have used gdb to debug a ros control plugin please share some experience with me:)

I added the "launch-prefix="gdb -ex run --args" " attribute in the node tag of my launch file.

But when roslaunch the launch file here is what I got

"/opt/ros/indigo/lib/controller_manager/spawner": not in executable format: File format not recognized
Starting program:  joint1_effort_controller __name:=controller_spawner __log:=/home/lc/.ros/log/7a02b5fc-3c75-11e6-8071-0023248137eb/rrbot-controller_spawner-1.log
No executable file specified.

My gdb version is 7.7.1 and my ubuntu version is 14.04, my ros version is indigo.

And by the way if don't use gdb, is there any other debug tools for debugging a plugin?

Thanks in advance

Erli

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-06-28 01:51:03 -0500

gvdhoorn gravatar image

The spawner script is a Python script that invokes some services to load / start / stop / unload your controllers. If you want to debug a controller, I think you'd need to run the process that contains your controller_manager and possibly your hardware_interface in gdb.

edit flag offensive delete link more

Comments

Thank you for your comment, now I know why I have such error. For debugging a controller in gdb, would you mind to describe it in more detail or provides me with some link solving similar question? Thanks again!

Erli

cangjiaxuan gravatar image cangjiaxuan  ( 2016-06-28 22:23:21 -0500 )edit

It should be a matter of determining which node is running your controller_manager and then loading that node in gdb using the launch-prefix approach you already found.

gvdhoorn gravatar image gvdhoorn  ( 2016-06-29 03:04:19 -0500 )edit

Great! I think I got your idea, I would try it later.

cangjiaxuan gravatar image cangjiaxuan  ( 2016-06-29 04:18:12 -0500 )edit

Hi, I tied several ways and finally I can use gdb to debug my plugin. I write my experience below.

cangjiaxuan gravatar image cangjiaxuan  ( 2016-07-09 21:53:05 -0500 )edit
0

answered 2016-07-09 21:51:10 -0500

cangjiaxuan gravatar image

I find two ways to solve this problem.

The first one is simple, just add debug:=true at the end of the command line when start gazebo. After loading the controller, if there is something wrong happened the program would stop and you could use gdb to debug the program.

For example:

roslaunch rrbot_gazebo rrbot_world.launch debug:=true

(rrbot_gazebo is an example package in the gazebo tutorial)

The second way is a little tricky, the main idea is to use gdb -p "pid". So one should first use ps -auxw | grep gzserver to locate the pid of gazebo. Then use gdb -p "pid" to start gdb. But the gdb would start with some sleep function. So we should use command finish to finish the sleep process until we get into run() function. Then we can set breakpoints and debug the program.

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-06-27 21:51:17 -0500

Seen: 467 times

Last updated: Jul 09 '16