Apollo  6.0
Open source self driving car software
ground_service.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 #include <memory>
19 #include <string>
20 
23 
24 namespace apollo {
25 namespace perception {
26 namespace lidar {
27 
29  public:
30  GroundServiceContent() = default;
31  ~GroundServiceContent() = default;
32  // @brief: get a copy of this service content
33  // @param [out]: copy of the service content
34  void GetCopy(SceneServiceContent* content) const override;
35  // @brief: set service content from outside
36  // @param [in]: input service content
37  void SetContent(const SceneServiceContent& content) override;
38  // @brief: get service content name
39  // @return: name
40  std::string Name() const override { return "GroundServiceContent"; }
41  bool Init(double roi_x, double roi_y, uint32_t rows, uint32_t cols);
42 
43  public:
44  // @brief: mapping function from point to grid index
45  // @param [in]: point in world frame
46  // @param [out] grid index
47  // @return: false if exceeding the range
48  bool PointToGrid(const Eigen::Vector3d& world_point,
49  uint32_t* grid_index) const;
50  // @brief: compute distance of point to ground plane
51  // @param [in]: point in world frame
52  // @return: distance
53  float PointToPlaneDistance(const Eigen::Vector3d& world_point) const;
54 
55  public:
58  uint32_t rows_ = 0; // y
59  uint32_t cols_ = 0; // x
60  double resolution_x_ = 0.0;
61  double resolution_y_ = 0.0;
62  double bound_x_min_ = 0.0;
63  double bound_y_min_ = 0.0;
64  double bound_x_max_ = 0.0;
65  double bound_y_max_ = 0.0;
66 };
67 
68 class GroundService : public SceneService {
69  public:
70  GroundService() = default;
71  ~GroundService() { ground_content_ref_ = nullptr; }
72  // @brief: initialize scene service
73  // @param [in]: init options
74  bool Init(const SceneServiceInitOptions& options =
75  SceneServiceInitOptions()) override;
76  // @brief: get service name
77  // @return: name
78  std::string Name() const override { return "GroundService"; }
79 
81  return ground_content_ref_;
82  }
83 
84  public:
85  // @brief: Query point to ground distance
86  // @param [in]: point in world frame
87  // @return: distance
88  float QueryPointToGroundDistance(const Eigen::Vector3d& world_point);
89  // @brief: Query point to ground distance
90  // @param [in]: point in world frame
91  // @param [in]: outside service content
92  // @return: distance
93  float QueryPointToGroundDistance(const Eigen::Vector3d& world_point,
94  const GroundServiceContent& content);
95 
96  protected:
97  GroundServiceContent* ground_content_ref_ = nullptr;
98 };
99 
100 typedef std::shared_ptr<GroundServiceContent> GroundServiceContentPtr;
101 typedef std::shared_ptr<const GroundServiceContent>
103 
104 typedef std::shared_ptr<GroundService> GroundServicePtr;
105 typedef std::shared_ptr<const GroundService> GroundServiceConstPtr;
106 
107 } // namespace lidar
108 } // namespace perception
109 } // namespace apollo
std::shared_ptr< GroundService > GroundServicePtr
Definition: ground_service.h:104
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: scene_service.h:61
Eigen::Vector3d Vector3d
Definition: frame_transform.h:27
uint32_t cols_
Definition: ground_service.h:59
void SetContent(const SceneServiceContent &content) override
GroundGrid grid_
Definition: ground_service.h:56
std::shared_ptr< GroundServiceContent > GroundServiceContentPtr
Definition: ground_service.h:100
double resolution_y_
Definition: ground_service.h:61
GroundServiceContent * GetGroundServiceContent() const
Definition: ground_service.h:80
double bound_y_max_
Definition: ground_service.h:65
Definition: ground_struct.h:31
uint32_t rows_
Definition: ground_service.h:58
Eigen::Vector3d grid_center_
Definition: ground_service.h:57
std::shared_ptr< const GroundServiceContent > GroundServiceContentConstPtr
Definition: ground_service.h:102
void GetCopy(SceneServiceContent *content) const override
~GroundService()
Definition: ground_service.h:71
double bound_x_max_
Definition: ground_service.h:64
std::string Name() const override
Definition: ground_service.h:40
bool Init(double roi_x, double roi_y, uint32_t rows, uint32_t cols)
std::shared_ptr< const GroundService > GroundServiceConstPtr
Definition: ground_service.h:105
Definition: ground_service.h:68
bool PointToGrid(const Eigen::Vector3d &world_point, uint32_t *grid_index) const
double bound_y_min_
Definition: ground_service.h:63
std::string Name() const override
Definition: ground_service.h:78
float PointToPlaneDistance(const Eigen::Vector3d &world_point) const
double bound_x_min_
Definition: ground_service.h:62
double resolution_x_
Definition: ground_service.h:60