add factory ...

main
feixyz10 2021-02-27 17:55:29 +08:00 committed by feixyz
parent caf01fb59f
commit 191ba733b1
7 changed files with 34 additions and 33 deletions

View File

@ -12,18 +12,13 @@
classname &operator=(const classname &) = delete;
// adapted form baidu apollo cyber/common/macros.h
#define DECLARE_SINGLETON(classname) \
public: \
static classname *Instance() { \
static std::unique_ptr<classname> instance{nullptr}; \
if (!instance) { \
static std::once_flag flag; \
std::call_once(flag, \
[&] { instance.reset(new (std::nothrow) classname()); }); \
} \
return instance.get(); \
} \
\
private: \
classname() = default; \
#define DECLARE_SINGLETON(classname) \
public: \
static classname *Instance() { \
static classname instance; \
return &instance; \
} \
\
private: \
classname() = default; \
DISALLOW_COPY_AND_ASSIGN(classname)

View File

@ -74,18 +74,4 @@ Eigen::Vector4d FitPlane(const pcl::PointCloud<PT> &cloud,
return coeffs;
}
// template <typename PT>
// Eigen::Vector4d FitPlane(const pcl::PointCloud<PT> &cloud) {
// Eigen::MatrixX3f A(cloud.size(), 3); // NOLINT
// Eigen::VectorXf b(cloud.size());
// b.setConstant(-1.0);
// size_t i = 0;
// for (const auto &p : cloud) {
// A.row(i++) << p.x, p.y, p.z;
// }
// Eigen::Vector3f sol = A.colPivHouseholderQr().solve(b);
// Eigen::Vector4d coeff(sol(0), sol(1), sol(2), 1.0);
// return coeff / sol.norm();
// }
} // namespace common

View File

@ -62,7 +62,6 @@ template <typename PT>
inline void TransformPointCloud(const Pose3d &pose,
const pcl::PointCloud<PT> &cloud_in,
pcl::PointCloud<PT> *const cloud_out) {
ACHECK(cloud_out);
pcl::transformPointCloud(cloud_in, *cloud_out, pose.TransMat().cast<float>());
}
@ -78,7 +77,7 @@ void RemovePoints(const pcl::PointCloud<PT> &cloud_in,
}
size_t j = 0;
for (size_t i = 0; i < cloud_in.size(); ++i) {
const auto pt = cloud_in.points[i];
const auto &pt = cloud_in.points[i];
if (check(pt)) {
if (removed_indices) removed_indices->push_back(i);
continue;

View File

View File

@ -0,0 +1,19 @@
#pragma once
#include <map>
#include <memory>
#include <string>
#include "common/log/log.h"
#include "common/macro/macros.h"
template <typename BaseClass>
class AbstractFactory {
virtual ~AbstractFactory() = default;
virtual std::shared_ptr<BaseClass> Create() = 0;
};
template <typename BaseClass, typename DerivedClass>
class ConcreteFactory {
virtual std::shared_ptr<BaseClass> Create() = 0;
};

View File

@ -4,6 +4,10 @@
namespace common {
void Timer::Tic() {
start_ = std::chrono::system_clock::now();
}
double Timer::Toc(char unit) {
ACHECK(unit == 's' || unit == 'm' || unit == 'u')
<< "Only 's'(second), 'm'(millisecond) and 'u'(microsecond) are "

View File

@ -13,9 +13,7 @@ class Timer {
Tic();
}
void Tic() {
start_ = std::chrono::system_clock::now();
}
void Tic();
// unit: 's' = second, 'm' = millisecond, 'u' = microsecond
double Toc(char unit = 'm');