Apollo 10.0
自动驾驶开放平台
apollo::v2x::V2xProxy类 参考

#include <v2x_proxy.h>

apollo::v2x::V2xProxy 的协作图:

Public 成员函数

 V2xProxy (std::shared_ptr<::apollo::hdmap::HDMap > hdmap=nullptr)
 
 ~V2xProxy ()
 
bool InitFlag ()
 
void stop ()
 
bool GetRsuListFromFile (const std::string &filename, std::set< std::string > *whitelist)
 

详细描述

在文件 v2x_proxy.h41 行定义.

构造及析构函数说明

◆ V2xProxy()

apollo::v2x::V2xProxy::V2xProxy ( std::shared_ptr<::apollo::hdmap::HDMap hdmap = nullptr)
explicit

在文件 v2x_proxy.cc49 行定义.

50 : node_(::apollo::cyber::CreateNode("v2x_proxy")), exit_(false) {
51 if (node_ == nullptr) {
52 AFATAL << "Create v2x proxy node failed.";
53 exit(1);
54 }
55 internal_ = std::make_shared<InternalData>();
56 hdmap_ = std::make_shared<::apollo::hdmap::HDMap>();
57 const auto hdmap_file = apollo::hdmap::BaseMapFile();
58 if (0 != hdmap_->LoadMapFromFile(hdmap_file)) {
59 AERROR << "Failed to load hadmap file: " << hdmap_file;
60 return;
61 }
62 ::apollo::cyber::TimerOption v2x_car_status_timer_option;
63 v2x_car_status_timer_option.period =
64 static_cast<uint32_t>((1000 + FLAGS_v2x_car_status_timer_frequency - 1) /
65 FLAGS_v2x_car_status_timer_frequency);
66 v2x_car_status_timer_option.callback = [this]() {
67 this->OnV2xCarStatusTimer();
68 };
69 v2x_car_status_timer_option.oneshot = false;
70 v2x_car_status_timer_.reset(
71 new ::apollo::cyber::Timer(v2x_car_status_timer_option));
72 os_interface_.reset(new OsInterFace());
73 obu_interface_.reset(new ObuInterFaceGrpcImpl());
74 recv_thread_.reset(new std::thread([this]() {
75 while (!exit_.load()) {
76 this->RecvTrafficlight();
77 }
78 }));
79 CHECK(!!hdmap_ && !!v2x_car_status_timer_);
80 CHECK(!!os_interface_ && !!obu_interface_);
81 CHECK(os_interface_->InitFlag() && obu_interface_->InitFlag());
82 planning_thread_.reset(new std::thread([this]() {
83 while (!exit_.load()) {
84 this->RecvOsPlanning();
85 }
86 }));
87 obs_thread_.reset(new std::thread([this]() {
88 while (!exit_.load()) {
89 std::shared_ptr<::apollo::v2x::V2XObstacles> obs = nullptr;
90 this->obu_interface_->GetV2xObstaclesFromObu(&obs); // Blocked
91 this->os_interface_->SendV2xObstacles2Sys(obs);
92 }
93 }));
94 v2x_car_status_timer_->Start();
95 GetRsuListFromFile(FLAGS_rsu_whitelist_name, &rsu_list_);
96 init_flag_ = true;
97}
bool GetRsuListFromFile(const std::string &filename, std::set< std::string > *whitelist)
Definition v2x_proxy.cc:99
#define AERROR
Definition log.h:44
#define AFATAL
Definition log.h:45
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
Definition cyber.cc:33
std::string BaseMapFile()
get base map file path from flags.
Definition hdmap_util.cc:47
The options of timer
Definition timer.h:32
uint32_t period
The period of the timer, unit is ms max: 512 * 64 min: 1
Definition timer.h:54
bool oneshot
True: perform the callback only after the first timing cycle False: perform the callback every timed ...
Definition timer.h:63
std::function< void()> callback
The task that the timer needs to perform
Definition timer.h:57

◆ ~V2xProxy()

apollo::v2x::V2xProxy::~V2xProxy ( )

在文件 v2x_proxy.cc37 行定义.

37 {
38 if (recv_thread_ != nullptr && recv_thread_->joinable()) {
39 recv_thread_->join();
40 }
41 if (planning_thread_ != nullptr && planning_thread_->joinable()) {
42 planning_thread_->join();
43 }
44 if (obs_thread_ != nullptr && obs_thread_->joinable()) {
45 obs_thread_->join();
46 }
47}

成员函数说明

◆ GetRsuListFromFile()

bool apollo::v2x::V2xProxy::GetRsuListFromFile ( const std::string &  filename,
std::set< std::string > *  whitelist 
)

在文件 v2x_proxy.cc99 行定义.

100 {
101 if (nullptr == whitelist) {
102 return false;
103 }
104 std::ifstream input_file(filename);
105 if (!input_file) {
106 return false;
107 }
108 std::string line;
109 while (getline(input_file, line)) {
110 whitelist->insert(line);
111 }
112 return !whitelist->empty();
113}

◆ InitFlag()

bool apollo::v2x::V2xProxy::InitFlag ( )

在文件 v2x_proxy.cc115 行定义.

115{ return init_flag_; }

◆ stop()

void apollo::v2x::V2xProxy::stop ( )
inline

在文件 v2x_proxy.h58 行定义.

58 {
59 exit_ = true;
60 v2x_car_status_timer_->Stop();
61 obu_status_timer_->Stop();
62 rsu_whitelist_timer_->Stop();
63 }

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