Apollo  6.0
Open source self driving car software
util.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 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 #pragma once
17 
18 namespace apollo {
19 namespace perception {
20 namespace lidar {
21 
22 enum class MetaType {
23  META_UNKNOWN = 0,
24  META_SMALLMOT = 1,
25  META_BIGMOT = 2,
26  META_NONMOT = 3,
27  META_PEDESTRIAN = 4,
29 };
30 
31 const double kPI = 3.1415926535897932384626433832795;
32 
33 inline int F2I(float val, float ori, float scale) {
34  return static_cast<int>(std::floor((ori - val) * scale));
35 }
36 
37 // for axis rotated case
38 inline void GroupPc2Pixel(float pc_x, float pc_y, float scale, float range,
39  int* x, int* y) {
40  float fx = (range - (0.707107f * (pc_x + pc_y))) * scale;
41  float fy = (range - (0.707107f * (pc_x - pc_y))) * scale;
42  *x = fx < 0 ? -1 : static_cast<int>(fx);
43  *y = fy < 0 ? -1 : static_cast<int>(fy);
44 }
45 
46 // for axis aligned case
47 inline int Pc2Pixel(float in_pc, float in_range, float out_size) {
48  float inv_res = 0.5f * out_size / in_range;
49  return static_cast<int>(std::floor((in_range - in_pc) * inv_res));
50 }
51 
52 inline float Pixel2Pc(int in_pixel, float in_size, float out_range) {
53  float res = 2.0f * out_range / in_size;
54  return out_range - (static_cast<float>(in_pixel) + 0.5f) * res;
55 }
56 
57 } // namespace lidar
58 } // namespace perception
59 } // namespace apollo
int F2I(float val, float ori, float scale)
Definition: util.h:33
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void GroupPc2Pixel(float pc_x, float pc_y, float scale, float range, int *x, int *y)
Definition: util.h:38
const double kPI
Definition: util.h:31
float Pixel2Pc(int in_pixel, float in_size, float out_range)
Definition: util.h:52
MetaType
Definition: util.h:22
int Pc2Pixel(float in_pc, float in_range, float out_size)
Definition: util.h:47