23 #include "cyber/component/component.h" 24 #include "modules/drivers/proto/sensor_image.pb.h" 25 #include "modules/map/proto/map_geometry.pb.h" 26 #include "modules/map/proto/map_signal.pb.h" 31 #include "modules/perception/onboard/proto/trafficlights_perception_component.pb.h" 33 #include "modules/perception/proto/perception_obstacle.pb.h" 34 #include "modules/perception/proto/traffic_light_detection.pb.h" 35 #include "modules/transform/buffer.h" 37 #include "modules/v2x/common/v2x_proxy_gflags.h" 38 #include "modules/v2x/proto/v2x_traffic_light.pb.h" 41 namespace perception {
58 int InitAlgorithmPlugin();
59 int InitCameraListeners();
60 int InitCameraFrame();
62 int InitV2XListener();
64 void OnReceiveImage(
const std::shared_ptr<apollo::drivers::Image> image,
65 const std::string& camera_name);
68 const std::shared_ptr<apollo::v2x::IntersectionTrafficLightData> v2x_msg);
71 std::vector<apollo::hdmap::Signal>* signals);
73 bool VerifyLightsProjection(
const double& ts,
75 const std::string& camera_name,
78 bool UpdateCameraSelection(
double timestamp,
82 bool CheckCameraImageStatus(
double timestamp,
double interval,
83 const std::string& camera_name);
87 bool GetPoseFromTF(
const double timestamp,
const std::string& frame_id,
88 const std::string& child_frame_id,
89 Eigen::Matrix4d* pose_matrix);
91 double stopline_distance(
const Eigen::Matrix4d& cam_pose);
92 bool TransformOutputMessage(
94 std::shared_ptr<apollo::perception::TrafficLightDetection>* out_msg);
96 bool TransformDebugMessage(
98 std::shared_ptr<apollo::perception::TrafficLightDetection>* out_msg);
99 void SendSimulationMsg();
100 void GenerateTrafficLights(
101 const std::vector<apollo::hdmap::Signal>& signals,
102 std::vector<base::TrafficLightPtr>* traffic_lights);
104 apollo::perception::TrafficLightBox* box);
108 const std::vector<base::TrafficLightPtr>& lights)
const;
114 std::shared_ptr<camera::TLPreprocessor> preprocessor_;
119 std::string tf2_frame_id_;
120 std::string tf2_child_frame_id_;
121 double tf2_timeout_second_ = 0.01;
123 Buffer* tf2_buffer_ = Buffer::Instance();
125 std::vector<std::string> camera_names_;
126 std::vector<std::string> input_camera_channel_names_;
128 std::map<std::string, std::shared_ptr<TransformWrapper>>
129 camera2world_trans_wrapper_map_;
131 std::map<std::string, int> image_border_sizes_;
133 std::vector<std::shared_ptr<cyber::Node>> camera_listener_nodes_;
135 double last_sub_tf_ts_ = 0.0;
137 std::map<std::string, double> last_sub_camera_image_ts_;
139 double query_tf_interval_seconds_ = 0.0;
140 double image_timestamp_offset_ = 0.0;
141 int max_process_image_fps_ = 10;
142 double proc_interval_seconds_ = 0.0;
143 double check_image_status_interval_thresh_ = 1.0;
145 double last_query_tf_ts_ = 0.0;
146 double last_proc_image_ts_ = 0.0;
148 double image_sys_ts_diff_threshold_ = 0.5;
151 double last_signals_ts_ = -1.0;
152 double valid_hdmap_interval_ = 1.5;
153 double forward_distance_to_query_signals = 150.0;
154 std::vector<apollo::hdmap::Signal> last_signals_;
157 int image_width_ = 1920;
158 int image_height_ = 1080;
159 int image_channel_num_ = 3;
160 int image_data_size_ = -1;
161 int frame_index_ = 0;
162 int default_image_border_size_ = 100;
165 bool enable_undistortion_ =
false;
169 std::map<std::string, std::shared_ptr<camera::DataProvider>>
178 std::unique_ptr<camera::TrafficLightCameraPerception> traffic_light_pipeline_;
179 ::google::protobuf::RepeatedPtrField<apollo::hdmap::Curve> stoplines_;
182 std::string simulation_channel_name_;
183 std::string traffic_light_output_channel_name_;
186 apollo::cyber::Writer<apollo::perception::TrafficLightDetection>>
197 std::string v2x_trafficlights_input_channel_name_;
198 double v2x_sync_interval_seconds_ = 0.1;
199 int max_v2x_msg_buff_size_ = 50;
200 boost::circular_buffer<apollo::v2x::IntersectionTrafficLightData>
Definition: camera_frame.h:33
Definition: base_camera_perception.h:28
TrafficLightsPerceptionComponent()=default
Definition: tl_preprocessor.h:42
Definition: trafficlights_perception_component.h:44
Definition: data_provider.h:34
Definition: tl_preprocessor.h:36
CYBER_REGISTER_COMPONENT(FusionCameraDetectionComponent)
Definition: base_camera_perception.h:34
TrafficLightsPerceptionComponent & operator=(const TrafficLightsPerceptionComponent &)=delete
TLColor
Definition: traffic_light.h:28
~TrafficLightsPerceptionComponent()=default