Apollo 11.0
自动驾驶开放平台
traffic_light_tracking_component.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#pragma once
17
18#include <memory>
19#include <string>
20#include <vector>
21
22#include "modules/common_msgs/perception_msgs/traffic_light_detection.pb.h"
23#include "modules/common_msgs/v2x_msgs/v2x_traffic_light.pb.h"
24
30
31namespace apollo {
32namespace perception {
33namespace trafficlight {
34
36
38 : public cyber::Component<TrafficDetectMessage> {
39 public:
42 bool Init() override;
43 bool Proc(const std::shared_ptr<TrafficDetectMessage>& message) override;
44
45 private:
46 int InitConfig();
47 int InitV2XListener();
48 bool InitAlgorithmPlugin();
49
50 bool InternalProc(
51 const std::shared_ptr<TrafficDetectMessage const>& message);
52
53 void OnReceiveV2XMsg(
54 const std::shared_ptr<apollo::v2x::IntersectionTrafficLightData> v2x_msg);
55
56 void SyncV2XTrafficLights(camera::TrafficLightFrame* frame);
57
58 double stopline_distance(const Eigen::Matrix4d& cam_pose);
59
60 void TransRect2Box(const base::RectI& rect,
62
63 void Visualize(const camera::TrafficLightFrame& frame,
64 const std::vector<base::TrafficLightPtr>& lights) const;
65
66 bool TransformOutputMessage(
67 camera::TrafficLightFrame* frame, const std::string& camera_name,
68 std::shared_ptr<apollo::perception::TrafficLightDetection>* out_msg,
69 const std::shared_ptr<TrafficDetectMessage const>& message);
70
71 bool TransformDebugMessage(
72 const camera::TrafficLightFrame* frame,
73 std::shared_ptr<apollo::perception::TrafficLightDetection>* out_msg,
74 const std::shared_ptr<TrafficDetectMessage const>& message);
75
76 private:
77 std::mutex mutex_;
78 // tracker
80 std::string tl_tracker_name_;
81 std::string config_path_;
82 std::string config_file_;
83 std::string traffic_light_output_channel_name_;
84
85 // traffic lights
86 apollo::perception::base::TLColor detected_trafficlight_color_;
87 double cnt_r_;
88 double cnt_g_;
89 double cnt_y_;
90 double cnt_u_;
91
92 // image info.
93 int image_width_ = 1920;
94 int image_height_ = 1080;
95
96 // v2x
97 int max_v2x_msg_buff_size_ = 50;
98 std::string v2x_trafficlights_input_channel_name_;
99 double v2x_sync_interval_seconds_ = 0.1;
100 boost::circular_buffer<apollo::v2x::IntersectionTrafficLightData>
101 v2x_msg_buffer_;
102
103 // proc
104 ::google::protobuf::RepeatedPtrField<apollo::hdmap::Curve> stoplines_;
105 std::shared_ptr<trafficlight::BaseTrafficLightTracker> tracker_;
106 std::shared_ptr<
108 writer_;
109};
110
112
113} // namespace trafficlight
114} // namespace perception
115} // namespace apollo
bool Proc(const std::shared_ptr< TrafficDetectMessage > &message) override
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:657
class register implement
Definition arena_queue.h:37