Skip to content

Commit 9e49998

Browse files
committed
Offset time YAML parameter
1 parent 81de64c commit 9e49998

File tree

8 files changed

+50
-3
lines changed

8 files changed

+50
-3
lines changed

config/ouster.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ real_time_delay: 0.1 # Should be at least [FULL_ROTATION_TIME] (without a
2626

2727
# LiDAR
2828
LiDAR_type: ouster # Options: velodyne, hesai, ouster, custom
29+
offset_begin: true # (Usual values: Velodyne = false, Ouster = true, HESAI = indiferent) Is the offset with respect the beginning of the rotation (i.e. point.time ~ [0, 0.1]) or with respect the end (i.e. point.time ~ [-0.1, 0])? For more information see Issue #14: https://github.com/Huguet57/LIMO-Velo/issues/14
2930
LiDAR_noise: 0.001
3031
full_rotation_time: 0.1
3132
min_dist: 4 # Minimum distance: doesn't use points closer than this radius

config/params.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ real_time_delay: 0.1 # Should be at least [FULL_ROTATION_TIME] (without a
2424

2525
# LiDAR
2626
LiDAR_type: velodyne # Options: velodyne, hesai, ouster, custom
27+
offset_begin: false # (Usual values: Velodyne = false, Ouster = true, HESAI = indiferent) Is the offset with respect the beginning of the rotation (i.e. point.time ~ [0, 0.1]) or with respect the end (i.e. point.time ~ [-0.1, 0])? For more information see Issue #14: https://github.com/Huguet57/LIMO-Velo/issues/14
2728
LiDAR_noise: 0.001
2829
full_rotation_time: 0.1
2930
min_dist: 4 # Minimum distance: doesn't use points closer than this radius

config/xaloc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ real_time_delay: 0.1 # Should be at least [FULL_ROTATION_TIME] (without a
2323

2424
# LiDAR
2525
LiDAR_type: velodyne
26+
offset_begin: true # (Xaloc's value, having a modified LiDAR driver, is 'true') Is the offset with respect the beginning of the rotation (i.e. point.time ~ [0, 0.1]) or with respect the end (i.e. point.time ~ [-0.1, 0])? For more information see Issue #14: https://github.com/Huguet57/LIMO-Velo/issues/14
2627
LiDAR_noise: 0.001
2728
full_rotation_time: 0.1
2829
min_dist: 4

include/Headers/Accumulator.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Accumulator {
5252

5353
private:
5454
bool is_ready = false;
55+
bool has_warned_lidar = false;
5556

5657
void push(const State&);
5758
void push(const IMU&);
@@ -110,6 +111,9 @@ class Accumulator {
110111
void set_initial_time();
111112
double interpret_heuristic(const HeuristicParams&, double t);
112113

114+
bool missing_data(const Points&);
115+
void throw_warning(const Points&);
116+
113117
// Singleton pattern
114118
public:
115119
static Accumulator& getInstance() {

include/Headers/Common.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ struct Params {
7373
double min_dist;
7474
std::string LiDAR_type;
7575

76+
bool offset_begin;
77+
7678
double degeneracy_threshold;
7779
bool print_degeneracy_values;
7880

include/Headers/Objects.hpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,22 @@ class Point {
9393
Point(const velodyne_ros::Point& p) {
9494
this->set_XYZ(p);
9595
this->set_attributes(p);
96-
this->time = (double) p.time;
96+
97+
// Time offset with respect to beginning of rotation, i.e. ~= [0, 0.1]
98+
if (Config.offset_begin) this->time = (double) p.time;
99+
// Time offset with respect to end of rotation, i.e. ~= [-0.1, 0]
100+
else this->time = Config.full_rotation_time + (double) p.time;
97101
}
98102

99103
// Ouster specific
100104
Point(const ouster_ros::Point& p) {
101105
this->set_XYZ(p);
102106
this->set_attributes(p);
103-
this->time = Conversions::nanosec2Sec(p.t);
107+
108+
// Time offset with respect to beginning of rotation, i.e. ~= [0, 0.1]
109+
if (Config.offset_begin) this->time = Conversions::nanosec2Sec(p.t);
110+
// Time offset with respect to end of rotation, i.e. ~= [-0.1, 0]
111+
else this->time = Config.full_rotation_time + Conversions::nanosec2Sec(p.t);
104112
}
105113

106114
// Custom specific

src/Modules/Accumulator.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ extern struct Params Config;
3939
void Accumulator::receive_lidar(const PointCloud_msg& msg) {
4040
// Turn message to processed points
4141
Points points = this->process(msg);
42+
43+
// Check if missing data
44+
if (this->missing_data(points)) this->throw_warning(points);
45+
4246
// Add them individually on the LiDAR buffer
4347
for (Point p : points) this->add(p);
4448
}
@@ -161,4 +165,29 @@ extern struct Params Config;
161165
return heuristic.deltas[k];
162166

163167
return heuristic.deltas.back();
168+
}
169+
170+
bool Accumulator::missing_data(const Points& time_sorted_points) {
171+
if (time_sorted_points.size() < Config.MAX_POINTS2MATCH) return false;
172+
173+
// Check missing 'time' information
174+
if (time_sorted_points.front().time == 0 and time_sorted_points.back().time == 0) {
175+
// Remove Heuristic
176+
Config.Heuristic.times = {};
177+
Config.Heuristic.deltas = {Config.full_rotation_time};
178+
179+
return true;
180+
}
181+
182+
return false;
183+
}
184+
185+
void Accumulator::throw_warning(const Points& time_sorted_points) {
186+
// Warn once
187+
if (not this->has_warned_lidar) this->has_warned_lidar = true;
188+
else return;
189+
190+
// Warn missing 'time' information
191+
ROS_ERROR("LiDAR points are missing 'time' information.");
192+
ROS_ERROR("Delta has been fixed to %f (s) leading to a fixed %d (Hz) localization.", Config.full_rotation_time, (int) 1./Config.full_rotation_time);
164193
}

src/main.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ void fill_config(ros::NodeHandle& nh) {
163163
nh.param<double>("wz_MULTIPLIER", Config.wz_MULTIPLIER, 1);
164164
nh.param<std::string>("points_topic", Config.points_topic, "/velodyne_points");
165165
nh.param<std::string>("imus_topic", Config.imus_topic, "/vectornav/IMU");
166+
nh.param<bool>("offset_begin", Config.offset_begin, false);
166167
nh.param<std::vector<double>>("/Heuristic/times", Config.Heuristic.times, {});
167-
nh.param<std::vector<double>>("/Heuristic/deltas", Config.Heuristic.deltas, {0.1});
168+
nh.param<std::vector<double>>("/Heuristic/deltas", Config.Heuristic.deltas, {Config.full_rotation_time});
168169
nh.param<std::vector<float>>("initial_gravity", Config.initial_gravity, {0.0, 0.0, -9.807});
169170
nh.param<std::vector<float>>("I_Translation_L", Config.I_Translation_L, std::vector<float> (3, 0.));
170171
nh.param<std::vector<float>>("I_Rotation_L", Config.I_Rotation_L, std::vector<float> (9, 0.));

0 commit comments

Comments
 (0)