Apollo  6.0
Open source self driving car software
udp_bridge_sender_component.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 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 
17 #pragma once
18 
19 #include <netinet/in.h>
20 #include <sys/socket.h>
21 
22 #include <cstdlib>
23 #include <iostream>
24 #include <memory>
25 #include <string>
26 #include <vector>
27 
28 #include "modules/bridge/proto/udp_bridge_remote_info.pb.h"
29 #include "modules/planning/proto/planning.pb.h"
30 
33 #include "cyber/cyber.h"
34 #include "cyber/init.h"
35 #include "cyber/io/session.h"
40 
41 namespace apollo {
42 namespace bridge {
43 
44 #define BRIDGE_COMPONENT_REGISTER(pb_msg) \
45  CYBER_REGISTER_COMPONENT(UDPBridgeSenderComponent<pb_msg>)
46 
47 template <typename T>
48 class UDPBridgeSenderComponent final : public cyber::Component<T> {
49  public:
51  : monitor_logger_buffer_(common::monitor::MonitorMessageItem::CONTROL) {}
52 
53  bool Init() override;
54  bool Proc(const std::shared_ptr<T> &pb_msg) override;
55 
56  std::string Name() const { return FLAGS_bridge_module_name; }
57 
58  private:
59  common::monitor::MonitorLogBuffer monitor_logger_buffer_;
60  unsigned int remote_port_ = 0;
61  std::string remote_ip_ = "";
62  std::string proto_name_ = "";
63  std::mutex mutex_;
64 };
65 
66 BRIDGE_COMPONENT_REGISTER(planning::ADCTrajectory)
67 BRIDGE_COMPONENT_REGISTER(localization::LocalizationEstimate)
68 
69 } // namespace bridge
70 } // namespace apollo
UDPBridgeSenderComponent()
Definition: udp_bridge_sender_component.h:50
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool Proc(const std::shared_ptr< T > &pb_msg) override
std::string Name() const
Definition: udp_bridge_sender_component.h:56
The class of MonitorLogBuffer.
This class help collect MonitorMessage pb to monitor topic. The messages can be published automatical...
Definition: monitor_log_buffer.h:60
#define BRIDGE_COMPONENT_REGISTER(pb_msg)
Definition: udp_bridge_sender_component.h:44
Some util functions.
Definition: udp_bridge_sender_component.h:48
The Component can process up to four channels of messages. The message type is specified when the com...
Definition: component.h:58