GDB 调试ROS节点的配置与使用

gdb调试ROS节点有两种方法,分别是调试coredump文件,一种是在线调试。

调试coredump文件

首先,要确认允许coredump文件,方法是在shell终端中执行命令

ulimit -c N

其中N为任意大于0的整数,表示允许生成的coredump文件大小的上限,通常N设置为unlimited,即不做大小限制,确保生成任意大小的coredump文件。

其次,运行导致coredump的程序。

最后,执行命令

gdb problem_program coredump_file

进入coredump分析环境,务必记住coredump文件必须和程序是匹配的,即coredump文件必须是运行problem_program崩溃时生成的。想要查看backtrace, 可以在gdb环境中输入where命令。

在线调试

首先,配置gdb调用。在launch文件中,找到该ROS节点的启动选项中添加launch-prefix="xterm -e gdb --args" 如

<launch>
<node pkg="my_pkg" type="my_pkg_node" name="my_pkg_name" launch-prefix="xterm -e gdb --args"/>
</node>
</launch>

然后,通过roslaunch 启动节点。如果不出意外,ROS节点启动失败,并会得到一个错误输出如下,

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

xterm -e gdb --args /home/.../ros_ws/devel/lib/my_pkg/my_pkg_node __name:=my_pkg_node __log:=/home/ubuntu/.ros/log/1b9a3f72-9eb6-11ec-a17d-bdfa0cb3ef94/my_pkg_node-3.log

Please make sure that all the executables in this command exist and have
executable permission. This is often caused by a bad launch-prefix.
The traceback for the exception was written to the log file

出现这种情况,一般可以通过安装xterm解决,方法为执行如下命令:

sudo apt-get install xterm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值