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

avoid zero division in RayCaster::setupRayCaster #418

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions voxblox/src/integrator/integrator_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,24 @@ void RayCaster::setupRayCaster(const Point& start_scaled,
Ray distance_to_boundaries(corrected_step.cast<FloatingPoint>() -
start_scaled_shifted);

t_to_next_boundary_ = Ray((std::abs(ray_scaled.x()) < 0.0)
t_to_next_boundary_ = Ray((std::abs(ray_scaled.x()) <= 0.0)
? 2.0
: distance_to_boundaries.x() / ray_scaled.x(),
(std::abs(ray_scaled.y()) < 0.0)
(std::abs(ray_scaled.y()) <= 0.0)
? 2.0
: distance_to_boundaries.y() / ray_scaled.y(),
(std::abs(ray_scaled.z()) < 0.0)
(std::abs(ray_scaled.z()) <= 0.0)
? 2.0
: distance_to_boundaries.z() / ray_scaled.z());

// Distance to cross one grid cell along the ray in t.
// Same as absolute inverse value of delta_coord.
t_step_size_ = Ray(
(std::abs(ray_scaled.x()) < 0.0) ? 2.0
(std::abs(ray_scaled.x()) <= 0.0) ? 2.0
: ray_step_signs_.x() / ray_scaled.x(),
(std::abs(ray_scaled.y()) < 0.0) ? 2.0
(std::abs(ray_scaled.y()) <= 0.0) ? 2.0
: ray_step_signs_.y() / ray_scaled.y(),
(std::abs(ray_scaled.z()) < 0.0) ? 2.0
(std::abs(ray_scaled.z()) <= 0.0) ? 2.0
: ray_step_signs_.z() / ray_scaled.z());
}

Expand Down