Apollo 11.0
自动驾驶开放平台
background_map.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <algorithm>
20#include <limits>
21#include <string>
22#include <vector>
23
24#include "cyber/common/log.h"
27
28namespace apollo {
29namespace perception {
30namespace lidar {
31
32struct BgNode {
33 int point_number = 0;
34 bool is_valid = false;
35 int id = -1;
36 // node feature
37 float mean_height = 0.0;
38 float max_height = std::numeric_limits<float>::min();
39 float mean_intensity = 0.0;
40 std::vector<int> pc_semantic_types = {0, 0, 0, 0, 0, 0, 0, 0, 0};
41 std::vector<int> pc_motion_types = {0, 0, 0};
42 bool is_important = false;
43};
44
46public:
47 BackgroundMap() = default;
48 ~BackgroundMap() = default;
59 bool Init(int width, int height, float resolution, float height_threshold);
60
61 bool Init(float xmin, float xmax, float ymin, float ymax, float resolution, float height_threshold);
69 bool Reset(size_t point_number);
77 bool UpdateMap(LidarFrame* frame);
85 bool UpdateMask(LidarFrame* frame);
93 bool UpdateNodes(LidarFrame* frame);
102 void GetNodeCoord(float x, float y, int* grid_x, int* grid_y);
108 int id() {
109 return valid_node_number_;
110 }
111
112public:
113 // background node, size: width * height
114 std::vector<BgNode> bg_nodes_;
115 // node index in bg_nodes_ for each point
116 std::vector<size_t> point_idx_;
117 // node importance for each point
118 std::vector<size_t> point_importance_;
119 // non-ground / non-foreground points
120 std::vector<bool> point_mask_;
121
122private:
123 size_t point_number_;
124 int width_;
125 int height_;
126 float resolution_;
127 float height_threshold_;
128 size_t valid_node_number_;
129
130 float xmin_;
131 float xmax_;
132 float ymin_;
133 float ymax_;
134};
135
136} // namespace lidar
137} // namespace perception
138} // namespace apollo
bool UpdateMask(LidarFrame *frame)
Update point mask and point index
bool UpdateMap(LidarFrame *frame)
Update map, update mask and node
bool UpdateNodes(LidarFrame *frame)
Update node feature based on points
bool Init(int width, int height, float resolution, float height_threshold)
Init background map
bool Reset(size_t point_number)
Reset all data
void GetNodeCoord(float x, float y, int *grid_x, int *grid_y)
Get Node Coordinate based on point
class register implement
Definition arena_queue.h:37