提交 f0b63eab 编写于 作者: T Teveillan 提交者: Jiangtao Hu

add comments in hdmap_roi_filter.h (#491)

上级 483ef0cc
......@@ -17,8 +17,6 @@
namespace apollo {
namespace perception {
bool HdmapROIFilter::Filter(const pcl_util::PointCloudPtr& cloud,
const ROIFilterOptions &roi_filter_options,
pcl_util::PointIndices* roi_indices) {
......@@ -56,7 +54,7 @@ bool HdmapROIFilter::FilterWithPolygonMask(
Bitmap2D bitmap(min_p, max_p, grid_size, major_dir);
bitmap.BuildMap();
DrawPolygonInBitmap(raw_polygons, bitmap, extend_dist_);
DrawPolygonInBitmap(raw_polygons, extend_dist_, &bitmap);
// 4. Check each point whether is in roi grids in bitmap
return Bitmap2dFilter(cloud, bitmap, roi_indices);
......@@ -143,12 +141,9 @@ void HdmapROIFilter::MergeHdmapStructToPolygons(
}
bool HdmapROIFilter::Init() {
//FLAGS_work_root = "modules/perception";
//FLAGS_config_manager_path = "data/config_manager.conf";
// load model config
ConfigManager* config_manager = Singleton<ConfigManager>::Get();
std::string model_name = "HdmapROIFilter";
std::string model_name = name();
const ModelConfig* model_config = nullptr;
if (config_manager == nullptr) {
AERROR << "Failed to get config manager";
......
......@@ -52,29 +52,30 @@ public:
bool Init() override;
std::string name() const {return "HdmapROIFilter";}
/**
* @params[In] cloud: All the cloud points with local coordinates
* @params[In] roi_filter_options: Type definition in
* "../../interface/base_roi_filter.h". Contains the information
* of ROI and world to local coordinates transformation matrix.
* @params[Out] roi_indices: The indices of points within ROI
* @return true if filter points successfully, otherwise return false
*/
bool Filter(const pcl_util::PointCloudPtr& cloud,
const ROIFilterOptions &roi_filter_options,
pcl_util::PointIndices* roi_indices) override;
protected:
/**
* @brief: Draw polygons bitmap and check each point whether is in polygons
* @params[In] cloud: point cloud with local coordinates
* @params[In] map_polygons: polygons after transformed to scan polygon type
* @params[Out] roi_indices: Indices of point in roi
* @return true if filter points successfully, otherwise return false
* @brief: Draw polygons into grids in bitmap and check each point whether
* is in the grids within ROI.
*/
bool FilterWithPolygonMask(const pcl_util::PointCloudPtr& cloud,
const std::vector<PolygonType>& map_polygons,
pcl_util::PointIndices* roi_indices);
/**
* @brief: transform polygon and cloud to local corrdinates
* @params[In] cloud: point cloud with world coordinates
* @params[In] vel_pose: TODO
* @params[In] polygons_world: polygons with world coordinates
* @params[Out] polygons_loca: polygons with local coordinates
* @params[Out] cloud_local: point cloud with local coordinates
* @brief: Transform polygon points and cloud points from world coordinates
* system to local.
*/
void TransformFrame(
const pcl_util::PointCloudConstPtr& cloud,
......@@ -85,23 +86,33 @@ protected:
/**
* @brief: Get major direction. Transform polygons type to what we want.
* @params[In] map_polygons: polygons with local coordinates
* @params[In] polygons: polygons with type of vector<Matrix<double, 2, 1>>
* @return major direction as x direction
*/
MajorDirection GetMajorDirection(
const std::vector<PolygonType>& map_polygons,
std::vector<PolygonScanConverter::Polygon>* polygons);
void MergeRoadBoundariesToPolygons(const std::vector<RoadBoundary>& road_boundaries,
std::vector<PolygonDType>* polygons);
/**
* @brief: Merge left boundary and right boundary of each road into polygon
* type.
*/
void MergeRoadBoundariesToPolygons(
const std::vector<RoadBoundary>& road_boundaries,
std::vector<PolygonDType>* polygons);
void MergeHdmapStructToPolygons(const HdmapStructConstPtr& hdmap_struct_ptr,
std::vector<PolygonDType>* polygons);
/**
* @brief: Merge junction polygons and road boundaries in a vector.
*/
void MergeHdmapStructToPolygons(
const HdmapStructConstPtr& hdmap_struct_ptr,
std::vector<PolygonDType>* polygons);
bool Bitmap2dFilter(const pcl::PointCloud<pcl_util::Point>::ConstPtr in_cloud_ptr,
const Bitmap2D &bitmap,
pcl_util::PointIndices* roi_indices_ptr);
/**
* @brief: After drawing polygons into grids in bitmap. We check each point
* whether is in the grids within ROI.
*/
bool Bitmap2dFilter(
const pcl::PointCloud<pcl_util::Point>::ConstPtr in_cloud_ptr,
const Bitmap2D &bitmap, pcl_util::PointIndices* roi_indices_ptr);
// We only filter point with local coordinates x, y in [-range, range] in meters
double range_;
......
......@@ -51,14 +51,14 @@ void GetValidXRange(const typename PolygonScanConverter::Polygon &polygon,
* major_dir_grid_size + bitmap_bottom_left_p[major_dir];
}
void DrawPolygonInBitmap(const typename PolygonScanConverter::Polygon &polygon,
Bitmap2D &bitmap, const double extend_dist) {
PolygonScanConverter::DirectionMajor major_dir = bitmap.get_dir_major();
PolygonScanConverter::DirectionMajor op_major_dir = bitmap.get_op_dir_major();
double major_dir_grid_size = bitmap.get_grid_size()[major_dir];
void DrawPolygonInBitmap(const typename PolygonScanConverter::Polygon& polygon,
const double extend_dist, Bitmap2D* bitmap) {
PolygonScanConverter::DirectionMajor major_dir = bitmap->get_dir_major();
PolygonScanConverter::DirectionMajor op_major_dir = bitmap->get_op_dir_major();
double major_dir_grid_size = bitmap->get_grid_size()[major_dir];
Interval valid_x_range;
GetValidXRange(polygon, bitmap, major_dir, major_dir_grid_size, &valid_x_range);
GetValidXRange(polygon, *bitmap, major_dir, major_dir_grid_size, &valid_x_range);
std::vector<std::vector<Interval>> scans_intervals;
PolygonScanConverter polygon_scan_converter(major_dir);
......@@ -66,8 +66,8 @@ void DrawPolygonInBitmap(const typename PolygonScanConverter::Polygon &polygon,
major_dir_grid_size, &scans_intervals);
const Eigen::Vector2d& bitmap_bottom_left_p = bitmap.get_min_p();
const Eigen::Vector2d& bitmap_top_right_p = bitmap.get_max_p();
const Eigen::Vector2d& bitmap_bottom_left_p = bitmap->get_min_p();
const Eigen::Vector2d& bitmap_top_right_p = bitmap->get_max_p();
double x = valid_x_range.first;
for (size_t i = 0; i < scans_intervals.size(); x += major_dir_grid_size, ++i) {
for (const auto &scan_interval : scans_intervals[i]) {
......@@ -81,16 +81,16 @@ void DrawPolygonInBitmap(const typename PolygonScanConverter::Polygon &polygon,
if (valid_y_range.first > valid_y_range.second) {
continue;
}
bitmap.Set(x, valid_y_range.first, valid_y_range.second);
bitmap->Set(x, valid_y_range.first, valid_y_range.second);
}
}
}
void DrawPolygonInBitmap(
const std::vector<typename PolygonScanConverter::Polygon>& polygons,
Bitmap2D& bitmap, const double extend_dist) {
const double extend_dist, Bitmap2D* bitmap) {
for (const auto &polygon : polygons) {
DrawPolygonInBitmap(polygon, bitmap, extend_dist);
DrawPolygonInBitmap(polygon, extend_dist, bitmap);
}
}
......
......@@ -30,12 +30,12 @@ namespace perception {
typedef typename PolygonScanConverter::Interval Interval;
void DrawPolygonInBitmap(const PolygonScanConverter::Polygon &polygon,
Bitmap2D &bitmap, const double extend_dist);
void DrawPolygonInBitmap(const PolygonScanConverter::Polygon& polygon,
const double extend_dist, Bitmap2D* bitmap);
void DrawPolygonInBitmap(
const std::vector<PolygonScanConverter::Polygon> &polygons,
Bitmap2D &bitmap, const double extend_dist);
const std::vector<PolygonScanConverter::Polygon>& polygons,
const double extend_dist, Bitmap2D* bitmap);
/*
* @brief: Get valid x range(Major direction range)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册