Apollo  6.0
Open source self driving car software
channel_verify.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2019 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 #pragma once
17 
18 #include <map>
19 #include <memory>
20 #include <set>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 #include "modules/map/tools/map_datachecker/proto/collection_error_code.pb.h"
26 
28 
29 namespace apollo {
30 namespace hdmap {
31 
33  std::string channel_name;
34  uint64_t msgnum;
35  std::string msg_type;
36 };
37 
39  std::string path;
40  double duration; // the unit is seconds
41  uint64_t start_time;
42  uint64_t end_time;
43  std::vector<CyberRecordChannel> channels;
44 };
45 
47  std::string record_path;
48  uint64_t start_time = 0;
49  std::vector<std::string> lack_channels;
50  // inadequate_rate: channel_name <---> (expected_rate, actual_rate)
51  std::map<std::string, std::pair<double, double>> inadequate_rate;
52 };
53 
54 typedef std::shared_ptr<std::vector<OneRecordChannelCheckResult>> CheckedResult;
55 typedef std::vector<OneRecordChannelCheckResult>::iterator CheckResultIterator;
56 
58  public:
59  explicit ChannelVerify(std::shared_ptr<JsonConf> sp_conf);
60  ErrorCode Check(const std::string& record_dir_or_record_full_path);
61  std::shared_ptr<std::vector<OneRecordChannelCheckResult>> get_check_result()
62  const;
63  ErrorCode GetReturnState() const;
64 
65  private:
66  bool IsRecordFile(const std::string& path) const;
67  std::shared_ptr<CyberRecordInfo> GetRecordInfo(
68  const std::string& record_path) const;
69  int IncrementalCheck(const std::vector<std::string>& records_path);
70  std::vector<std::string> GetRecordsPath(
71  const std::string& record_dir_or_record_full_path) const;
72  bool IsRecordChecked(const std::string& record_path);
73  OneRecordChannelCheckResult CheckRecordChannels(
74  const std::string& record_path);
75  void Reset();
76 
77  private:
78  std::shared_ptr<JsonConf> sp_conf_ = nullptr;
79  CheckedResult sp_vec_check_result_ = nullptr;
80  ErrorCode return_state_;
81  std::set<std::string> checked_records_;
82 };
83 
84 } // namespace hdmap
85 } // namespace apollo
Definition: channel_verify.h:57
uint64_t msgnum
Definition: channel_verify.h:34
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
std::vector< OneRecordChannelCheckResult >::iterator CheckResultIterator
Definition: channel_verify.h:55
std::string record_path
Definition: channel_verify.h:47
Definition: channel_verify.h:32
std::vector< std::string > lack_channels
Definition: channel_verify.h:49
double duration
Definition: channel_verify.h:40
uint64_t end_time
Definition: channel_verify.h:42
Definition: channel_verify.h:38
std::map< std::string, std::pair< double, double > > inadequate_rate
Definition: channel_verify.h:51
std::shared_ptr< std::vector< OneRecordChannelCheckResult > > CheckedResult
Definition: channel_verify.h:54
std::vector< CyberRecordChannel > channels
Definition: channel_verify.h:43
uint64_t start_time
Definition: channel_verify.h:41
std::string msg_type
Definition: channel_verify.h:35
std::string channel_name
Definition: channel_verify.h:33
std::string path
Definition: channel_verify.h:39
Definition: channel_verify.h:46