point_cloud.cpp
Go to the documentation of this file.
00001 
00002 #include "mrpt_bridge/point_cloud.h"
00003 #include <ros/console.h>
00004 
00005 namespace mrpt_bridge {
00006 
00011 bool point_cloud::ros2mrpt(
00012                 const sensor_msgs::PointCloud &msg,
00013                 mrpt::slam::CSimplePointsMap  &obj )
00014 {
00015         const size_t N = msg.points.size();
00016 
00017         obj.clear();
00018         obj.reserve(N);
00019         for (size_t i=0;i<N;i++)
00020                 obj.insertPoint(msg.points[i].x,msg.points[i].y,msg.points[i].z);
00021 
00022         return true;
00023 }
00024 
00025 
00032 bool point_cloud::mrpt2ros(
00033         const mrpt::slam::CSimplePointsMap  &obj,
00034         const std_msgs::Header &msg_header,
00035         sensor_msgs::PointCloud &msg )
00036 {
00037         // 1) sensor_msgs::PointCloud:: header
00038         msg.header = msg_header;
00039 
00040         // 2) sensor_msgs::PointCloud:: points
00041         const size_t N = obj.size();
00042         msg.points.resize( N );
00043         for (size_t i=0;i<N;i++)
00044         {
00045                 geometry_msgs::Point32 & pt = msg.points[i];
00046                 obj.getPoint(i,pt.x,pt.y,pt.z);
00047         }
00048 
00049         // 3) sensor_msgs::PointCloud:: channels
00050         msg.channels.clear();
00051 
00052         return true;
00053 }
00054 
00055 } //namespace mrpt_bridge


mrpt_bridge
Author(s):
autogenerated on Mon Aug 11 2014 11:23:21