mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Added util3d::transformLaserScan(). OdomF2F: filling local scan map field with key frame scane in odom info. DbViewer: Print database parameters in Info view.
This commit is contained in:
@@ -129,7 +129,11 @@ Transform OdometryF2F::computeTransform(
|
||||
{
|
||||
info->localMap.insert(std::make_pair(iter->first, util3d::transformPoint(iter->second, t)));
|
||||
}
|
||||
info->localMapSize = tmpRefFrame.getWords3().size();
|
||||
info->words = newFrame.getWords();
|
||||
|
||||
info->localScanMapSize = tmpRefFrame.sensorData().laserScanRaw().cols;
|
||||
info->localScanMap = util3d::transformLaserScan(tmpRefFrame.sensorData().laserScanRaw(), t);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -948,12 +948,11 @@ cv::Mat laserScanFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud,
|
||||
{
|
||||
cv::Mat laserScan(1, (int)cloud.size(), CV_32FC(6));
|
||||
bool nullTransform = transform.isNull() || transform.isIdentity();
|
||||
Eigen::Affine3f transform3f = transform.toEigen3f();
|
||||
for(unsigned int i=0; i<cloud.size(); ++i)
|
||||
{
|
||||
if(!nullTransform)
|
||||
{
|
||||
pcl::PointNormal pt = pcl::transformPoint(cloud.at(i), transform3f);
|
||||
pcl::PointNormal pt = util3d::transformPoint(cloud.at(i), transform);
|
||||
laserScan.at<cv::Vec6f>(i)[0] = pt.x;
|
||||
laserScan.at<cv::Vec6f>(i)[1] = pt.y;
|
||||
laserScan.at<cv::Vec6f>(i)[2] = pt.z;
|
||||
|
||||
@@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "rtabmap/core/util3d_transforms.h"
|
||||
|
||||
#include <pcl/common/transforms.h>
|
||||
#include <rtabmap/utilite/ULogger.h>
|
||||
|
||||
namespace rtabmap
|
||||
{
|
||||
@@ -35,6 +36,58 @@ namespace rtabmap
|
||||
namespace util3d
|
||||
{
|
||||
|
||||
cv::Mat transformLaserScan(const cv::Mat & laserScan, const Transform & transform)
|
||||
{
|
||||
UASSERT(laserScan.empty() || laserScan.type() == CV_32FC2 || laserScan.type() == CV_32FC3 || laserScan.type() == CV_32FC(6));
|
||||
|
||||
cv::Mat output = laserScan.clone();
|
||||
|
||||
if(!transform.isNull() && !transform.isIdentity())
|
||||
{
|
||||
for(int i=0; i<laserScan.cols; ++i)
|
||||
{
|
||||
if(laserScan.type() == CV_32FC2)
|
||||
{
|
||||
pcl::PointXYZ pt(
|
||||
laserScan.at<cv::Vec2f>(i)[0],
|
||||
laserScan.at<cv::Vec2f>(i)[1], 0);
|
||||
pt = util3d::transformPoint(pt, transform);
|
||||
output.at<cv::Vec2f>(i)[0] = pt.x;
|
||||
output.at<cv::Vec2f>(i)[1] = pt.y;
|
||||
}
|
||||
else if(laserScan.type() == CV_32FC3)
|
||||
{
|
||||
pcl::PointXYZ pt(
|
||||
laserScan.at<cv::Vec3f>(i)[0],
|
||||
laserScan.at<cv::Vec3f>(i)[1],
|
||||
laserScan.at<cv::Vec3f>(i)[2]);
|
||||
pt = util3d::transformPoint(pt, transform);
|
||||
output.at<cv::Vec3f>(i)[0] = pt.x;
|
||||
output.at<cv::Vec3f>(i)[1] = pt.y;
|
||||
output.at<cv::Vec3f>(i)[2] = pt.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
pcl::PointNormal pt;
|
||||
pt.x=laserScan.at<cv::Vec6f>(i)[0];
|
||||
pt.y=laserScan.at<cv::Vec6f>(i)[1];
|
||||
pt.z=laserScan.at<cv::Vec6f>(i)[2];
|
||||
pt.normal_x=laserScan.at<cv::Vec6f>(i)[3];
|
||||
pt.normal_y=laserScan.at<cv::Vec6f>(i)[4];
|
||||
pt.normal_z=laserScan.at<cv::Vec6f>(i)[5];
|
||||
pt = util3d::transformPoint(pt, transform);
|
||||
output.at<cv::Vec6f>(i)[0] = pt.x;
|
||||
output.at<cv::Vec6f>(i)[1] = pt.y;
|
||||
output.at<cv::Vec6f>(i)[2] = pt.z;
|
||||
output.at<cv::Vec6f>(i)[3] = pt.normal_x;
|
||||
output.at<cv::Vec6f>(i)[4] = pt.normal_y;
|
||||
output.at<cv::Vec6f>(i)[5] = pt.normal_z;
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr transformPointCloud(
|
||||
const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
|
||||
const Transform & transform)
|
||||
|
||||
Reference in New Issue
Block a user