Apollo 10.0
自动驾驶开放平台
recorder.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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#ifndef CYBER_TOOLS_CYBER_RECORDER_RECORDER_H_
18#define CYBER_TOOLS_CYBER_RECORDER_RECORDER_H_
19
20#include <memory>
21#include <mutex>
22#include <regex>
23#include <string>
24#include <unordered_map>
25#include <vector>
26
27#include "cyber/proto/record.pb.h"
28#include "cyber/proto/topology_change.pb.h"
29
30#include "cyber/base/signal.h"
31#include "cyber/cyber.h"
34
44
45namespace apollo {
46namespace cyber {
47namespace record {
48
49class Recorder : public std::enable_shared_from_this<Recorder> {
50 public:
51 Recorder(const std::string& output, bool all_channels,
52 const std::vector<std::string>& white_channels,
53 const std::vector<std::string>& black_channels);
54 Recorder(const std::string& output, bool all_channels,
55 const std::vector<std::string>& white_channels,
56 const std::vector<std::string>& black_channels,
57 const proto::Header& header);
58 ~Recorder();
59 bool Start();
60 bool Stop();
61
62 private:
63 bool is_started_ = false;
64 bool is_stopping_ = false;
65 std::shared_ptr<Node> node_ = nullptr;
66 std::shared_ptr<RecordWriter> writer_ = nullptr;
67 std::shared_ptr<std::thread> display_thread_ = nullptr;
69 std::string output_;
70 bool all_channels_ = true;
71 std::vector<std::string> white_channels_;
72 std::vector<std::regex> white_channel_patterns_;
73 std::vector<std::string> black_channels_;
74 std::vector<std::regex> black_channel_patterns_;
75 proto::Header header_;
76 std::unordered_map<std::string, std::shared_ptr<ReaderBase>>
77 channel_reader_map_;
78 uint64_t message_count_;
79 uint64_t message_time_;
80
81 bool InitReadersImpl();
82
83 bool FreeReadersImpl();
84
85 bool InitReaderImpl(const std::string& channel_name,
86 const std::string& message_type);
87
88 void TopologyCallback(const ChangeMsg& msg);
89
90 void ReaderCallback(const std::shared_ptr<RawMessage>& message,
91 const std::string& channel_name);
92
93 void FindNewChannel(const RoleAttributes& role_attr);
94
95 void ShowProgress();
96};
97
98} // namespace record
99} // namespace cyber
100} // namespace apollo
101
102#endif // CYBER_TOOLS_CYBER_RECORDER_RECORDER_H_
Node is the fundamental building block of Cyber RT.
Definition node.h:44
Base Class for Reader Reader is identified by one apollo::cyber::proto::RoleAttribute,...
Definition reader_base.h:46
Topology Manager of Service related
elements in Cyber – Node, Channel, Service, Writer, Reader, Client and Server's relationship is prese...
class register implement
Definition arena_queue.h:37