Apollo 10.0
自动驾驶开放平台
mainboard.cc 文件参考
#include <string.h>
#include <list>
#include <string>
#include "cyber/common/global_data.h"
#include "cyber/common/log.h"
#include "cyber/init.h"
#include "cyber/mainboard/module_argument.h"
#include "cyber/mainboard/module_controller.h"
#include "cyber/state.h"
#include "gperftools/profiler.h"
#include "gperftools/heap-profiler.h"
#include "gperftools/malloc_extension.h"
mainboard.cc 的引用(Include)关系图:

浏览源代码.

函数

int main (int argc, char **argv)
 

函数说明

◆ main()

int main ( int  argc,
char **  argv 
)

在文件 mainboard.cc36 行定义.

36 {
37 // parse the argument
38 ModuleArgument module_args;
39 module_args.ParseArgument(argc, argv);
40
41 auto dag_list = module_args.GetDAGConfList();
42
43 std::string dag_info;
44 for (auto&& i = dag_list.begin(); i != dag_list.end(); i++) {
45 size_t pos = 0;
46 for (size_t j = 0; j < (*i).length(); j++) {
47 pos = ((*i)[j] == '/') ? j: pos;
48 }
49 if (i != dag_list.begin()) dag_info += "_";
50
51 if (pos == 0) {
52 dag_info += *i;
53 } else {
54 dag_info +=
55 (pos == (*i).length()-1) ? (*i).substr(pos): (*i).substr(pos+1);
56 }
57 }
58
59 if (module_args.GetProcessGroup() !=
60 apollo::cyber::mainboard::DEFAULT_process_group_) {
61 dag_info = module_args.GetProcessGroup();
62 }
63
64 // initialize cyber
65 apollo::cyber::Init(argv[0], dag_info);
66
67 static bool enable_cpu_profile = module_args.GetEnableCpuprofile();
68 static bool enable_mem_profile = module_args.GetEnableHeapprofile();
69 std::signal(SIGTERM, [](int sig){
71 if (enable_cpu_profile) {
72 ProfilerStop();
73 }
74
75 if (enable_mem_profile) {
76 HeapProfilerDump("Befor shutdown");
77 HeapProfilerStop();
78 }
79 });
80
81 if (module_args.GetEnableHeapprofile()) {
82 auto profile_filename = module_args.GetHeapProfileFilename();
83 HeapProfilerStart(profile_filename.c_str());
84 }
85
86 // start module
87 ModuleController controller(module_args);
88 if (!controller.Init()) {
89 controller.Clear();
90 AERROR << "module start error.";
91 return -1;
92 }
93
94 if (module_args.GetEnableCpuprofile()) {
95 auto profile_filename = module_args.GetProfileFilename();
96 ProfilerStart(profile_filename.c_str());
97 }
98
100
101 if (module_args.GetEnableCpuprofile()) {
102 ProfilerStop();
103 }
104
105 if (module_args.GetEnableHeapprofile()) {
106 HeapProfilerDump("Befor shutdown");
107 HeapProfilerStop();
108 }
109
110 controller.Clear();
111 AINFO << "exit mainboard.";
112
113 return 0;
114}
const std::list< std::string > & GetDAGConfList() const
const std::string & GetProcessGroup() const
void ParseArgument(int argc, char *const argv[])
const std::string GetHeapProfileFilename() const
const std::string GetProfileFilename() const
std::string profile_filename
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
void OnShutdown(int sig)
Definition init.cc:89
void WaitForShutdown()
Definition state.h:50
bool Init(const char *binary_name, const std::string &dag_info)
Definition init.cc:98