Apollo 11.0
自动驾驶开放平台
latency_statistic_component.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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 <map>
20#include <memory>
21#include <regex>
22#include <string>
23#include <vector>
24
25#include "modules/statistics_msgs/latency_statistic.pb.h"
26
28#include "cyber/cyber.h"
29
34namespace apollo {
35namespace latency_statistic {
36
37struct Metric {
38 uint64_t compensator = 0;
39 uint64_t perception = 0;
40 uint64_t prediction = 0;
41 uint64_t planning = 0;
42 uint64_t control = 0;
43};
44
45struct Result {
46 std::vector<uint64_t> compensator_chain_list;
47 std::vector<uint64_t> compensator_proc_list;
48 std::vector<uint64_t> perception_chain_list;
49 std::vector<uint64_t> perception_proc_list;
50 std::vector<uint64_t> prediction_chain_list;
51 std::vector<uint64_t> prediction_proc_list;
52 std::vector<uint64_t> planning_chain_list;
53 std::vector<uint64_t> planning_proc_list;
54 std::vector<uint64_t> control_chain_list;
55 std::vector<uint64_t> control_proc_list;
56};
57
59public:
60 bool Init() override;
61 bool Proc() override;
62
63private:
64 void CreateReaders();
65
66 template <class T>
67 void CreateReader(const std::string& channel_name);
68 void FillResult(const uint64_t& lidar_timestamp, const Metric& metric, Result* result);
69 void CalculateLatency(const Result& result, std::shared_ptr<LatencyMetrics> metrics);
70
71 void GetLatencyMetric(const std::vector<uint64_t>& items, LatencyMetrics_Metric* metric);
72
73 std::map<uint64_t, Metric> latency_map_;
74 uint64_t latest_stamp_ = 0;
75 std::mutex lock_;
76
77 std::shared_ptr<cyber::Writer<LatencyMetrics>> metric_writer_;
78
79 std::string compensator_topic;
80 std::string perception_topic;
81 std::string prediction_topic;
82 std::string planning_topic;
83 std::string control_topic;
84};
85
87
88} // namespace latency_statistic
89} // namespace apollo
bool Proc() override
The Proc logic of the component, which called by the CyberRT frame.
Planning module main class.
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:657
class register implement
Definition arena_queue.h:37