Apollo 10.0
自动驾驶开放平台
ManualTrafficLight类 参考final
类 ManualTrafficLight 继承关系图:
ManualTrafficLight 的协作图:

Public 成员函数

bool Init ()
 
bool Proc ()
 The Proc logic of the component, which called by the CyberRT frame.
 
- Public 成员函数 继承自 apollo::cyber::TimerComponent
 TimerComponent ()
 
 ~TimerComponent () override
 
bool Initialize (const TimerComponentConfig &config) override
 init the component by protobuf object.
 
void Clear () override
 
bool Process ()
 
uint32_t GetInterval () const
 
- Public 成员函数 继承自 apollo::cyber::ComponentBase
virtual ~ComponentBase ()
 
virtual bool Initialize (const ComponentConfig &config)
 
virtual void Shutdown ()
 
template<typename T >
bool GetProtoConfig (T *config) const
 

额外继承的成员函数

- Public 类型 继承自 apollo::cyber::ComponentBase
template<typename M >
using Reader = cyber::Reader< M >
 
- Protected 成员函数 继承自 apollo::cyber::ComponentBase
const std::string & ConfigFilePath () const
 
void LoadConfigFiles (const ComponentConfig &config)
 
void LoadConfigFiles (const TimerComponentConfig &config)
 
- Protected 属性 继承自 apollo::cyber::ComponentBase
std::atomic< bool > is_shutdown_ = {false}
 
std::shared_ptr< Node > node_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 manual_traffic_light.cc 第 44 行定义.

成员函数说明

◆ Init()

bool ManualTrafficLight::Init ( )
inlinevirtual

实现了 apollo::cyber::ComponentBase.

在文件 manual_traffic_light.cc 第 46 行定义.

46 {
47 localization_reader_ = node_->CreateReader<LocalizationEstimate>(
48 FLAGS_localization_topic,
49 [this](const std::shared_ptr<LocalizationEstimate> &localization) {
50 ADEBUG << "Received chassis data: run chassis callback.";
51 OnLocalization(localization);
52 });
53
54 traffic_light_detection_writer_ =
55 node_->CreateWriter<TrafficLightDetection>(
56 FLAGS_traffic_light_detection_topic);
57
58 return true;
59 }
std::shared_ptr< Node > node_
#define ADEBUG
Definition log.h:41

◆ Proc()

bool ManualTrafficLight::Proc ( )
inlinevirtual

The Proc logic of the component, which called by the CyberRT frame.

返回
returns true if successful, otherwise returns false

实现了 apollo::cyber::TimerComponent.

在文件 manual_traffic_light.cc 第 61 行定义.

61 {
62 std::vector<SignalInfoConstPtr> signals;
63 bool result = false;
64 if (FLAGS_all_lights) {
65 result = GetAllTrafficLights(&signals);
66 } else {
67 result = GetTrafficLightsWithinDistance(&signals);
68 }
69 if (!result) {
70 ADEBUG << "Failed to get traffic signals from current location on map";
71 } else {
72 ADEBUG << "Received " << signals.size() << " traffic lights";
73 }
74 std::vector<std::string> signal_ids;
75 for (const auto &ptr : signals) {
76 signal_ids.emplace_back(ptr->id().id());
77 }
78 if (IsDifferent(prev_traffic_lights_, signal_ids)) {
79 prev_traffic_lights_ =
80 std::unordered_set<std::string>(signal_ids.begin(), signal_ids.end());
81 updated_ = true;
82 }
83 TrafficLightDetection traffic_light_detection;
84 TrafficLight::Color color = GetKeyBoardColorInput();
85 ADEBUG << "Color: " << TrafficLight::Color_Name(color);
86 if (updated_) {
87 updated_ = false;
88 const char *print_color = is_green_ ? ANSI_GREEN : ANSI_RED;
89 std::cout << print_color
90 << "Current Light: " << (is_green_ ? "GREEN" : "RED");
91 if (signal_ids.empty()) {
92 if (FLAGS_all_lights) {
93 std::cout << " No lights in the map";
94 } else {
95 std::cout << " No lights in the next " << FLAGS_traffic_light_distance
96 << " meters";
97 }
98 } else {
99 if (signal_ids.size() < 5) {
100 std::cout << " IDs: " << absl::StrJoin(signal_ids, " ");
101 } else {
102 std::cout << " IDs: "
103 << absl::StrJoin(signal_ids.begin(), signal_ids.begin() + 4,
104 " ")
105 << " ...";
106 }
107 }
108 std::cout << std::endl
109 << ANSI_RESET << "Press 'c' to change" << std::endl
110 << std::endl;
111 }
112 CreateTrafficLightDetection(signals, color, &traffic_light_detection);
113 traffic_light_detection_writer_->Write(traffic_light_detection);
114 return true;
115 }
constexpr char ANSI_RESET[]
Definition color.h:36
constexpr char ANSI_RED[]
Definition color.h:30
constexpr char ANSI_GREEN[]
Definition color.h:31

该类的文档由以下文件生成: