feat(obstacle_layer): zero_is_valid for laser scans that report no return as 0

- New per-source flag zero_is_valid (default false): a 0 range is replaced by
  range_max - 0.1 mm, like inf_is_valid does for Inf, so the beam clears free
  space up to raytrace_range instead of being dropped.
- The flag is copied from the shared costmap block like inf_is_valid; it logs an
  error when set on a non-LaserScan source.
- Test obstacle_layer_scan_ranges_test covers the range replacement.
This commit is contained in:
2026-11-20 16:30:31 +07:00
parent 2695eb4e55
commit 55c7359632
5 changed files with 77 additions and 20 deletions

View File

@@ -64,8 +64,12 @@ struct CallBackInfo
std::string data_type;
std::string topic;
bool inf_is_valid;
bool zero_is_valid = false;
};
/** Replace enabled no-return ranges with range_max minus a small epsilon. */
void replaceNoReturnRanges(robot_sensor_msgs::LaserScan& scan, bool inf_is_valid, bool zero_is_valid);
class ObstacleLayer : public CostmapLayer
{
public:
@@ -107,12 +111,13 @@ protected:
const boost::shared_ptr<ObservationBuffer>& buffer);
/**
* @brief A callback to handle buffering LaserScan messages which need filtering to turn Inf values into range_max.
* @brief Buffer LaserScan messages after replacing enabled no-return ranges.
* @param message The message returned from a message notifier
* @param buffer A pointer to the observation buffer to update
*/
void laserScanValidInfCallback(const robot_sensor_msgs::LaserScan& message,
const boost::shared_ptr<ObservationBuffer>& buffer);
const boost::shared_ptr<ObservationBuffer>& buffer,
bool inf_is_valid, bool zero_is_valid);
/**
* @brief A callback to handle buffering PointCloud messages