optimal voxel layer
This commit is contained in:
@@ -519,11 +519,13 @@ bool VoxelLayer::readDepthMeters(const robot_sensor_msgs::Image& depth, unsigned
|
||||
|
||||
void VoxelLayer::updateDepthRayCache(unsigned int width, unsigned int height,
|
||||
unsigned int pixel_step, double fx, double fy,
|
||||
double cx, double cy)
|
||||
double cx, double cy,
|
||||
unsigned int u_offset, unsigned int v_offset)
|
||||
{
|
||||
if (cached_depth_width_ == width && cached_depth_height_ == height &&
|
||||
cached_depth_pixel_step_ == pixel_step && cached_fx_ == fx && cached_fy_ == fy &&
|
||||
cached_cx_ == cx && cached_cy_ == cy)
|
||||
cached_cx_ == cx && cached_cy_ == cy &&
|
||||
cached_u_offset_ == u_offset && cached_v_offset_ == v_offset)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -535,15 +537,17 @@ void VoxelLayer::updateDepthRayCache(unsigned int width, unsigned int height,
|
||||
cached_fy_ = fy;
|
||||
cached_cx_ = cx;
|
||||
cached_cy_ = cy;
|
||||
cached_u_offset_ = u_offset;
|
||||
cached_v_offset_ = v_offset;
|
||||
|
||||
const std::size_t rows = (height + pixel_step - 1) / pixel_step;
|
||||
const std::size_t columns = (width + pixel_step - 1) / pixel_step;
|
||||
depth_ray_cache_.clear();
|
||||
depth_ray_cache_.reserve(rows * columns);
|
||||
|
||||
for (unsigned int v = 0; v < height; v += pixel_step)
|
||||
for (unsigned int v = v_offset; v < height; v += pixel_step)
|
||||
{
|
||||
for (unsigned int u = 0; u < width; u += pixel_step)
|
||||
for (unsigned int u = u_offset; u < width; u += pixel_step)
|
||||
{
|
||||
const double x = (static_cast<double>(u) - cx) / fx;
|
||||
const double y = (static_cast<double>(v) - cy) / fy;
|
||||
@@ -683,7 +687,16 @@ bool VoxelLayer::raytraceDepthFrustum(const DepthCameraObservation& observation,
|
||||
frustum_skip_distance_ >= 0.0 ? frustum_skip_distance_ : 2.0 * resolution_;
|
||||
const unsigned int width = std::min(depth.width, camera_info.width == 0 ? depth.width : camera_info.width);
|
||||
const unsigned int height = std::min(depth.height, camera_info.height == 0 ? depth.height : camera_info.height);
|
||||
updateDepthRayCache(width, height, step, fx, fy, cx, cy);
|
||||
|
||||
// Dither the sampled pixel grid every pass. With a fixed subgrid a static
|
||||
// camera re-traces identical rays each frame; cells between adjacent rays
|
||||
// (angular gap step / fx, ~5 cm at 2.5 m for step 8) are never crossed and
|
||||
// stay marked until the robot moves. Cycling the phase sweeps every pixel
|
||||
// column/row over step^2 frames at the same per-frame ray count.
|
||||
const unsigned int u_offset = step > 1 ? frustum_phase_ % step : 0;
|
||||
const unsigned int v_offset = step > 1 ? (frustum_phase_ / step) % step : 0;
|
||||
++frustum_phase_;
|
||||
updateDepthRayCache(width, height, step, fx, fy, cx, cy, u_offset, v_offset);
|
||||
|
||||
double qx = tfm.transform.rotation.x;
|
||||
double qy = tfm.transform.rotation.y;
|
||||
|
||||
Reference in New Issue
Block a user