Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(at128): allow negative values in points' elevation fields #193

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,23 @@ class AngleCorrectorCorrectionBased : public AngleCorrector<HesaiCorrection>
{
int field = findField(block_azimuth);

int32_t elevation =
correction_->elevation[channel_id] +
correction_->getElevationAdjustV3(channel_id, block_azimuth) * (AngleUnit / 100);
int32_t elevation = correction_->elevation[channel_id] +
correction_->getElevationAdjustV3(channel_id, block_azimuth) *
static_cast<int32_t>(AngleUnit / 100);

// Allow negative angles in the radian value. This makes visualization of this field nicer and
// should have no other mathematical implications in downstream modules.
float elevation_rad = 2.f * elevation * M_PI / MAX_AZIMUTH;
// Then, normalize the integer value to the positive [0, MAX_AZIMUTH] range for array indexing
elevation = (MAX_AZIMUTH + elevation) % MAX_AZIMUTH;

int32_t azimuth =
(block_azimuth + MAX_AZIMUTH - correction_->startFrame[field]) * 2 -
correction_->azimuth[channel_id] +
correction_->getAzimuthAdjustV3(channel_id, block_azimuth) * (AngleUnit / 100);
int32_t azimuth = (block_azimuth + MAX_AZIMUTH - correction_->startFrame[field]) * 2 -
correction_->azimuth[channel_id] +
correction_->getAzimuthAdjustV3(channel_id, block_azimuth) *
static_cast<int32_t>(AngleUnit / 100);
azimuth = (MAX_AZIMUTH + azimuth) % MAX_AZIMUTH;

float azimuth_rad = 2.f * azimuth * M_PIf / MAX_AZIMUTH;
float elevation_rad = 2.f * elevation * M_PIf / MAX_AZIMUTH;
float azimuth_rad = 2.f * azimuth * M_PI / MAX_AZIMUTH;

return {azimuth_rad, elevation_rad, sin_[azimuth],
cos_[azimuth], sin_[elevation], cos_[elevation]};
Expand Down
Loading