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 *****************************************************************************/
17
18#include "cyber/time/clock.h"
33
34DEFINE_bool(enable_functional_safety, true,
35 "Whether to enable functional safety check.");
36
37namespace apollo {
38namespace monitor {
39
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
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
static double NowInSeconds()
gets the current time in second.
Definition clock.cc:56
std::shared_ptr< Node > node_
bool Proc() override
The Proc logic of the component, which called by the CyberRT frame.
Definition monitor.cc:77
bool Init() override
Definition monitor.cc:40
DEFINE_bool(enable_functional_safety, true, "Whether to enable functional safety check.")
class register implement
Definition arena_queue.h:37