ros 加-g编译或debug编译

编译方式

1.命令行catkin_make(亲测可以)

在输入catkin_make时加上一个参数:

catkin_make -DCMAKE_BUILD_TYPE=Debug

2.直接修改CMakelist.txt

添加以下代码

SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")

GDB执行

1.rosrun执行(亲测可以)

[package_name]:节点路径目录名
[node_name]:节点名

rosrun --prefix 'gdb -ex run --args' [package_name] [node_name] 

2.修改ROS launch文件

在node标签中添加一句话

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

修改后的launch文件如下所示

<node pkg="waypoint_follower" type="pure_persuit" name="pure_pursuit" output="screen" launch-prefix="xterm -e gdb -ex run --args">
        <param name="is_linear_interpolation" value="$(arg is_linear_interpolation)"/>
</node>

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

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

launch-prefix="xterm -e python -m pdb "
test@test-VMware20-1:~$ apt search gz-sim Sorting... Done Full Text Search... Done libgz-sim6/jammy 6.16.0-2~jammy all transitional package libgz-sim6-dbg/jammy 6.16.0-2~jammy all transitional package libgz-sim6-dev/jammy 6.16.0-2~jammy all transitional package libgz-sim6-plugins/jammy 6.16.0-2~jammy all transitional package python3-gz-sim6/jammy 6.16.0-2~jammy all transitional package ros-humble-ros-gz-sim/jammy 0.244.16-2jammy.20241205.203411 amd64 Tools for using Gazebo Sim simulation with ROS. ros-humble-ros-gz-sim-dbgsym/jammy 0.244.16-2jammy.20241205.203411 amd64 debug symbols for ros-humble-ros-gz-sim ros-humble-ros-gz-sim-demos/jammy 0.244.16-2jammy.20250211.200053 amd64 Demos using Gazebo Sim simulation with ROS. ros-iron-ros-gz-sim/jammy 0.254.2-1jammy.20241114.224242 amd64 Tools for using Gazebo Sim simulation with ROS. ros-iron-ros-gz-sim-dbgsym/jammy 0.254.2-1jammy.20241114.224242 amd64 debug symbols for ros-iron-ros-gz-sim ros-iron-ros-gz-sim-demos/jammy 0.254.2-1jammy.20241126.215247 amd64 Demos using Gazebo Sim simulation with ROS. ros-jazzy-gz-sim-vendor/noble 0.0.8-1noble.20250220.105624 amd64 Vendor package for: gz-sim8 8.9.0 Gazebo Sim : A Robotic Simulator ros-jazzy-gz-sim-vendor-dbgsym/noble 0.0.8-1noble.20250220.105624 amd64 debug symbols for ros-jazzy-gz-sim-vendor ros-jazzy-irobot-create-gz-sim/noble 3.0.4-1noble.20250305.001338 amd64 Metapackage for the iRobot(R) Create(R) 3 robot Ignition simulator ros-jazzy-ros-gz-sim/noble 1.0.9-1noble.20250220.114428 amd64 Tools for using Gazebo Sim simulation with ROS. ros-jazzy-ros-gz-sim-dbgsym/noble 1.0.9-1noble.20250220.114428 amd64 debug symbols for ros-jazzy-ros-gz-sim ros-jazzy-ros-gz-sim-demos/noble 1.0.9-1noble.20250220.115000 amd64 Demos using Gazebo Sim simulation with ROS. ros-rolling-gz-sim-vendor/noble 0.2.1-1noble.20250227.011014 amd64 Vendor package for: gz-sim9 9.1.0 Gazebo Sim : A Robotic Simulator ros-rolling-gz-sim-vendor-dbgsym/
03-14
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值