30 #include <pcl/common/transforms.h> 41 cv::Mat output = laserScan.
data().clone();
45 Eigen::Affine3f transform3f = transform.
toEigen3f();
49 for(
int i=0; i<laserScan.
size(); ++i)
51 const float * ptr = laserScan.
data().ptr<
float>(0, i);
52 float * out = output.ptr<
float>(0, i);
55 pcl::PointXYZ pt(ptr[0], ptr[1], laserScan.
is2d()?0:ptr[2]);
69 pt.z=laserScan.
is2d()?0:ptr[2];
80 out[nx] = pt.normal_x;
81 out[ny] = pt.normal_y;
82 out[nz] = pt.normal_z;
108 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
111 pcl::PointCloud<pcl::PointXYZ>::Ptr output(
new pcl::PointCloud<pcl::PointXYZ>);
116 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
119 pcl::PointCloud<pcl::PointXYZI>::Ptr output(
new pcl::PointCloud<pcl::PointXYZI>);
124 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
127 pcl::PointCloud<pcl::PointXYZRGB>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGB>);
132 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
135 pcl::PointCloud<pcl::PointNormal>::Ptr output(
new pcl::PointCloud<pcl::PointNormal>);
136 pcl::transformPointCloudWithNormals(*cloud, *output, transform.
toEigen4f());
140 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
143 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
144 pcl::transformPointCloudWithNormals(*cloud, *output, transform.
toEigen4f());
148 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
151 pcl::PointCloud<pcl::PointXYZINormal>::Ptr output(
new pcl::PointCloud<pcl::PointXYZINormal>);
152 pcl::transformPointCloudWithNormals(*cloud, *output, transform.
toEigen4f());
157 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
158 const pcl::IndicesPtr & indices,
161 pcl::PointCloud<pcl::PointXYZ>::Ptr output(
new pcl::PointCloud<pcl::PointXYZ>);
166 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
167 const pcl::IndicesPtr & indices,
170 pcl::PointCloud<pcl::PointXYZI>::Ptr output(
new pcl::PointCloud<pcl::PointXYZI>);
175 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
176 const pcl::IndicesPtr & indices,
179 pcl::PointCloud<pcl::PointXYZRGB>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGB>);
184 const pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
185 const pcl::IndicesPtr & indices,
188 pcl::PointCloud<pcl::PointNormal>::Ptr output(
new pcl::PointCloud<pcl::PointNormal>);
189 pcl::transformPointCloudWithNormals(*cloud, *indices, *output, transform.
toEigen4f());
193 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
194 const pcl::IndicesPtr & indices,
197 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr output(
new pcl::PointCloud<pcl::PointXYZRGBNormal>);
198 pcl::transformPointCloudWithNormals(*cloud, *indices, *output, transform.
toEigen4f());
202 const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
203 const pcl::IndicesPtr & indices,
206 pcl::PointCloud<pcl::PointXYZINormal>::Ptr output(
new pcl::PointCloud<pcl::PointXYZINormal>);
207 pcl::transformPointCloudWithNormals(*cloud, *indices, *output, transform.
toEigen4f());
212 const cv::Point3f & point,
215 cv::Point3f ret = point;
216 ret.x = transform (0, 0) * point.
x + transform (0, 1) * point.
y + transform (0, 2) * point.
z + transform (0, 3);
217 ret.y = transform (1, 0) * point.
x + transform (1, 1) * point.
y + transform (1, 2) * point.
z + transform (1, 3);
218 ret.z = transform (2, 0) * point.
x + transform (2, 1) * point.
y + transform (2, 2) * point.
z + transform (2, 3);
222 const pcl::PointXYZ & pt,
228 const pcl::PointXYZI & pt,
234 const pcl::PointXYZRGB & pt,
242 const pcl::PointNormal & point,
245 pcl::PointNormal ret;
246 Eigen::Matrix<float, 3, 1> pt (point.x, point.y, point.z);
247 ret.x =
static_cast<float> (transform (0, 0) * pt.coeffRef (0) + transform (0, 1) * pt.coeffRef (1) + transform (0, 2) * pt.coeffRef (2) + transform (0, 3));
248 ret.y =
static_cast<float> (transform (1, 0) * pt.coeffRef (0) + transform (1, 1) * pt.coeffRef (1) + transform (1, 2) * pt.coeffRef (2) + transform (1, 3));
249 ret.z =
static_cast<float> (transform (2, 0) * pt.coeffRef (0) + transform (2, 1) * pt.coeffRef (1) + transform (2, 2) * pt.coeffRef (2) + transform (2, 3));
252 Eigen::Matrix<float, 3, 1> nt (point.normal_x, point.normal_y, point.normal_z);
253 ret.normal_x =
static_cast<float> (transform (0, 0) * nt.coeffRef (0) + transform (0, 1) * nt.coeffRef (1) + transform (0, 2) * nt.coeffRef (2));
254 ret.normal_y =
static_cast<float> (transform (1, 0) * nt.coeffRef (0) + transform (1, 1) * nt.coeffRef (1) + transform (1, 2) * nt.coeffRef (2));
255 ret.normal_z =
static_cast<float> (transform (2, 0) * nt.coeffRef (0) + transform (2, 1) * nt.coeffRef (1) + transform (2, 2) * nt.coeffRef (2));
259 const pcl::PointXYZRGBNormal & point,
262 pcl::PointXYZRGBNormal ret;
263 Eigen::Matrix<float, 3, 1> pt (point.x, point.y, point.z);
264 ret.x =
static_cast<float> (transform (0, 0) * pt.coeffRef (0) + transform (0, 1) * pt.coeffRef (1) + transform (0, 2) * pt.coeffRef (2) + transform (0, 3));
265 ret.y =
static_cast<float> (transform (1, 0) * pt.coeffRef (0) + transform (1, 1) * pt.coeffRef (1) + transform (1, 2) * pt.coeffRef (2) + transform (1, 3));
266 ret.z =
static_cast<float> (transform (2, 0) * pt.coeffRef (0) + transform (2, 1) * pt.coeffRef (1) + transform (2, 2) * pt.coeffRef (2) + transform (2, 3));
269 Eigen::Matrix<float, 3, 1> nt (point.normal_x, point.normal_y, point.normal_z);
270 ret.normal_x =
static_cast<float> (transform (0, 0) * nt.coeffRef (0) + transform (0, 1) * nt.coeffRef (1) + transform (0, 2) * nt.coeffRef (2));
271 ret.normal_y =
static_cast<float> (transform (1, 0) * nt.coeffRef (0) + transform (1, 1) * nt.coeffRef (1) + transform (1, 2) * nt.coeffRef (2));
272 ret.normal_z =
static_cast<float> (transform (2, 0) * nt.coeffRef (0) + transform (2, 1) * nt.coeffRef (1) + transform (2, 2) * nt.coeffRef (2));
278 const pcl::PointXYZINormal & point,
281 pcl::PointXYZINormal ret;
282 Eigen::Matrix<float, 3, 1> pt (point.x, point.y, point.z);
283 ret.x =
static_cast<float> (transform (0, 0) * pt.coeffRef (0) + transform (0, 1) * pt.coeffRef (1) + transform (0, 2) * pt.coeffRef (2) + transform (0, 3));
284 ret.y =
static_cast<float> (transform (1, 0) * pt.coeffRef (0) + transform (1, 1) * pt.coeffRef (1) + transform (1, 2) * pt.coeffRef (2) + transform (1, 3));
285 ret.z =
static_cast<float> (transform (2, 0) * pt.coeffRef (0) + transform (2, 1) * pt.coeffRef (1) + transform (2, 2) * pt.coeffRef (2) + transform (2, 3));
288 Eigen::Matrix<float, 3, 1> nt (point.normal_x, point.normal_y, point.normal_z);
289 ret.normal_x =
static_cast<float> (transform (0, 0) * nt.coeffRef (0) + transform (0, 1) * nt.coeffRef (1) + transform (0, 2) * nt.coeffRef (2));
290 ret.normal_y =
static_cast<float> (transform (1, 0) * nt.coeffRef (0) + transform (1, 1) * nt.coeffRef (1) + transform (1, 2) * nt.coeffRef (2));
291 ret.normal_z =
static_cast<float> (transform (2, 0) * nt.coeffRef (0) + transform (2, 1) * nt.coeffRef (1) + transform (2, 2) * nt.coeffRef (2));
293 ret.intensity = point.intensity;
cv::Point3f RTABMAP_EXP transformPoint(const cv::Point3f &pt, const Transform &transform)
const cv::Mat & data() const
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP transformPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const Transform &transform)
int getNormalsOffset() const
LaserScan RTABMAP_EXP transformLaserScan(const LaserScan &laserScan, const Transform &transform)
Transform localTransform() const
float angleIncrement() const
ULogger class and convenient macros.