Apollo  6.0
Open source self driving car software
realtime_record_processor.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 
17 #pragma once
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "absl/strings/str_cat.h"
24 #include "cyber/cyber.h"
27 
28 #include "modules/data/tools/smart_recorder/proto/smart_recorder_status.pb.h"
29 #include "modules/data/tools/smart_recorder/proto/smart_recorder_triggers.pb.h"
31 
32 namespace apollo {
33 namespace data {
34 
40  public:
41  RealtimeRecordProcessor(const std::string& source_record_dir,
42  const std::string& restored_output_dir);
43  bool Init(const SmartRecordTrigger& trigger_conf) override;
44  bool Process() override;
45  std::string GetDefaultOutputFile() const override {
46  return absl::StrCat(restored_output_dir_, "/", default_output_filename_);
47  };
48  void MonitorStatus();
49  virtual ~RealtimeRecordProcessor() = default;
50 
51  private:
52  bool GetNextValidRecord(std::string* record_path) const;
53  void RestoreMessage(const uint64_t message_time);
54  void PublishStatus(const RecordingState state,
55  const std::string& message) const;
56 
57  std::shared_ptr<cyber::record::Recorder> recorder_ = nullptr;
58  std::shared_ptr<cyber::Node> smart_recorder_node_ = nullptr;
59  std::shared_ptr<cyber::Writer<SmartRecorderStatus>> recorder_status_writer_ =
60  nullptr;
61  std::string default_output_filename_;
62  std::string restore_path_;
63  uint64_t restore_reader_time_ = 0;
64  double max_backward_time_ = 30.0;
65  double min_restore_chunk_ = 5.0;
66  bool is_terminating_ = false;
67  const int recorder_wait_time_ = 5000;
68 };
69 
70 } // namespace data
71 } // namespace apollo
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool Init(const SmartRecordTrigger &trigger_conf) override
Realtime processor against recorded tasks that are being recorded.
Definition: realtime_record_processor.h:39
RealtimeRecordProcessor(const std::string &source_record_dir, const std::string &restored_output_dir)
std::string GetDefaultOutputFile() const override
Definition: realtime_record_processor.h:45
virtual ~RealtimeRecordProcessor()=default
const std::string restored_output_dir_
Definition: record_processor.h:50
Process messages and apply the rules based on configured triggers.
Definition: record_processor.h:36