oh_my_loam/src/oh_my_loam.cc

44 lines
1.2 KiB
C++
Raw Normal View History

2020-10-12 21:09:32 +08:00
#include "oh_my_loam.h"
2020-10-18 01:14:43 +08:00
#include "extractor/extractor_VLP16.h"
2020-10-12 21:09:32 +08:00
namespace oh_my_loam {
2020-10-18 01:14:43 +08:00
namespace {
const double kPointMinDist = 0.1;
}
2020-10-16 18:08:31 +08:00
bool OhMyLoam::Init() {
YAML::Node config = Config::Instance()->config();
2020-10-18 01:14:43 +08:00
extractor_.reset(new ExtractorVLP16);
if (!extractor_->Init(config["extractor_config"])) {
AERROR << "Failed to initialize extractor";
2020-10-16 18:08:31 +08:00
return false;
2020-10-12 21:09:32 +08:00
}
2020-10-29 20:32:19 +08:00
odometry_.reset(new Odometry);
if (!odometry_->Init(config["odometry_config"])) {
AERROR << "Failed to initialize odometry";
return false;
}
2020-10-12 21:09:32 +08:00
return true;
}
2020-10-18 01:14:43 +08:00
void OhMyLoam::Run(const PointCloud& cloud_in, double timestamp) {
PointCloudPtr cloud(new PointCloud);
RemoveOutliers(cloud_in, cloud.get());
ADEBUG << "After remove, point num: " << cloud_in.size() << " -> "
<< cloud->size();
FeaturePoints feature_points;
2020-10-28 02:09:59 +08:00
extractor_->Process(*cloud, &feature_points);
2020-10-29 20:32:19 +08:00
Pose3D pose;
odometry_->Process(feature_points, &pose);
poses_.emplace_back(pose);
2020-10-18 01:14:43 +08:00
}
void OhMyLoam::RemoveOutliers(const PointCloud& cloud_in,
PointCloud* const cloud_out) const {
RemoveNaNPoint<Point>(cloud_in, cloud_out);
RemoveClosedPoints<Point>(*cloud_out, cloud_out, kPointMinDist);
2020-10-12 21:09:32 +08:00
}
2020-10-13 01:07:59 +08:00
} // namespace oh_my_loam