admin管理员组

文章数量:1650774

1.简单分析

失败后显示输出了log日志,此时可以打开log日志查看内容,然而这个日志基本没什么用。因为这个日志都是程序在刚加载的时候输出的,内容很少。而且既然ros可执行文件都已经编译成功了,这个时候运行出现错误,很大概率是链接库有问题,或者加载参数文件的时候有问题。

2.添加GDB调试

参考:ros项目调试:ROS项目使用GDB调试

2.1.在rosrun命令中添加

可以使用gdb进行调试,使用以下命令调试:

rosrun --prefix 'gdb -ex run --args' feature_tracker feature_tracker 

2.2.在roslaunch中添加

修改ROS launch文件,在node标签中添加一句话

launch-prefix="xterm -e gdb -ex run --args "

如果使用的是Python来写ROS,则需要修改调试器为pdb,如下:

launch-prefix="xterm -e python -m pdb "

这样在执行原来例子的时候,就会先打开一个新的Shell界面,被调试的程序就在这个Shell中被执行了。

注意:如果加入xterm相关语句报错,比如报错如下:

RLException: Roslaunch got a 'No such file or directory' error while attempting to run:

xterm -e gdb -ex run --args

则是因为没有安装xterm,终端输入sudo apt-get install xterm安装即可。

附:roslaunch node前缀

The launch-prefix attribute of the tag that, among other things, makes it easy to debug a ROS node process. Here are some example launch-prefixes you might find useful:

launch-prefix=“xterm -e gdb --args” : run your node in a gdb in a separate xterm window, manually type run to start it

launch-prefix=“gdb -ex run --args” : run your node in gdb in the same xterm as your launch without having to type run to start it

launch-prefix=“stterm -g 200x60 -e gdb -ex run --args” : run your node in gdb in a new stterm window without having to type run to start it

launch-prefix=“valgrind” : run your node in valgrind

这个valgrind工具可以用于检测内存泄露,并执行性能分析

launch-prefix=“xterm -e” : run your node in a separate xterm window

launch-prefix=“nice” : nice your process to lower its CPU usage

launch-prefix=“screen -d -m gdb --args” : useful if the node is being run on another machine; you can then ssh to that machine and do screen -D -R to see the gdb session

launch-prefix=“xterm -e python -m pdb” : run your python node a separate xterm window in pdb for debugging; manually type run to start it

本文标签: 节点rosgdbdiedProcess