点云技术相关产学研社区

 找回密码
 立即注册加入PCL中国点云技术相关产学研社区

扫一扫,访问微社区

查看: 4954|回复: 1

在ros上如何实时保存点云数据

[复制链接]
发表于 2017-10-1 23:03:29 | 显示全部楼层 |阅读模式
前几天学生写了一个ros的node,保存处理后的点云数据测试后帧率不到10.
我就让他先考虑是否可以用多线程来将处理和保存工作与node中的subscriber的callback分离出来。
自己今天搜了下,有一下几个链接感觉比较有用。
http://www.pcl-users.org/Recordi ... quot-td3823331.html
建议用
PCDWriter w;
w.writeBinaryCompressed ("filename", cloud);
因为现在学生应该用的是未压缩的那个接口。
另外一个考虑写一个nodelet,而非现在的node,这个可以避免多线程之间的互锁之类。
http://tayyabnaseer.blogspot.com ... odelets-in-ros.html
改天再看看,最终还是要看实现。
回复

使用道具 举报

 楼主| 发表于 2017-10-16 18:30:45 | 显示全部楼层
本帖最后由 mypcl 于 2017-10-16 18:32 编辑

最终还是用了线程池的方案。参考下面代码
A thread pool for executing arbitrary tasks
Create an io_service:
  asio::io_service io_service;
and some work to stop its run() function from exiting if it has nothing else to do:
  asio::io_service::work work(io_service);
Start some worker threads:
  boost::thread_group threads;
  for (std::size_t i = 0; i < my_thread_count; ++i)
    threads.create_thread(boost::bind(&asio::io_service::run, &io_service));
Post the tasks to the io_service so they can be performed by the worker threads:
  io_service.post(boost::bind(an_expensive_calculation, 42));
  io_service.post(boost::bind(a_long_running_task, 123));
Finally, before the program exits shut down the io_service and wait for all threads to exit:
  io_service.stop();
  threads.join_all();
参考:
http://think-async.com/Asio/Reci ... _for_executing_arbi
https://segmentfault.com/a/1190000006691692

回复 支持 反对

使用道具 举报

本版积分规则

QQ|小黑屋|点云技术相关产学研社区 ( 陕ICP备13001629号 )

GMT+8, 2024-4-20 12:56 , Processed in 1.640506 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表