Apollo  6.0
Open source self driving car software
roi_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 #include <vector>
21 
22 #include "Eigen/Dense"
23 
25 
26 namespace apollo {
27 namespace perception {
28 namespace lidar {
29 
31  public:
32  using Vec2ui = Eigen::Matrix<size_t, 2, 1>;
33  enum class DirectionMajor { XMAJOR = 0, YMAJOR = 1 };
34 
35  ROIServiceContent() = default;
36  ~ROIServiceContent() = default;
37 
38  // @brief: get a copy of this service content
39  // @param [out]: copy of the service content
40  void GetCopy(SceneServiceContent* content) const override;
41 
42  // @brief: set service content from outside
43  // @param [in]: input service content
44  void SetContent(const SceneServiceContent& content) override;
45 
46  // @brief: get service content name
47  // @return: name
48  std::string Name() const override { return "ROIServiceContent"; }
49 
50  // @brief: check bitmap bit
51  // @brief return true if bit has been set
52  inline bool CheckBit(const size_t loc, const uint64_t block) const;
53 
54  // @brief: check if point in bitmp;
55  // @return: return true if point is in roi
56  bool Check(const Eigen::Vector3d& world_point) const;
57 
58  public:
59  std::vector<uint64_t> bitmap_;
61  double cell_size_ = 0.25;
62  double range_ = 120.0;
65 };
66 
67 class ROIService : public SceneService {
68  public:
69  ROIService() = default;
70  ~ROIService() { roi_content_ref_ = nullptr; }
71 
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 "ROIService"; }
79 
80  public:
81  bool QueryIsPointInROI(const Eigen::Vector3d& world_point);
82  bool QueryIsPointInROI(const Eigen::Vector3d& world_point,
83  const ROIServiceContent& content);
84 
85  protected:
86  ROIServiceContent* roi_content_ref_ = nullptr;
87 };
88 
89 typedef std::shared_ptr<ROIServiceContent> ROIServiceContentPtr;
90 typedef std::shared_ptr<const ROIServiceContent> ROIServiceContentConstPtr;
91 
92 typedef std::shared_ptr<ROIService> ROIServicePtr;
93 typedef std::shared_ptr<const ROIService> ROIServiceConstPtr;
94 
95 } // namespace lidar
96 } // namespace perception
97 } // namespace apollo
std::string Name() const override
Definition: roi_service.h:48
DirectionMajor
Definition: roi_service.h:33
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 transform_
Definition: roi_service.h:64
bool Check(const Eigen::Vector3d &world_point) const
Eigen::Vector3d Vector3d
Definition: frame_transform.h:27
Eigen::Matrix< size_t, 2, 1 > Vec2ui
Definition: roi_service.h:32
std::vector< uint64_t > bitmap_
Definition: roi_service.h:59
double range_
Definition: roi_service.h:62
Vec2ui map_size_
Definition: roi_service.h:60
std::shared_ptr< const ROIServiceContent > ROIServiceContentConstPtr
Definition: roi_service.h:90
DirectionMajor major_dir_
Definition: roi_service.h:63
std::shared_ptr< ROIService > ROIServicePtr
Definition: roi_service.h:92
bool Init(const char *binary_name)
void GetCopy(SceneServiceContent *content) const override
std::shared_ptr< ROIServiceContent > ROIServiceContentPtr
Definition: roi_service.h:89
double cell_size_
Definition: roi_service.h:61
bool CheckBit(const size_t loc, const uint64_t block) const
Definition: roi_service.h:67
std::shared_ptr< const ROIService > ROIServiceConstPtr
Definition: roi_service.h:93
void SetContent(const SceneServiceContent &content) override
~ROIService()
Definition: roi_service.h:70
std::string Name() const override
Definition: roi_service.h:78