Apollo 11.0
自动驾驶开放平台
os_interface.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
22#pragma once
23
24#include <chrono>
25#include <cstring>
26#include <iostream>
27#include <memory>
28#include <mutex>
29#include <string>
30
31#include "modules/common_msgs/localization_msgs/localization.pb.h"
32#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
33#include "modules/common_msgs/planning_msgs/planning.pb.h"
34#include "modules/v2x/proto/v2x_obstacles.pb.h"
35#include "modules/v2x/proto/v2x_obu_rsi.pb.h"
36#include "modules/v2x/proto/v2x_obu_traffic_light.pb.h"
37#include "modules/common_msgs/v2x_msgs/v2x_traffic_light.pb.h"
38
39#include "cyber/cyber.h"
41
42namespace apollo {
43namespace v2x {
45 public:
47
49
50 bool InitFlag() { return init_flag_; }
51
53 const std::shared_ptr<::apollo::localization::LocalizationEstimate> &msg);
54
56 const std::shared_ptr<::apollo::planning::ADCTrajectory> &msg);
57
59 const std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight> &msg);
60
62 const std::shared_ptr<::apollo::v2x::IntersectionTrafficLightData> &msg);
63
65 const std::shared_ptr<apollo::v2x::V2XObstacles> &msg);
66
68 const std::shared_ptr<::apollo::perception::TrafficLightDetection> &msg);
69
70 private:
71 template <typename MessageT>
72 void SendMsgToOs(::apollo::cyber::Writer<MessageT> *writer,
73 const std::shared_ptr<MessageT> &msg) {
74 if (nullptr == writer) {
75 return;
76 }
77 writer->Write(msg);
78 }
79
80 bool InitReaders();
81
82 bool InitWriters();
83
84 std::unique_ptr<::apollo::cyber::Node> node_ = nullptr;
85 std::shared_ptr<
87 localization_reader_ = nullptr;
88 std::shared_ptr<::apollo::cyber::Reader<::apollo::planning::ADCTrajectory>>
89 planning_reader_ = nullptr;
90 std::shared_ptr<::apollo::cyber::Writer<::apollo::v2x::obu::ObuTrafficLight>>
91 v2x_obu_traffic_light_writer_ = nullptr;
92 std::shared_ptr<
94 v2x_traffic_light_writer_ = nullptr;
95 std::shared_ptr<
97 v2x_traffic_light_hmi_writer_ = nullptr;
98 std::shared_ptr<::apollo::cyber::Writer<::apollo::v2x::V2XObstacles>>
99 v2x_obstacles_internal_writer_ = nullptr;
101 ::apollo::planning::ADCTrajectory adc_trajectory_msg_;
102 bool flag_planning_new_ = false;
103
104 mutable std::mutex mutex_localization_;
105 mutable std::mutex mutex_planning_;
106 mutable std::condition_variable cond_planning_;
107
108 bool init_flag_ = false;
109};
110} // namespace v2x
111} // namespace apollo
Reader subscribes a channel, it has two main functions:
Definition reader.h:69
virtual bool Write(const MessageT &msg)
Write a MessageT instance
Definition writer.h:166
void GetPlanningAdcFromOs(const std::shared_ptr<::apollo::planning::ADCTrajectory > &msg)
void GetLocalizationFromOs(const std::shared_ptr<::apollo::localization::LocalizationEstimate > &msg)
void SendV2xTrafficLightToOs(const std::shared_ptr<::apollo::v2x::IntersectionTrafficLightData > &msg)
void SendV2xTrafficLight4Hmi2Sys(const std::shared_ptr<::apollo::perception::TrafficLightDetection > &msg)
void SendV2xObstacles2Sys(const std::shared_ptr< apollo::v2x::V2XObstacles > &msg)
void SendV2xObuTrafficLightToOs(const std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight > &msg)
class register implement
Definition arena_queue.h:37
The gflags used by v2x proxy module