Apollo 10.0
自动驾驶开放平台
monitor_manager.h
浏览该文件的文档.
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
17#pragma once
18
19#include <memory>
20#include <string>
21#include <unordered_map>
22
23#include "cyber/common/macros.h"
25#include "modules/common_msgs/dreamview_msgs/hmi_config.pb.h"
26#include "modules/common_msgs/dreamview_msgs/hmi_mode.pb.h"
27#include "modules/common_msgs/dreamview_msgs/hmi_status.pb.h"
28#include "modules/common_msgs/monitor_msgs/system_status.pb.h"
29
34namespace apollo {
35namespace monitor {
36
37// Centralized monitor config and status manager.
39 public:
40 void Init(const std::shared_ptr<apollo::cyber::Node>& node);
41
42 // Start and end a monitoring frame.
43 bool StartFrame(const double current_time);
44 void EndFrame();
45
46 // Getters.
47 const apollo::dreamview::HMIMode& GetHMIMode() const { return mode_config_; }
48 bool IsInAutonomousMode() const { return in_autonomous_driving_; }
49 SystemStatus* GetStatus() { return &status_; }
51
52 // Cyber reader / writer creator.
53 template <class T>
54 std::shared_ptr<cyber::Reader<T>> CreateReader(const std::string& channel) {
55 if (readers_.find(channel) == readers_.end()) {
56 readers_.emplace(channel, node_->CreateReader<T>(channel));
57 }
58 return std::dynamic_pointer_cast<cyber::Reader<T>>(readers_[channel]);
59 }
60
61 template <class T>
62 std::shared_ptr<cyber::Writer<T>> CreateWriter(const std::string& channel) {
63 return node_->CreateWriter<T>(channel);
64 }
65
66 private:
67 SystemStatus status_;
68
69 // Input statuses.
70 std::string current_mode_;
71 const apollo::dreamview::HMIConfig hmi_config_;
72 apollo::dreamview::HMIMode mode_config_;
73 bool in_autonomous_driving_ = false;
74 bool CheckAutonomousDriving(const double current_time);
75
77 std::shared_ptr<apollo::cyber::Node> node_;
78 std::unordered_map<std::string, std::shared_ptr<cyber::ReaderBase>> readers_;
79
81};
82
83} // namespace monitor
84} // namespace apollo
std::shared_ptr< cyber::Writer< T > > CreateWriter(const std::string &channel)
const apollo::dreamview::HMIMode & GetHMIMode() const
bool StartFrame(const double current_time)
void Init(const std::shared_ptr< apollo::cyber::Node > &node)
apollo::common::monitor::MonitorLogBuffer & LogBuffer()
std::shared_ptr< cyber::Reader< T > > CreateReader(const std::string &channel)
#define DECLARE_SINGLETON(classname)
Definition macros.h:52
The class of MonitorLogBuffer
class register implement
Definition arena_queue.h:37