feat(depth): DepthCameraObstacleLayer replaces depth clearing in ObstacleLayer/VoxelLayer
Depth cameras now go through their own costmap layer instead of the frustum clearing that lived in ObstacleLayer and VoxelLayer. - Add DepthCameraObstacleLayer. It stores marked points per costmap column, clears stored points inside each camera frustum with a kd-tree check against the new cloud, keeps points outside the view, groups points with Euclidean clustering, and does not mark a 12 cm band at the frustum faces. - The layer follows the CostmapLayer contract: updateWithMax/Overwrite by combination_method, reset(), clearArea() with the usual invert semantics, footprint clearing, matchSize() and the layer mutex. So ClearCostmapRecovery and costmap resets work on it. - Add LayerType::DEPTH_CAMERA_LAYER, appended last so the existing values keep their numbers. The host's SensorGateway must dispatch PointCloud2 and DepthCameraData to it (move_base2 feature/depth-camera-layer-type). - Remove the frustum clearing code from Observation, ObservationBuffer, ObstacleLayer, VoxelLayer and costmap_2d_robot.cpp. - ObstacleLayer and VoxelLayer now reject a DepthCameraData source or frustum_clearing_enabled: true at startup, with a message that points to DepthCameraObstacleLayer. - Link PCL into the plugins library only. Add 21 unit tests for the layer (depth_camera_obstacle_layer_test). Squashed from feature/depth-observed-volume (2ca0bcc..40dc70e).
This commit is contained in:
@@ -94,65 +94,15 @@ private:
|
||||
void clearNonLethal(double wx, double wy, double w_size_x, double w_size_y, bool clear_no_info);
|
||||
virtual void raytraceFreespace(const robot_costmap_2d::Observation& clearing_observation, double* min_x, double* min_y,
|
||||
double* max_x, double* max_y);
|
||||
// bool raytraceDepthFrustum(double* min_x, double* min_y, double* max_x, double* max_y);
|
||||
bool raytraceDepthFrustum(const robot_costmap_2d::DepthCameraObservation& observation,
|
||||
double* min_x, double* min_y, double* max_x, double* max_y);
|
||||
bool readDepthMeters(const robot_sensor_msgs::Image& depth, unsigned int u, unsigned int v,
|
||||
double& depth_m, bool& is_valid) const;
|
||||
void updateDepthRayCache(unsigned int width, unsigned int height, unsigned int pixel_step,
|
||||
double fx, double fy, double cx, double cy);
|
||||
bool clipRaytraceEndpoint(double ox, double oy, double oz, double& wx, double& wy, double& wz);
|
||||
bool clearVoxelRay(double ox, double oy, double oz, double wx, double wy, double wz,
|
||||
double raytrace_range, unsigned int cell_raytrace_range,
|
||||
double* min_x, double* min_y, double* max_x, double* max_y);
|
||||
bool clearDepthColumns(double ox, double oy, double cover_distance, double far_distance,
|
||||
double min_range, double max_range, double skip_dist,
|
||||
double* min_x, double* min_y, double* max_x, double* max_y);
|
||||
bool clipColumnSegment(double& sx, double& sy, double& ex, double& ey) const;
|
||||
|
||||
|
||||
bool publish_voxel_;
|
||||
robot_voxel_grid::VoxelGrid robot_voxel_grid_;
|
||||
double z_resolution_, origin_z_;
|
||||
/// Scratch for the full-column clearing pass (config lives per observation
|
||||
/// source in DepthFrustumConfig): per depth-image pixel column, the nearest
|
||||
/// return inside the obstacle height band certifies "no obstacle in this
|
||||
/// direction closer than d". Cells along that 2D beam get their whole voxel
|
||||
/// column cleared, removing marked voxels the per-pixel 3D rays cannot
|
||||
/// reach (above the vertical FOV at close range).
|
||||
struct DepthColumnStat
|
||||
{
|
||||
double min_band_dist = -1.0; ///< horizontal distance of nearest in-band return; < 0 = none
|
||||
double azimuth = 0.0; ///< beam direction in the global frame
|
||||
double best_row_delta = std::numeric_limits<double>::infinity();
|
||||
bool has_ray = false; ///< column had at least one readable pixel
|
||||
bool in_border = false; ///< column lies in a left/right no-disparity strip
|
||||
};
|
||||
std::vector<DepthColumnStat> depth_column_stats_;
|
||||
unsigned int unknown_threshold_, mark_threshold_, size_z_;
|
||||
robot_sensor_msgs::PointCloud clearing_endpoints_;
|
||||
std::vector<unsigned char> rolling_costmap_scratch_;
|
||||
std::vector<unsigned int> rolling_voxel_scratch_;
|
||||
|
||||
struct DepthRay
|
||||
{
|
||||
unsigned int u;
|
||||
unsigned int v;
|
||||
unsigned int col; ///< pixel-column index in the cache (border column included)
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
};
|
||||
std::vector<DepthRay> depth_ray_cache_;
|
||||
unsigned int cached_column_count_ = 0;
|
||||
unsigned int cached_depth_width_ = 0;
|
||||
unsigned int cached_depth_height_ = 0;
|
||||
unsigned int cached_depth_pixel_step_ = 0;
|
||||
double cached_fx_ = 0.0;
|
||||
double cached_fy_ = 0.0;
|
||||
double cached_cx_ = 0.0;
|
||||
double cached_cy_ = 0.0;
|
||||
|
||||
inline bool worldToMap3DFloat(double wx, double wy, double wz, double& mx, double& my, double& mz)
|
||||
{
|
||||
if (wx < origin_x_ || wy < origin_y_ || wz < origin_z_)
|
||||
|
||||
Reference in New Issue
Block a user