The whole-voxel rule never clears a voxel whose box crosses the image edge. A person bending over to lift an object leaves high voxels at the top edge of the image: in the 2026-10-15 lift bag 0 of 54 phantom cells cleared. - DepthEvidenceStore keeps, per marked voxel, the 6 per-axis extreme points plus the most recent ones, keyed by a window-independent cell index. - DepthVisibilityChecker::classifyPoints: Free only when every evidence point projects with a full patch inside the usable image and sees valid depth behind it; any surface in front keeps it, invalid depth keeps it. - Paired marking drops points within depth_marking_border_px of the image edge, so every kept point can be re-checked from the pose that saw it. - Voxels without evidence keep the whole-voxel rule; evidence is erased on clear, pruned on rolling shift and every 50 frames. - New keys depth_evidence_points_enabled (default false), depth_evidence_points_per_voxel (8, 6..16), depth_marking_border_px (must be > depth_projection_margin_px when enabled); startup log and counters (by_evidence, border_dropped_points, evidence_voxels). - Tests: depth_evidence_store_test; checker and layer tests for the image top cut, border drop, rolling shift and a still-visible object.
53 lines
2.1 KiB
C++
53 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <robot_costmap_2d/observation.h>
|
|
#include <tf3/compat.h>
|
|
#include <Eigen/Geometry>
|
|
#include <vector>
|
|
|
|
namespace robot_costmap_2d
|
|
{
|
|
enum class DepthVisibility { Free, Unknown, Surface };
|
|
enum class DepthVisibilityReason { Free, OutsideView, InvalidDepth, Surface, EmptyRegion };
|
|
struct DepthVisibilityResult
|
|
{
|
|
DepthVisibility state{DepthVisibility::Unknown};
|
|
DepthVisibilityReason reason{DepthVisibilityReason::OutsideView};
|
|
};
|
|
|
|
// Pure geometry/measurement helper. It never mutates occupancy or queries TF.
|
|
class DepthVisibilityChecker
|
|
{
|
|
public:
|
|
bool prepare(robot_sensor_msgs::DepthCameraData::ConstPtr data,
|
|
const tf3::TransformStampedMsg& global_from_camera,
|
|
double min_height, double max_height, const DepthFrustumConfig& config);
|
|
DepthVisibilityResult classify(const Eigen::Vector3d& lower,
|
|
const Eigen::Vector3d& upper) const;
|
|
|
|
/**
|
|
* @brief Certifies the measured evidence points of one voxel [global frame, m].
|
|
*
|
|
* Free only when every point projects with its projection_margin_px patch fully inside
|
|
* the usable image, every patch pixel holds valid depth, and that depth lies behind the
|
|
* point by more than free_margin_m. Any pixel in front keeps the voxel (Surface); an
|
|
* invalid pixel or a point out of view keeps it as Unknown. An empty list is Unknown.
|
|
*/
|
|
DepthVisibilityResult classifyPoints(const std::vector<Eigen::Vector3d>& points) const;
|
|
|
|
/// True when a global-frame point projects at least border_px inside the usable image
|
|
/// (the clear_left/right border strips are not usable). Used to gate evidence marking.
|
|
bool projectsInside(const Eigen::Vector3d& point, unsigned int border_px) const;
|
|
|
|
private:
|
|
/// Raw depth at a pixel [m]; NaN for an unsupported encoding. Caller checks bounds.
|
|
double depthAt(int u, int v) const;
|
|
|
|
robot_sensor_msgs::DepthCameraData::ConstPtr data_;
|
|
Eigen::Isometry3d camera_from_global_{Eigen::Isometry3d::Identity()};
|
|
double min_height_{0}, max_height_{0};
|
|
DepthFrustumConfig config_;
|
|
unsigned int bytes_per_pixel_{0};
|
|
};
|
|
} // namespace robot_costmap_2d
|