Apollo  6.0
Open source self driving car software
mpc_controller_submodule.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 
25 #include "modules/canbus/proto/chassis.pb.h"
31 #include "modules/control/proto/calibration_table.pb.h"
32 #include "modules/control/proto/control_cmd.pb.h"
33 #include "modules/control/proto/control_conf.pb.h"
34 #include "modules/control/proto/pad_msg.pb.h"
35 #include "modules/control/proto/preprocessor.pb.h"
36 #include "modules/localization/proto/localization.pb.h"
37 #include "modules/planning/proto/planning.pb.h"
38 
39 namespace apollo {
40 namespace control {
41 class MPCControllerSubmodule final : public cyber::Component<Preprocessor> {
42  public:
52 
57  std::string Name() const;
58 
63  bool Init() override;
64 
71  bool Proc(const std::shared_ptr<Preprocessor>& preprocessor_status) override;
72 
73  private:
74  common::Status ProduceControlCoreCommand(
75  const LocalView& local_view, ControlCommand* control_core_command);
76 
77  private:
78  bool estop_ = false;
79 
80  common::monitor::MonitorLogBuffer monitor_logger_buffer_;
81 
82  MPCController mpc_controller_;
83 
84  std::mutex mutex_;
85  // TODO(SHU): separate conf
86  ControlConf mpc_controller_conf_;
87  std::shared_ptr<cyber::Writer<ControlCommand>> control_core_writer_;
88  std::shared_ptr<DependencyInjector> injector_;
89 };
90 
92 
93 } // namespace control
94 } // namespace apollo
MPCControllerSubmodule()
Construct a new MPCControllerSubmodule object.
MPCController, combined lateral and longitudinal controllers.
Definition: mpc_controller.h:51
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
LocalView contains all necessary data as planning input.
bool Init() override
Initialize the node.
CYBER_REGISTER_COMPONENT(PreprocessorSubmodule)
bool Proc(const std::shared_ptr< Preprocessor > &preprocessor_status) override
generate control command
Defines the MPCController class.
Definition: mpc_controller_submodule.h:41
Defines the Controller base class.
std::string Name() const
Get name of the node.
The class of MonitorLogBuffer.
A general class to denote the return status of an API call. It can either be an OK status for success...
Definition: status.h:43
This class help collect MonitorMessage pb to monitor topic. The messages can be published automatical...
Definition: monitor_log_buffer.h:60
Some util functions.
The Component can process up to four channels of messages. The message type is specified when the com...
Definition: component.h:58