wip: state before depth cleanup
Uncommitted work as it ran on the KIT robot until 2026-10-20: the ROC observed_volume tuning patch on top of 63707c9 and the DepthCameraObstacleLayer plugin (clone of tsengapola/costmap_depth_camera noetic, B6 window fix), its 17 unit tests and the CMake wiring. Kept as one commit so the cleanup that follows has a recoverable starting point; not meant to be pushed.
This commit is contained in:
@@ -467,7 +467,9 @@ void Costmap2DROBOT::copyParentParameters(const std::string& costmap_name,
|
||||
"depth_valid_max_z_m", "depth_free_margin_m", "depth_projection_margin_px",
|
||||
"depth_voxel_z_resolution_m", "depth_evidence_points_enabled",
|
||||
"depth_evidence_points_per_voxel", "depth_marking_border_px",
|
||||
"depth_far_return_is_behind"})
|
||||
"depth_far_return_is_behind", "depth_reobserve_clearing",
|
||||
"depth_confirm_tolerance_m", "depth_miss_frames", "depth_no_return_weight",
|
||||
"depth_stereo_baseline_m", "depth_stereo_band_margin_px"})
|
||||
if (plugin_nh_element.hasParam(key))
|
||||
costmap_plugin_nh_element.setParam(key, YAML::Clone(plugin_nh_element.getParamValue(key)));
|
||||
robot::log_info("topic: %s data_type: %s clearing: %d marking: %d inf_is_valid: %d min_obstacle_height: %f max_obstacle_height: %f", topic.c_str(), data_type.c_str(), clearing, marking, inf_is_valid, min_obstacle_height, max_obstacle_height);
|
||||
|
||||
@@ -21,6 +21,7 @@ void DepthEvidenceStore::add(const VoxelKey& key, const Eigen::Vector3f& point,
|
||||
if (!point.allFinite())
|
||||
return;
|
||||
Entry& entry = entries_[key];
|
||||
entry.miss = 0.f;
|
||||
if (fresh || entry.count == 0)
|
||||
{
|
||||
// Slots 0..5 hold min/max of x, y, z; the first point is every extreme.
|
||||
@@ -65,6 +66,22 @@ bool DepthEvidenceStore::points(const VoxelKey& key, std::vector<Eigen::Vector3d
|
||||
return true;
|
||||
}
|
||||
|
||||
float DepthEvidenceStore::addMiss(const VoxelKey& key, float weight)
|
||||
{
|
||||
const auto it = entries_.find(key);
|
||||
if (it == entries_.end())
|
||||
return 0.f;
|
||||
it->second.miss += weight;
|
||||
return it->second.miss;
|
||||
}
|
||||
|
||||
void DepthEvidenceStore::resetMiss(const VoxelKey& key)
|
||||
{
|
||||
const auto it = entries_.find(key);
|
||||
if (it != entries_.end())
|
||||
it->second.miss = 0.f;
|
||||
}
|
||||
|
||||
void DepthEvidenceStore::erase(const VoxelKey& key)
|
||||
{
|
||||
entries_.erase(key);
|
||||
|
||||
@@ -200,6 +200,16 @@ bool projectToPixel(const Eigen::Vector3d& camera_point, const robot_sensor_msgs
|
||||
}
|
||||
} // namespace
|
||||
|
||||
int DepthVisibilityChecker::usableLeft(double z) const
|
||||
{
|
||||
int left = static_cast<int>(config_.clear_left_border_px);
|
||||
// The right imager cannot see the leftmost fx * B / z columns at depth z: no disparity there.
|
||||
if (config_.stereo_baseline_m > 0)
|
||||
left = std::max(left, static_cast<int>(std::ceil(data_->camera_info.K[0] * config_.stereo_baseline_m / z)) +
|
||||
static_cast<int>(config_.stereo_band_margin_px));
|
||||
return left;
|
||||
}
|
||||
|
||||
bool DepthVisibilityChecker::projectsInside(const Eigen::Vector3d& point, unsigned int border_px) const
|
||||
{
|
||||
if (!data_ || !point.allFinite())
|
||||
@@ -210,12 +220,55 @@ bool DepthVisibilityChecker::projectsInside(const Eigen::Vector3d& point, unsign
|
||||
return false;
|
||||
const int border = static_cast<int>(border_px);
|
||||
int u, v;
|
||||
return projectToPixel(p, data_->camera_info,
|
||||
static_cast<int>(config_.clear_left_border_px) + border,
|
||||
return projectToPixel(p, data_->camera_info, usableLeft(p.z()) + border,
|
||||
static_cast<int>(image.width) - 1 - static_cast<int>(config_.clear_right_border_px) - border,
|
||||
border, static_cast<int>(image.height) - 1 - border, u, v);
|
||||
}
|
||||
|
||||
DepthObservation DepthVisibilityChecker::observePoints(const std::vector<Eigen::Vector3d>& points) const
|
||||
{
|
||||
DepthObservation best = DepthObservation::OutOfView;
|
||||
if (!data_)
|
||||
return best;
|
||||
const auto& image = data_->depth;
|
||||
const int r = static_cast<int>(config_.projection_margin_px);
|
||||
const double tolerance = config_.confirm_tolerance_m;
|
||||
for (const auto& point : points)
|
||||
{
|
||||
if (!point.allFinite())
|
||||
continue;
|
||||
const Eigen::Vector3d p = camera_from_global_ * point;
|
||||
if (!p.allFinite() || p.z() < config_.valid_min_z_m || p.z() > config_.valid_max_z_m)
|
||||
continue;
|
||||
int u, v;
|
||||
if (!projectToPixel(p, data_->camera_info, usableLeft(p.z()) + r,
|
||||
static_cast<int>(image.width) - 1 - static_cast<int>(config_.clear_right_border_px) - r,
|
||||
r, static_cast<int>(image.height) - 1 - r, u, v))
|
||||
continue;
|
||||
// A return beyond the trusted range only proves free space for a point well inside it.
|
||||
const bool far_is_behind = config_.far_return_is_behind && p.z() + tolerance < config_.valid_max_z_m;
|
||||
bool in_front = false, behind = false;
|
||||
for (int dv = -r; dv <= r; ++dv)
|
||||
for (int du = -r; du <= r; ++du)
|
||||
{
|
||||
const double measured_z = depthAt(u + du, v + dv);
|
||||
if (!std::isfinite(measured_z) || measured_z < config_.valid_min_z_m ||
|
||||
(measured_z > config_.valid_max_z_m && !far_is_behind))
|
||||
continue; // no return: says nothing about this point
|
||||
if (std::abs(measured_z - p.z()) <= tolerance)
|
||||
return DepthObservation::Confirmed;
|
||||
if (measured_z < p.z())
|
||||
in_front = true;
|
||||
else
|
||||
behind = true;
|
||||
}
|
||||
const DepthObservation seen = in_front ? DepthObservation::Occluded :
|
||||
behind ? DepthObservation::SeenThrough : DepthObservation::NoReturn;
|
||||
best = std::max(best, seen);
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
DepthVisibilityResult DepthVisibilityChecker::classifyPoints(const std::vector<Eigen::Vector3d>& points) const
|
||||
{
|
||||
if (!data_ || points.empty())
|
||||
|
||||
Reference in New Issue
Block a user