Apollo  6.0
Open source self driving car software
obu_interface_grpc_impl.h
Go to the documentation of this file.
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 <condition_variable>
25 #include <memory>
26 #include <mutex>
27 #include <thread>
28 
29 #include <grpc++/grpc++.h>
30 
34 
35 namespace apollo {
36 namespace v2x {
37 
39  public:
42 
43  /* function that init grpc server
44  */
45  bool InitialServer() override;
46 
47  /* function that init grpc client
48  */
49  bool InitialClient() override;
50 
51  /* function that get v2x traffic light through grpc
52  @param output return latest v2x traffic light
53  */
55  std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight> *msg) override;
56 
58  std::shared_ptr<::apollo::v2x::V2XObstacles> *msg) override;
59 
60  void GetV2xRsiFromObu(
61  std::shared_ptr<::apollo::v2x::obu::ObuRsi> *msg) override;
62 
63  /* function that send car status through grpc
64  @param input send car status msg to grpc
65  */
66  void SendCarStatusToObu(
67  const std::shared_ptr<::apollo::v2x::CarStatus> &msg) override;
68 
69  /* function that return init flag
70  */
71  bool InitFlag() { return init_succ_; }
72 
73  private:
74  /* thread function that run server
75  */
76  void ThreadRunServer();
77 
78  std::shared_ptr<GrpcClientImpl> grpc_client_;
79  std::unique_ptr<GrpcServerImpl> grpc_server_;
80  std::unique_ptr<grpc::Server> server_;
81 
82  bool cli_init_ = false;
83  bool srv_init_ = false;
84 
85  bool init_succ_ = false;
86  bool exit_flag_ = false;
87  std::unique_ptr<std::thread> thread_grpc_;
88  std::mutex mutex_;
89  std::condition_variable condition_;
90 };
91 
92 } // namespace v2x
93 } // namespace apollo
Definition: obu_interface_grpc_impl.h:38
define v2x proxy module and onboard unit interface grpc implement
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
void SendCarStatusToObu(const std::shared_ptr<::apollo::v2x::CarStatus > &msg) override
bool InitFlag()
Definition: obu_interface_grpc_impl.h:71
void GetV2xTrafficLightFromObu(std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight > *msg) override
void GetV2xRsiFromObu(std::shared_ptr<::apollo::v2x::obu::ObuRsi > *msg) override
define v2x proxy module and onboard unit interface base class
void GetV2xObstaclesFromObu(std::shared_ptr<::apollo::v2x::V2XObstacles > *msg) override
Definition: obu_interface_abstract_class.h:38
define v2x proxy module and onboard unit interface grpc implement