Apollo 10.0
自动驾驶开放平台
ros_bridge.cc 文件参考
#include <vector>
#include "cyber/ros_bridge/common/macros.h"
#include "cyber/ros_bridge/proto/ros_bridge_conf.pb.h"
#include "cyber/cyber.h"
#include "cyber/plugin_manager/plugin_manager.h"
#include "cyber/ros_bridge/common/bridge_argument.h"
#include "cyber/ros_bridge/common/ros_bridge_gflags.h"
#include "cyber/ros_bridge/common/utils.h"
#include "cyber/ros_bridge/converter_base/message_converter.h"
#include "gperftools/heap-profiler.h"
#include "gperftools/malloc_extension.h"
#include "gperftools/profiler.h"
ros_bridge.cc 的引用(Include)关系图:

浏览源代码.

函数

int main (int argc, char **argv)
 

函数说明

◆ main()

int main ( int  argc,
char **  argv 
)

在文件 ros_bridge.cc42 行定义.

42 {
43 apollo::cyber::BridgeConf bridge_conf;
44 std::vector<std::shared_ptr<MessageConverter>> converter_list_;
45
46 BridgeArgument bridge_args;
47 bridge_args.ParseArgument(argc, argv);
48
49 apollo::cyber::Init(argv[0]);
50
51#ifdef RCLCPP__RCLCPP_HPP_
52 rclcpp::init(argc, argv);
53#endif
54
55 PluginManager::Instance()->LoadInstalledPlugins();
56
57 auto config_path =
58 GetAbsolutePath(WorkRoot(), apollo::cyber::FLAGS_bridge_conf_path);
59 if (!GetProtoFromFile(config_path, &bridge_conf)) {
60 AERROR << "parse ros bridge config failed!";
61 return 1;
62 }
63
64 for (int i = 0; i < bridge_conf.converter_size(); i++) {
65 auto converter =
66 PluginManager::Instance()->CreateInstance<MessageConverter>(
68 bridge_conf.converter(i).type()));
69 ACHECK(converter->Init())
70 << "Can not init converter " << bridge_conf.converter(i).type();
71 converter_list_.push_back(converter);
72 }
73
74 if (bridge_args.GetEnableCpuprofile()) {
75 auto profile_filename = bridge_args.GetProfileFilename();
76 ProfilerStart(profile_filename.c_str());
77 }
78
79 if (bridge_args.GetEnableHeapprofile()) {
80 auto profile_filename = bridge_args.GetHeapProfileFilename();
81 HeapProfilerStart(profile_filename.c_str());
82 }
83
85#ifdef RCLCPP__RCLCPP_HPP_
86 rclcpp::shutdown();
87#endif
88
89 if (bridge_args.GetEnableCpuprofile()) {
90 ProfilerStop();
91 }
92
93 if (bridge_args.GetEnableHeapprofile()) {
94 HeapProfilerDump("Befor shutdown");
95 HeapProfilerStop();
96 }
97
98 return 0;
99}
const bool GetEnableHeapprofile() const
const std::string GetHeapProfileFilename() const
const bool GetEnableCpuprofile() const
const std::string GetProfileFilename() const
void ParseArgument(int argc, char *const argv[])
std::string profile_filename
#define ACHECK(cond)
Definition log.h:80
#define AERROR
Definition log.h:44
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
std::string GetAbsolutePath(const std::string &prefix, const std::string &relative_path)
Get absolute path by concatenating prefix and relative_path.
Definition file.cc:179
const std::string WorkRoot()
Definition environment.h:40
std::string GetFullConverterClassName(const std::string &class_name)
Definition utils.h:24
void WaitForShutdown()
Definition state.h:50
bool Init(const char *binary_name, const std::string &dag_info)
Definition init.cc:98
repeated PluginDeclareInfo converter