Apollo 11.0
自动驾驶开放平台
tl_preprocessor.h
浏览该文件的文档.
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 <map>
19#include <string>
20#include <utility>
21#include <vector>
22#include <boost/circular_buffer.hpp>
23
32
33namespace apollo {
34namespace perception {
35namespace trafficlight {
36
38 public:
43 TLPreprocessor() = default;
48 ~TLPreprocessor() = default;
56 bool Init(const TrafficLightPreprocessorInitOptions& options) override;
62 std::string Name() const override;
74 const TLPreprocessorOption& option,
75 std::vector<base::TrafficLightPtr>* lights) override;
85 bool SyncInformation(const double ts, const std::string& camera_name);
98 const TLPreprocessorOption& option,
99 const std::string& camera_name,
100 std::vector<base::TrafficLightPtr>* lights) override;
109 bool SetCameraWorkingFlag(const std::string& camera_name,
110 bool is_working) override;
119 bool GetCameraWorkingFlag(const std::string& camera_name,
120 bool* is_working) const override;
126 const std::vector<std::string>&
128 return projection_.getCameraNamesByDescendingFocalLen();
129 }
136 bool GetAlllightsOutsideFlag() const;
137
138 private:
139 void SelectCamera(
140 std::vector<base::TrafficLightPtrs>* lights_on_image_array,
141 std::vector<base::TrafficLightPtrs>* lights_outside_image_array,
142 const TLPreprocessorOption& option, std::string* selected_camera_name);
143
144 // @brief Project lights from HDMap onto long focus or short focus image plane
145 bool ProjectLights(const camera::CarPose& pose,
146 const std::string& camera_name,
147 std::vector<base::TrafficLightPtr>* lights,
148 base::TrafficLightPtrs* lights_on_image,
149 base::TrafficLightPtrs* lights_outside_image);
150
151 bool ProjectLightsAndSelectCamera(const camera::CarPose& pose,
152 const TLPreprocessorOption& option,
153 std::string* selected_camera_name,
154 std::vector<base::TrafficLightPtr>* lights);
155
156 std::string GetMinFocalLenWorkingCameraName() const;
157 std::string GetMaxFocalLenWorkingCameraName() const;
158
159 private:
160 MultiCamerasProjection projection_;
161 double last_pub_img_ts_ = 0.0;
162
163 // <timestamp, camera_name>
164 std::pair<double, std::string> selected_camera_name_;
165 std::map<std::string, bool> camera_is_working_flags_;
166 double sync_interval_seconds_ = 0.1; // some parameters from config file
167 size_t num_cameras_ = 0;
168 std::vector<base::TrafficLightPtrs> lights_on_image_array_;
169 std::vector<base::TrafficLightPtrs> lights_outside_image_array_;
170 base::TrafficLightPtrs lights_on_image_;
171 base::TrafficLightPtrs lights_outside_image_;
172 bool projections_outside_all_images_ = false;
173};
174
175} // namespace trafficlight
176} // namespace perception
177} // namespace apollo
const std::vector< std::string > & getCameraNamesByDescendingFocalLen() const
Get the camera names by descending focal len object.
bool GetAlllightsOutsideFlag() const
Get all projections outside the image.
bool Init(const TrafficLightPreprocessorInitOptions &options) override
Traffic light preprocessing initialization parameters.
~TLPreprocessor()=default
Destroy the TLPreprocessor object.
bool SyncInformation(const double ts, const std::string &camera_name)
Determine whether the selected camera is available and synchronize timestamp information.
bool SetCameraWorkingFlag(const std::string &camera_name, bool is_working) override
Set the camera working flag object.
bool GetCameraWorkingFlag(const std::string &camera_name, bool *is_working) const override
Get the camera working flag object.
std::string Name() const override
returns the name of the preprocessing plugin.
const std::vector< std::string > & GetCameraNamesByDescendingFocalLen() const override
Get the camera names by descending focal len object.
TLPreprocessor()=default
Construct a new TLPreprocessor object.
bool UpdateCameraSelection(const camera::CarPose &pose, const TLPreprocessorOption &option, std::vector< base::TrafficLightPtr > *lights) override
Select the appropriate camera for preprocessing according to the position of the vehicle and the posi...
bool UpdateLightsProjection(const camera::CarPose &pose, const TLPreprocessorOption &option, const std::string &camera_name, std::vector< base::TrafficLightPtr > *lights) override
Update the traffic light projection status and determine whether the projection exceeds the boundary ...
std::vector< TrafficLightPtr > TrafficLightPtrs
class register implement
Definition arena_queue.h:37