add factory ...
parent
caf01fb59f
commit
191ba733b1
|
@ -12,18 +12,13 @@
|
||||||
classname &operator=(const classname &) = delete;
|
classname &operator=(const classname &) = delete;
|
||||||
|
|
||||||
// adapted form baidu apollo cyber/common/macros.h
|
// adapted form baidu apollo cyber/common/macros.h
|
||||||
#define DECLARE_SINGLETON(classname) \
|
#define DECLARE_SINGLETON(classname) \
|
||||||
public: \
|
public: \
|
||||||
static classname *Instance() { \
|
static classname *Instance() { \
|
||||||
static std::unique_ptr<classname> instance{nullptr}; \
|
static classname instance; \
|
||||||
if (!instance) { \
|
return &instance; \
|
||||||
static std::once_flag flag; \
|
} \
|
||||||
std::call_once(flag, \
|
\
|
||||||
[&] { instance.reset(new (std::nothrow) classname()); }); \
|
private: \
|
||||||
} \
|
classname() = default; \
|
||||||
return instance.get(); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
private: \
|
|
||||||
classname() = default; \
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(classname)
|
DISALLOW_COPY_AND_ASSIGN(classname)
|
||||||
|
|
|
@ -74,18 +74,4 @@ Eigen::Vector4d FitPlane(const pcl::PointCloud<PT> &cloud,
|
||||||
return coeffs;
|
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
|
} // namespace common
|
|
@ -62,7 +62,6 @@ template <typename PT>
|
||||||
inline void TransformPointCloud(const Pose3d &pose,
|
inline void TransformPointCloud(const Pose3d &pose,
|
||||||
const pcl::PointCloud<PT> &cloud_in,
|
const pcl::PointCloud<PT> &cloud_in,
|
||||||
pcl::PointCloud<PT> *const cloud_out) {
|
pcl::PointCloud<PT> *const cloud_out) {
|
||||||
ACHECK(cloud_out);
|
|
||||||
pcl::transformPointCloud(cloud_in, *cloud_out, pose.TransMat().cast<float>());
|
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;
|
size_t j = 0;
|
||||||
for (size_t i = 0; i < cloud_in.size(); ++i) {
|
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 (check(pt)) {
|
||||||
if (removed_indices) removed_indices->push_back(i);
|
if (removed_indices) removed_indices->push_back(i);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -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;
|
||||||
|
};
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
namespace common {
|
namespace common {
|
||||||
|
|
||||||
|
void Timer::Tic() {
|
||||||
|
start_ = std::chrono::system_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
double Timer::Toc(char unit) {
|
double Timer::Toc(char unit) {
|
||||||
ACHECK(unit == 's' || unit == 'm' || unit == 'u')
|
ACHECK(unit == 's' || unit == 'm' || unit == 'u')
|
||||||
<< "Only 's'(second), 'm'(millisecond) and 'u'(microsecond) are "
|
<< "Only 's'(second), 'm'(millisecond) and 'u'(microsecond) are "
|
||||||
|
|
|
@ -13,9 +13,7 @@ class Timer {
|
||||||
Tic();
|
Tic();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tic() {
|
void Tic();
|
||||||
start_ = std::chrono::system_clock::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
// unit: 's' = second, 'm' = millisecond, 'u' = microsecond
|
// unit: 's' = second, 'm' = millisecond, 'u' = microsecond
|
||||||
double Toc(char unit = 'm');
|
double Toc(char unit = 'm');
|
||||||
|
|
Loading…
Reference in New Issue