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>();
58 if (0 != hdmap_->LoadMapFromFile(hdmap_file)) {
59 AERROR <<
"Failed to load hadmap file: " << hdmap_file;
60 return;
61 }
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);
91 this->os_interface_->SendV2xObstacles2Sys(obs);
92 }
93 }));
94 v2x_car_status_timer_->Start();
96 init_flag_ = true;
97}
bool GetRsuListFromFile(const std::string &filename, std::set< std::string > *whitelist)
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
std::string BaseMapFile()
get base map file path from flags.
uint32_t period
The period of the timer, unit is ms max: 512 * 64 min: 1
bool oneshot
True: perform the callback only after the first timing cycle False: perform the callback every timed ...
std::function< void()> callback
The task that the timer needs to perform