Skip to content

Commit 0959959

Browse files
committed
WIP
1 parent 87dbb2e commit 0959959

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/angle_corrector.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class AngleCorrector
5252
/// @brief Returns whether the given block (azimuth) is the last in the current scan
5353
/// @param block_azimuth The current azimuth value in the sensor's angle resolution
5454
/// @return true if the current azimuth is the last in the current scan, false otherwise
55-
virtual bool blockCompletesScan(uint32_t block_azimuth) = 0;
55+
virtual bool blockCompletesScan(uint32_t block_azimuth, uint32_t last_azimuth) = 0;
5656
};
5757

5858
} // namespace drivers

nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/angle_corrector_calibration_based.hpp

+10-14
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,12 @@ class AngleCorrectorCalibrationBased : public AngleCorrector<HesaiCalibrationCon
7878
}
7979
}
8080

81-
auto scan_cut_block_azimuth = static_cast<uint32_t>(rad2deg(scan_cut_azimuth_rad) * 10.0);
82-
while (true) {
83-
auto block_azimuth_rad = block_azimuth_rad_[scan_cut_block_azimuth];
84-
for (auto correction : azimuth_offset_rad_) {
85-
if (block_azimuth_rad + correction < scan_cut_azimuth_rad) {
86-
scan_cut_block_azimuth_++;
87-
break;
88-
}
89-
}
90-
91-
break;
92-
}
81+
auto min_azimuth_offset = std::min(azimuth_offset_rad_);
82+
9383

9484
scan_cut_block_azimuth_ = scan_cut_block_azimuth;
85+
std::cout << "Cut angle setting: " << rad2deg(scan_cut_azimuth_rad)
86+
<< " deg, calculated: " << scan_cut_block_azimuth_ / 100.0 << " deg" << std::endl;
9587
}
9688

9789
CorrectedAngleData getCorrectedAngleData(uint32_t block_azimuth, uint32_t channel_id) override
@@ -108,9 +100,13 @@ class AngleCorrectorCalibrationBased : public AngleCorrector<HesaiCalibrationCon
108100
elevation_cos_[channel_id]};
109101
}
110102

111-
bool blockCompletesScan(uint32_t current_azimuth) override
103+
bool blockCompletesScan(uint32_t current_azimuth, uint32_t last_azimuth) override
112104
{
113-
return current_azimuth == scan_cut_block_azimuth_;
105+
if (current_azimuth < last_azimuth) {
106+
current_azimuth += MAX_AZIMUTH_LEN;
107+
}
108+
109+
return current_azimuth >= scan_cut_block_azimuth_ && last_azimuth < scan_cut_block_azimuth_;
114110
}
115111
};
116112

nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/angle_corrector_correction_based.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class AngleCorrectorCorrectionBased : public AngleCorrector<HesaiCorrection>
126126
cos_[azimuth], sin_[elevation], cos_[elevation]};
127127
}
128128

129-
bool blockCompletesScan(uint32_t block_azimuth) override
129+
bool blockCompletesScan(uint32_t block_azimuth, uint32_t last_azimuth) override
130130
{
131131
auto begin = cut_azimuths_.cbegin();
132132
auto end = cut_azimuths_.cend();

nebula_decoders/include/nebula_decoders/nebula_decoders_hesai/decoders/hesai_decoder.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class HesaiDecoder : public HesaiScanDecoder
237237
return static_cast<uint32_t>(sensor_configuration_->scan_phase * 10);
238238
}
239239

240-
return sensor_configuration_->cloud_max_angle;
240+
return sensor_configuration_->cloud_max_angle * 10;
241241
}
242242

243243
public:
@@ -281,7 +281,7 @@ class HesaiDecoder : public HesaiScanDecoder
281281
convertReturns(block_id, n_returns);
282282

283283
auto block_azimuth = packet_.body.blocks[block_id].get_azimuth();
284-
bool scan_completed = angle_corrector_.blockCompletesScan(block_azimuth);
284+
bool scan_completed = angle_corrector_.blockCompletesScan(block_azimuth, last_phase_);
285285

286286
if (scan_completed) {
287287
std::swap(decode_pc_, output_pc_);

nebula_hw_interfaces/src/nebula_hesai_hw_interfaces/hesai_hw_interface.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,16 @@ HesaiLidarRangeAll HesaiHwInterface::GetLidarRange()
505505
Status HesaiHwInterface::checkAndSetLidarRange(
506506
const HesaiCalibrationConfigurationBase & calibration)
507507
{
508-
int cloud_min = sensor_configuration_->cloud_min_angle;
509-
int cloud_max = sensor_configuration_->cloud_max_angle;
508+
int cloud_min = sensor_configuration_->cloud_min_angle * 10;
509+
int cloud_max = sensor_configuration_->cloud_max_angle * 10;
510+
511+
std::cout << "Starting with HW FoV of " << cloud_min << "~" << cloud_max << std::endl;
510512

511513
// Only oversize the FoV if it is not already the full 360deg
512-
if (cloud_max - cloud_min < 3600) {
514+
if (cloud_min != 0 || cloud_max != 3600) {
513515
auto padding = calibration.getFovPadding();
514-
cloud_min += static_cast<int>(std::get<0>(padding) * 10);
515-
cloud_max += static_cast<int>(std::get<1>(padding) * 10);
516+
cloud_min += floor(std::get<0>(padding) * 10);
517+
cloud_max += ceil(std::get<1>(padding) * 10);
516518
}
517519

518520
auto clamp = [](int x) {
@@ -521,6 +523,8 @@ Status HesaiHwInterface::checkAndSetLidarRange(
521523
return x;
522524
};
523525

526+
std::cout << "Setting HW FoV to " << cloud_min << "~" << cloud_max << std::endl;
527+
524528
return SetLidarRange(clamp(cloud_min), clamp(cloud_max));
525529
}
526530

nebula_ros/config/lidar/hesai/Pandar128E4X.param.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**:
22
ros__parameters:
3-
host_ip: 255.255.255.255
3+
host_ip: 192.168.1.10
44
sensor_ip: 192.168.1.201
55
data_port: 2368
66
gnss_port: 10110
@@ -11,8 +11,8 @@
1111
diag_span: 1000
1212
min_range: 0.3
1313
max_range: 300.0
14-
cloud_min_angle: 0
15-
cloud_max_angle: 360
14+
cloud_min_angle: 90
15+
cloud_max_angle: 270
1616
scan_phase: 0.0
1717
sensor_model: Pandar128E4X
1818
calibration_file: $(find-pkg-share nebula_decoders)/calibration/hesai/$(var sensor_model).csv

0 commit comments

Comments
 (0)