Apollo
10.0
自动驾驶开放平台
monitor.cc
浏览该文件的文档.
1
/******************************************************************************
2
* Copyright 2017 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
#include "
modules/monitor/monitor.h
"
17
18
#include "
cyber/time/clock.h
"
19
#include "
modules/monitor/common/monitor_manager.h
"
20
#include "
modules/monitor/hardware/esdcan_monitor.h
"
21
#include "
modules/monitor/hardware/gps_monitor.h
"
22
#include "
modules/monitor/hardware/resource_monitor.h
"
23
#include "
modules/monitor/hardware/socket_can_monitor.h
"
24
#include "
modules/monitor/software/camera_monitor.h
"
25
#include "
modules/monitor/software/channel_monitor.h
"
26
#include "
modules/monitor/software/functional_safety_monitor.h
"
27
#include "
modules/monitor/software/latency_monitor.h
"
28
#include "
modules/monitor/software/localization_monitor.h
"
29
#include "
modules/monitor/software/module_monitor.h
"
30
#include "
modules/monitor/software/process_monitor.h
"
31
#include "
modules/monitor/software/recorder_monitor.h
"
32
#include "
modules/monitor/software/summary_monitor.h
"
33
34
DEFINE_bool
(enable_functional_safety,
true
,
35
"Whether to enable functional safety check."
);
36
37
namespace
apollo
{
38
namespace
monitor {
39
40
bool
Monitor::Init
() {
41
MonitorManager::Instance()->Init(
node_
);
42
43
// Only the one CAN card corresponding to current mode will take effect.
44
runners_.emplace_back(
new
EsdCanMonitor
());
45
runners_.emplace_back(
new
SocketCanMonitor
());
46
// To enable the GpsMonitor, you must add FLAGS_gps_component_name to the
47
// mode's monitored_components.
48
runners_.emplace_back(
new
GpsMonitor
());
49
// To enable the LocalizationMonitor, you must add
50
// FLAGS_localization_component_name to the mode's monitored_components.
51
runners_.emplace_back(
new
LocalizationMonitor
());
52
// To enable the CameraMonitor, you must add
53
// FLAGS_camera_component_name to the mode's monitored_components.
54
runners_.emplace_back(
new
CameraMonitor
());
55
// Monitor if processes are running.
56
runners_.emplace_back(
new
ProcessMonitor
());
57
// Monitor if modules are running.
58
runners_.emplace_back(
new
ModuleMonitor
());
59
// Monitor message processing latencies across modules
60
const
std::shared_ptr<LatencyMonitor> latency_monitor(
new
LatencyMonitor
());
61
runners_.emplace_back(latency_monitor);
62
// Monitor if channel messages are updated in time.
63
runners_.emplace_back(
new
ChannelMonitor
(latency_monitor));
64
// Monitor if resources are sufficient.
65
runners_.emplace_back(
new
ResourceMonitor
());
66
// Monitor all changes made by each sub-monitor, and summarize to a final
67
// overall status.
68
runners_.emplace_back(
new
SummaryMonitor
());
69
// Check functional safety according to the summary.
70
if
(FLAGS_enable_functional_safety) {
71
runners_.emplace_back(
new
FunctionalSafetyMonitor
());
72
}
73
74
return
true
;
75
}
76
77
bool
Monitor::Proc
() {
78
const
double
current_time =
apollo::cyber::Clock::NowInSeconds
();
79
if
(!MonitorManager::Instance()->StartFrame(current_time)) {
80
return
false
;
81
}
82
for
(
auto
& runner : runners_) {
83
runner->Tick(current_time);
84
}
85
MonitorManager::Instance()->EndFrame();
86
87
return
true
;
88
}
89
90
}
// namespace monitor
91
}
// namespace apollo
camera_monitor.h
channel_monitor.h
apollo::cyber::Clock::NowInSeconds
static double NowInSeconds()
gets the current time in second.
Definition
clock.cc:56
apollo::cyber::ComponentBase::node_
std::shared_ptr< Node > node_
Definition
component_base.h:119
apollo::monitor::CameraMonitor
Definition
camera_monitor.h:24
apollo::monitor::ChannelMonitor
Definition
channel_monitor.h:30
apollo::monitor::EsdCanMonitor
Definition
esdcan_monitor.h:23
apollo::monitor::FunctionalSafetyMonitor
Definition
functional_safety_monitor.h:27
apollo::monitor::GpsMonitor
Definition
gps_monitor.h:23
apollo::monitor::LatencyMonitor
Definition
latency_monitor.h:31
apollo::monitor::LocalizationMonitor
Definition
localization_monitor.h:23
apollo::monitor::ModuleMonitor
Definition
module_monitor.h:30
apollo::monitor::Monitor::Proc
bool Proc() override
The Proc logic of the component, which called by the CyberRT frame.
Definition
monitor.cc:77
apollo::monitor::Monitor::Init
bool Init() override
Definition
monitor.cc:40
apollo::monitor::ProcessMonitor
Definition
process_monitor.h:29
apollo::monitor::ResourceMonitor
Definition
resource_monitor.h:25
apollo::monitor::SocketCanMonitor
Definition
socket_can_monitor.h:23
apollo::monitor::SummaryMonitor
Definition
summary_monitor.h:28
clock.h
esdcan_monitor.h
functional_safety_monitor.h
gps_monitor.h
latency_monitor.h
localization_monitor.h
module_monitor.h
DEFINE_bool
DEFINE_bool(enable_functional_safety, true, "Whether to enable functional safety check.")
monitor.h
monitor_manager.h
apollo
class register implement
Definition
arena_queue.h:37
process_monitor.h
recorder_monitor.h
resource_monitor.h
socket_can_monitor.h
summary_monitor.h
modules
monitor
monitor.cc