forked from fetty31/fast_LIMO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommon.hpp
150 lines (122 loc) · 3.87 KB
/
Common.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
Copyright (c) 2024 Oriol Martínez @fetty31
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FASTLIMO_COMMON_HPP__
#define __FASTLIMO_COMMON_HPP__
#ifndef HAS_CUPID
#include <cpuid.h>
#endif
#define FAST_LIMO_v "1.0.0"
// System
#include <ctime>
#include <iomanip>
#include <future>
#include <ios>
#include <sys/times.h>
#include <sys/vtimes.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <string>
#include <climits>
#include <cmath>
#include <thread>
#include <atomic>
#include <mutex>
#include <queue>
template <typename T>
std::string to_string_with_precision(const T a_value, const int n = 6)
{
std::ostringstream out;
out.precision(n);
out << std::fixed << a_value;
return out.str();
}
// FASTLIOv2
#include "IKFoM/use-ikfom.hpp"
#include "ikd-Tree/ikd_Tree/ikd_Tree.h"
// Boost
#include <boost/format.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/range/adaptor/indexed.hpp>
#include <boost/range/adaptor/adjacent_filtered.hpp>
#include <boost/range/adaptor/filtered.hpp>
// PCL
#define PCL_NO_PRECOMPILE
#include <pcl/filters/crop_box.h>
#include <pcl/filters/voxel_grid.h>
#include <pcl/filters/statistical_outlier_removal.h>
#include <pcl/io/pcd_io.h>
namespace fast_limo {
enum class SensorType { OUSTER, VELODYNE, HESAI, LIVOX, UNKNOWN };
// MODULES
class Localizer;
class Mapper;
// OBJECTS
class State;
class Plane;
class Match;
// UTILS
struct Config;
// STRUCTURES
struct Point {
Point(): data{0.f, 0.f, 0.f, 1.f} {}
Point(float x, float y, float z): data{x, y, z, 1.f} {}
PCL_ADD_POINT4D;
float intensity;
union {
std::uint32_t t; // (Ouster) time since beginning of scan in nanoseconds
float time; // (Velodyne) time since beginning of scan in seconds
double timestamp; // (Hesai) absolute timestamp in seconds
// (Livox) absolute timestamp in (seconds * 10e9)
};
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
} EIGEN_ALIGN16;
struct Extrinsics{
struct SE3 {
Eigen::Vector3f t;
Eigen::Matrix3f R;
};
SE3 imu2baselink;
SE3 lidar2baselink;
Eigen::Matrix4f imu2baselink_T;
Eigen::Matrix4f lidar2baselink_T;
};
struct IMUmeas{
double stamp;
double dt; // defined as the difference between the current and the previous measurement
Eigen::Vector3f ang_vel;
Eigen::Vector3f lin_accel;
Eigen::Quaternionf q;
};
}
POINT_CLOUD_REGISTER_POINT_STRUCT(fast_limo::Point,
(float, x, x)
(float, y, y)
(float, z, z)
(float, intensity, intensity)
(std::uint32_t, t, t)
(float, time, time)
(double, timestamp, timestamp))
typedef fast_limo::Point PointType;
typedef pcl::PointXYZ MapPoint;
typedef std::vector<pcl::PointXYZ, Eigen::aligned_allocator<pcl::PointXYZ>> MapPoints;
typedef std::vector<PointType, Eigen::aligned_allocator<PointType>> LocPoints;
typedef std::vector<fast_limo::Match> Matches;
typedef std::vector<fast_limo::Plane> Planes;
typedef std::vector<fast_limo::State> States;
#endif