cartographer线程创建数量

记录cartographer运行过程中创建了多少个线程。
首先是 main函数里面的运行结果(cartographer_ros::Run();之前)

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe7b9f700 (LWP 35875)]
[New Thread 0x7fffe739e700 (LWP 35876)]
[New Thread 0x7fffe2b9d700 (LWP 35877)]
[New Thread 0x7fffe039c700 (LWP 35878)]
[New Thread 0x7fffddb9b700 (LWP 35879)]
[New Thread 0x7fffdb39a700 (LWP 35880)]
[New Thread 0x7fffd8b99700 (LWP 35881)]
::ros::init
::ros::start
[New Thread 0x7fffd5ac1700 (LWP 35883)]
[New Thread 0x7fffd52c0700 (LWP 35884)]
[New Thread 0x7fffd4abf700 (LWP 35885)]
[New Thread 0x7fffcffff700 (LWP 35886)]
cartographer_ros::ScopedRosLogSink ros_log_sink;

这个表明下面代码块创建了从35875到35881的线程

  google::InitGoogleLogging(argv[0]);
  google::ParseCommandLineFlags(&argc, &argv, true);

这个表明下面代码块创建了从35883到35886的线程

  ::ros::start();

然后后端回环检测线程池创建num_background_threads数量的线程

继续往下

对于cartographer_ros::Run();函数其会在tf2_ros::TransformListener tf(tf_buffer);这个函数中创建一个发布监听tf树的线程

继续往下

[New Thread 0x7fffce7fc700 (LWP 35889)]
[ INFO] [1691996207.857706512]: I0814 14:56:47.000000 35870 node.cc:224] node all WallTimer PublishSubmapList
[New Thread 0x7fffcdffb700 (LWP 35890)]
[ INFO] [1691996207.857899289]: I0814 14:56:47.000000 35870 node.cc:230] node all WallTimer PublishLocalTrajectoryData
[ INFO] [1691996207.857931726]: I0814 14:56:47.000000 35870 node.cc:234] node all WallTimer PublishTrajectoryNodeList
[ INFO] [1691996207.857948724]: I0814 14:56:47.000000 35870 node.cc:238] node all WallTimer PublishLandmarkPosesList
[ INFO] [1691996207.857964145]: I0814 14:56:47.000000 35870 node.cc:242] node all WallTimer PublishConstraintList
[ INFO] [1691996207.857979489]: I0814 14:56:47.000000 35870 node.cc:247] node all WallTimer LogLocalization
[ INFO] [1691996207.857996249]: I0814 14:56:47.000000 35870 node.cc:254] node all WallTimer PublishLocalizationQuality
[ INFO] [1691996207.858010825]: I0814 14:56:47.000000 35870 node.cc:259] node all WallTimer PublishPointCloudMap

其中wall_timers_会创建[New Thread 0x7fffce7fc700 (LWP 35889)]线程
publish_local_trajectory_data_timer_会创建[New Thread 0x7fffcdffb700 (LWP 35890)]线程

注意ceres_solver_options中的num_threads,ceres_solver_options会有两个地方使用,一个是前端基于ceres的匹配,另一个是后端优化。

对于前端ceres_solver_options中的num_threads,如果设置为1,那么其不会创建新的线程,会跟主线程一起。

对于后端优化ceres_solver_options中的num_threads,如果设置为7,那么其会额外开启7-1=6个线程

总结,只考虑正常算法运行,即不考虑::ros::start()一堆的线程,其会开启1(tf2_ros::TransformListener) + num_background_threads(回环检测) + 1(wall_timers_) + 1(publish_local_trajectory_data_timer_) + 前端num_threads-1 + 后端num_threads-1 + 1(主线程)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

庞闲森

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值