Apollo  6.0
Open source self driving car software
recorder.h
Go to the documentation of this file.
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 <string>
23 #include <unordered_map>
24 #include <vector>
25 
26 #include "cyber/base/signal.h"
27 #include "cyber/cyber.h"
29 #include "cyber/proto/record.pb.h"
30 #include "cyber/proto/topology_change.pb.h"
32 
37 using apollo::cyber::proto::ChangeMsg;
38 using apollo::cyber::proto::RoleAttributes;
39 using apollo::cyber::proto::RoleType;
42 
43 namespace apollo {
44 namespace cyber {
45 namespace record {
46 
47 class Recorder : public std::enable_shared_from_this<Recorder> {
48  public:
49  Recorder(const std::string& output, bool all_channels,
50  const std::vector<std::string>& white_channels,
51  const std::vector<std::string>& black_channels);
52  Recorder(const std::string& output, bool all_channels,
53  const std::vector<std::string>& white_channels,
54  const std::vector<std::string>& black_channels,
55  const proto::Header& header);
56  ~Recorder();
57  bool Start();
58  bool Stop();
59 
60  private:
61  bool is_started_ = false;
62  bool is_stopping_ = false;
63  std::shared_ptr<Node> node_ = nullptr;
64  std::shared_ptr<RecordWriter> writer_ = nullptr;
65  std::shared_ptr<std::thread> display_thread_ = nullptr;
66  Connection<const ChangeMsg&> change_conn_;
67  std::string output_;
68  bool all_channels_ = true;
69  std::vector<std::string> white_channels_;
70  std::vector<std::string> black_channels_;
71  proto::Header header_;
72  std::unordered_map<std::string, std::shared_ptr<ReaderBase>>
73  channel_reader_map_;
74  uint64_t message_count_;
75  uint64_t message_time_;
76 
77  bool InitReadersImpl();
78 
79  bool FreeReadersImpl();
80 
81  bool InitReaderImpl(const std::string& channel_name,
82  const std::string& message_type);
83 
84  void TopologyCallback(const ChangeMsg& msg);
85 
86  void ReaderCallback(const std::shared_ptr<RawMessage>& message,
87  const std::string& channel_name);
88 
89  void FindNewChannel(const RoleAttributes& role_attr);
90 
91  void ShowProgress();
92 };
93 
94 } // namespace record
95 } // namespace cyber
96 } // namespace apollo
97 
98 #endif // CYBER_TOOLS_CYBER_RECORDER_RECORDER_H_
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Definition: raw_message.h:31
elements in Cyber – Node, Channel, Service, Writer, Reader, Client and Server&#39;s relationship is pres...
Definition: topology_manager.h:64
Node is the fundamental building block of Cyber RT. every module contains and communicates through th...
Definition: node.h:44
Recorder(const std::string &output, bool all_channels, const std::vector< std::string > &white_channels, const std::vector< std::string > &black_channels)
Base Class for Reader Reader is identified by one apollo::cyber::proto::RoleAttribute, it contains the channel_name, channel_id that we subscribe, and host_name, process_id and node that we are located, and qos that describes our transportation quality.
Definition: reader_base.h:46
Definition: signal.h:34
Topology Manager of Service related.
Definition: channel_manager.h:42
Definition: recorder.h:47