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 cv::Point3d & point,
225 cv::Point3d ret = point;
226 ret.x = transform (0, 0) * point.
x + transform (0, 1) * point.
y + transform (0, 2) * point.
z + transform (0, 3);
227 ret.y = transform (1, 0) * point.
x + transform (1, 1) * point.
y + transform (1, 2) * point.
z + transform (1, 3);
228 ret.z = transform (2, 0) * point.
x + transform (2, 1) * point.
y + transform (2, 2) * point.
z + transform (2, 3);
232 const pcl::PointXYZ & pt,
238 const pcl::PointXYZI & pt,
244 const pcl::PointXYZRGB & pt,
252 const pcl::PointNormal & point,
255 pcl::PointNormal ret;
256 Eigen::Matrix<float, 3, 1> pt (point.x, point.y, point.z);
257 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));
258 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));
259 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));
262 Eigen::Matrix<float, 3, 1> nt (point.normal_x, point.normal_y, point.normal_z);
263 ret.normal_x =
static_cast<float> (transform (0, 0) * nt.coeffRef (0) + transform (0, 1) * nt.coeffRef (1) + transform (0, 2) * nt.coeffRef (2));
264 ret.normal_y =
static_cast<float> (transform (1, 0) * nt.coeffRef (0) + transform (1, 1) * nt.coeffRef (1) + transform (1, 2) * nt.coeffRef (2));
265 ret.normal_z =
static_cast<float> (transform (2, 0) * nt.coeffRef (0) + transform (2, 1) * nt.coeffRef (1) + transform (2, 2) * nt.coeffRef (2));
269 const pcl::PointXYZRGBNormal & point,
272 pcl::PointXYZRGBNormal ret;
273 Eigen::Matrix<float, 3, 1> pt (point.x, point.y, point.z);
274 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));
275 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));
276 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));
279 Eigen::Matrix<float, 3, 1> nt (point.normal_x, point.normal_y, point.normal_z);
280 ret.normal_x =
static_cast<float> (transform (0, 0) * nt.coeffRef (0) + transform (0, 1) * nt.coeffRef (1) + transform (0, 2) * nt.coeffRef (2));
281 ret.normal_y =
static_cast<float> (transform (1, 0) * nt.coeffRef (0) + transform (1, 1) * nt.coeffRef (1) + transform (1, 2) * nt.coeffRef (2));
282 ret.normal_z =
static_cast<float> (transform (2, 0) * nt.coeffRef (0) + transform (2, 1) * nt.coeffRef (1) + transform (2, 2) * nt.coeffRef (2));
288 const pcl::PointXYZINormal & point,
291 pcl::PointXYZINormal ret;
292 Eigen::Matrix<float, 3, 1> pt (point.x, point.y, point.z);
293 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));
294 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));
295 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));
298 Eigen::Matrix<float, 3, 1> nt (point.normal_x, point.normal_y, point.normal_z);
299 ret.normal_x =
static_cast<float> (transform (0, 0) * nt.coeffRef (0) + transform (0, 1) * nt.coeffRef (1) + transform (0, 2) * nt.coeffRef (2));
300 ret.normal_y =
static_cast<float> (transform (1, 0) * nt.coeffRef (0) + transform (1, 1) * nt.coeffRef (1) + transform (1, 2) * nt.coeffRef (2));
301 ret.normal_z =
static_cast<float> (transform (2, 0) * nt.coeffRef (0) + transform (2, 1) * nt.coeffRef (1) + transform (2, 2) * nt.coeffRef (2));
303 ret.intensity = point.intensity;
cv::Point3f RTABMAP_EXP transformPoint(const cv::Point3f &pt, const Transform &transform)
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_EXP transformPointCloud(const pcl::PointCloud< pcl::PointXYZ >::Ptr &cloud, const Transform &transform)
const cv::Mat & data() const
int getNormalsOffset() const
LaserScan RTABMAP_EXP transformLaserScan(const LaserScan &laserScan, const Transform &transform)
ULogger class and convenient macros.
float angleIncrement() const
Transform localTransform() const