ros nodelet 使用
ros nodelet能够加快高吞吐量程序运行速度比如点云
基本入门程序可以看
http://wiki.ros.org/nodelet/Tutorials/Porting%20nodes%20to%20nodelets
http://wiki.ros.org/nodelet
什么是nodelet,nodelet有什么用处
https://answers.ros.org/question/230972/what-is-a-nodelet/


代码框架:
class pcl_process_class
{
class MyPointCloudGeneratorNodelet : public nodelet::Nodelet
{
// Subscriptions
boost::shared_ptr<image_transport::ImageTransport> it_;
image_transport::CameraSubscriber sub_depth_;
int queue_size_; // Publications
boost::mutex connect_mutex_;
typedef sensor_msgs::PointCloud2 PointCloud;
ros::Publisher pub_point_cloud_; image_geometry::PinholeCameraModel model_; virtual void onInit(); void connectCb(); void depthCb(const sensor_msgs::ImageConstPtr& depth_msg,
const sensor_msgs::CameraInfoConstPtr& info_msg);
}; void MyPointCloudGeneratorNodelet::onInit()
{
ros::NodeHandle& nh = getNodeHandle();
it_.reset(new image_transport::ImageTransport(nh));
queue_size_ = ;
// Read parameters // Monitor whether anyone is subscribed to the output
ros::SubscriberStatusCallback connect_cb = boost::bind(&MyPointCloudGeneratorNodelet::connectCb, this);
// Make sure we don't enter connectCb() between advertising and assigning to pub_point_cloud_
boost::lock_guard<boost::mutex> lock(connect_mutex_);
pub_point_cloud_ = nh.advertise<PointCloud>("points", , connect_cb, connect_cb);
ROS_INFO("onInit"); } // Handles (un)subscribing when clients (un)subscribe
void MyPointCloudGeneratorNodelet::connectCb()
{
boost::lock_guard<boost::mutex> lock(connect_mutex_);
if (pub_point_cloud_.getNumSubscribers() == )
{
sub_depth_.shutdown();
}
else if (!sub_depth_)
{
image_transport::TransportHints hints("raw", ros::TransportHints(), getPrivateNodeHandle());
sub_depth_ = it_->subscribeCamera("image_rect", queue_size_, &MyPointCloudGeneratorNodelet::depthCb, this, hints);
}
ROS_INFO("connectCb"); } void MyPointCloudGeneratorNodelet::depthCb(const sensor_msgs::ImageConstPtr& depth_msg,
const sensor_msgs::CameraInfoConstPtr& info_msg)
{ pcl_process_class mpcl_process_class;
mpcl_process_class.pcl_process(depth_msg);
PointCloud pointCloud;
pcl::toROSMsg(*mpcl_p ointCloud);
} } // namespace depth_image_proc // Register as nodelet
#include <pluginlib/class_list_macros.h>
PLUGINLIB_EXPORT_CLASS(vision_obstacles_avoidance::MyPointCloudGeneratorNodelet,nodelet::Nodelet);
nodelet.launch
<launch>
<node pkg="nodelet" type="nodelet" name="standalone_nodelet" args="manager" output="screen"/> <node pkg="nodelet" type="nodelet" name="MyPointCloudGeneratorNodelet" args="load vision_obstacles_avoidance/MyPointCloudGeneratorNodelet standalone_nodelet" output="screen">
<remap from="image_rect" to="/camera/depth_registered/hw_registered/image_rect_raw"/>
<remap from="points" to="/point_cloud"/>
<remap from="/camera/depth_registered/hw_registered/camera_info" to="/camera/depth_registered/camera_info"/>
</node>
</launch>
nodelet比较好用尤其是在使用pointcloud时候,由于ros node之间采用tcpros标准来传输数据,点云要经过压缩解压缩过程所以很慢,但是nodelet是直接使用原来数据,类似指针,但是只能在同一个机器下才有用。
class MyPointCloudGeneratorNodelet : public nodelet::Nodelet{ // Subscriptions boost::shared_ptr<image_transport::ImageTransport> it_; image_transport::CameraSubscriber sub_depth_; int queue_size_;
// Publications boost::mutex connect_mutex_; typedef sensor_msgs::PointCloud2 PointCloud; ros::Publisher pub_point_cloud_;
image_geometry::PinholeCameraModel model_;
virtual void onInit();
void connectCb();
void depthCb(const sensor_msgs::ImageConstPtr& depth_msg, const sensor_msgs::CameraInfoConstPtr& info_msg);};
void MyPointCloudGeneratorNodelet::onInit(){ ros::NodeHandle& nh = getNodeHandle(); it_.reset(new image_transport::ImageTransport(nh)); queue_size_ = 5; // Read parameters
// Monitor whether anyone is subscribed to the output ros::SubscriberStatusCallback connect_cb = boost::bind(&MyPointCloudGeneratorNodelet::connectCb, this); // Make sure we don't enter connectCb() between advertising and assigning to pub_point_cloud_ boost::lock_guard<boost::mutex> lock(connect_mutex_); pub_point_cloud_ = nh.advertise<PointCloud>("points", 1, connect_cb, connect_cb); ROS_INFO("onInit");
}
// Handles (un)subscribing when clients (un)subscribevoid MyPointCloudGeneratorNodelet::connectCb(){ boost::lock_guard<boost::mutex> lock(connect_mutex_); if (pub_point_cloud_.getNumSubscribers() == 0) { sub_depth_.shutdown(); } else if (!sub_depth_) { image_transport::TransportHints hints("raw", ros::TransportHints(), getPrivateNodeHandle()); sub_depth_ = it_->subscribeCamera("image_rect", queue_size_, &MyPointCloudGeneratorNodelet::depthCb, this, hints); } ROS_INFO("connectCb");
}
void MyPointCloudGeneratorNodelet::depthCb(const sensor_msgs::ImageConstPtr& depth_msg, const sensor_msgs::CameraInfoConstPtr& info_msg){
pcl_process_class mpcl_process_class; mpcl_process_class.pcl_process(depth_msg); PointCloud pointCloud; pcl::toROSMsg(*mpcl_p ointCloud);}
} // namespace depth_image_proc
// Register as nodelet#include <pluginlib/class_list_macros.h>PLUGINLIB_EXPORT_CLASS(vision_obstacles_avoidance::MyPointCloudGeneratorNodelet,nodelet::Nodelet);
ros nodelet 使用的更多相关文章
- ROS nodelet的使用
ROS是一种基于分布式网络通讯的操作系统,整个机器人控制系统是由一个Master主节点和若干个功能相对独立的Node子节点组成,这也是ROS系统最主要的特点就是分布式以及模块化的设计.在ROS通讯过程 ...
- ROS nodelet 理解记录
发现网上许多的例子都是基于官网的例子,还需要做进一步的说明. 1. NODELET_DEBUG 是无法打印的信息的,需要使用NODELET_INFO NODELET_DEBUG("Addin ...
- 使用yocs_cmd_vel_mux进行机器人速度控制切换
cmd_vel_mux包从名字就可以推测出它的用途,即进行速度的选择(In electronics, a multiplexer or mux is a device that selects one ...
- ubuntu14.04 and ros indigo install kinect driver--16
摘要: 原创博客:转载请表明出处:http://www.cnblogs.com/zxouxuewei/ 今日多次测设ros indigo install kinect driver ,提示各种失败,然 ...
- ROS Node/Topic/Message/Service的一些问题
1.Node http://blog.exbot.net/archives/1412 (摘自老王说ros) node干的什么活?callback queue里的活.这个callback queue里的 ...
- ZED 相机 && ORB-SLAM2安装环境配置与ROS下的调试
注:1. 对某些地方进行了更新(红色标注),以方便进行配置. 2. ZED ROS Wrapper官方github已经更新,根据描述新的Wrapper可能已经不适用与Ros Indigo了,如果大家想 ...
- (一)ROS系统入门 Getting Started with ROS 以Kinetic为主更新 附课件PPT
ROS机器人程序设计(原书第2版)补充资料 教案1 ROS Kinetic系统入门 ROS Kinetic在Ubuntu 16.04.01 安装可参考:http://blog.csdn.net/zha ...
- 奥比中光Orbbec Astra Pro RGBD 3D视觉传感器在ROS(indigo和kinetic)使用说明 rgb depth同时显示
Orbbec Astra Pro传感器在ROS(indigo和kinetic)使用说明 rgb depth同时显示 这款摄像头使用uvc输入彩色信息,需要libuvc和libuvc_ros这样才能在R ...
- ROS机器人程序设计(原书第2版)补充资料 (贰) 第二章 ROS系统架构及概念
ROS机器人程序设计(原书第2版)补充资料 (贰) 第二章 ROS系统架构及概念 书中,大部分出现hydro的地方,直接替换为indigo或jade或kinetic,即可在对应版本中使用. 由于工作事 ...
随机推荐
- pxp
Time Limit: 2000 ms Memory Limit: 512 MB Description 给定 \(n\), 求\(\sum\limits_{p,q∈primes}[pq≤n]\) ( ...
- Python2和Python3共存安装
记录下: 先下载Python2.7.6,安装完成,不要添加到path中: 再下载Python3.4.3,安装,不要添加到path中. 进入 Python2: py -2 进入Python3: py - ...
- python学习(十一)测试和调试
最近学习了python的错误处理和几种测试方法 1 try except 可以通过try except方式捕捉异常 try: print('try...') r = 10/0 print('resul ...
- win7 64位环境下配置汇编环境和程序设计
下载dosbox,并解压安装 下载地址: http://pan.baidu.com/s/1eRJbJAq 默认安装到C:\Program Files (x86)\DOSBox-0.74 安装成功后,双 ...
- 手脱PE Pack v1.0
1.PEID查壳 PE Pack v1.0 2.载入OD,一上来就这架势,先F8走着 > / je ; //入口点 -\E9 C49D0000 jmp Pepack_1.0040D000 004 ...
- windows如何要查看IIS连接数
1.运行,输入,perfmon.msc 2.在系统监视器,区域点击,添加计数器. 3.在“添加计数器”窗口,“性能对象”选择Web Service,“从列表选择计数器”选中Current Connec ...
- vue 拦截器
拦截器:请求发送之前和请求返回之后的处理 使用:1.config---dev.env.js 开发环境配置 2. prod.env.js 生产 API:'http://www.wpdic.com' 3. ...
- 前端PHP入门-005-爱情是常量还是变量
常量 常--汉语字面为:长久,经久不变. 常量那就好翻译了:长久不变的值. 常量的使用范围非常广泛. 我们在以后,定义我们的工作目录.定义一些特点的帐户密码.版本号等我们都会使用到常量.所以这一块的知 ...
- tomcat启动 报org.apache.catalina.LifecycleException异常
java 服务器 tomcat启动 报org.apache.catalina.LifecycleException异常 异常代码如下: [2018-05-10 04:45:08,856] Artifa ...
- 【Atcoer】ARC088 E - Papple Sort
[题目]E - Papple Sort [题意]给定长度为n的小写字母串,只能交换相邻字母,求形成回文串的最小步数.n<=2*10^5. [算法]数学 [题解]官方题解 本题题解中有以下重要的思 ...