Apollo  6.0
Open source self driving car software
guardian_component.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 
21 #pragma once
22 
23 #include <memory>
24 
25 #include "cyber/common/macros.h"
27 #include "cyber/cyber.h"
28 
29 #include "modules/canbus/proto/chassis.pb.h"
30 #include "modules/control/proto/control_cmd.pb.h"
31 #include "modules/guardian/proto/guardian.pb.h"
32 #include "modules/guardian/proto/guardian_conf.pb.h"
33 #include "modules/monitor/proto/system_status.pb.h"
34 
39 namespace apollo {
40 namespace guardian {
41 
43  public:
44  bool Init() override;
45  bool Proc() override;
46 
47  private:
48  void PassThroughControlCommand();
49  void TriggerSafetyMode();
50 
51  apollo::guardian::GuardianConf guardian_conf_;
52  apollo::canbus::Chassis chassis_;
53  apollo::monitor::SystemStatus system_status_;
54  apollo::control::ControlCommand control_cmd_;
55  apollo::guardian::GuardianCommand guardian_cmd_;
56 
57  double last_status_received_s_{};
58 
59  std::shared_ptr<apollo::cyber::Reader<apollo::canbus::Chassis>>
60  chassis_reader_;
61  std::shared_ptr<apollo::cyber::Reader<apollo::control::ControlCommand>>
62  control_cmd_reader_;
63  std::shared_ptr<apollo::cyber::Reader<apollo::monitor::SystemStatus>>
64  system_status_reader_;
65  std::shared_ptr<apollo::cyber::Writer<apollo::guardian::GuardianCommand>>
66  guardian_writer_;
67 
68  std::mutex mutex_;
69 };
70 
72 
73 } // namespace guardian
74 } // namespace apollo
Definition: guardian_component.h:42
TimerComponent is a timer component. Your component can inherit from Component, and implement Init() ...
Definition: timer_component.h:35
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
#define CYBER_REGISTER_COMPONENT(name)
Definition: component.h:551
bool Proc() override
The Proc logic of the component, which called by the CyberRT frame.