Apollo 10.0
自动驾驶开放平台
apollo::control::MPCControllerSubmodule类 参考final

#include <mpc_controller_submodule.h>

类 apollo::control::MPCControllerSubmodule 继承关系图:
apollo::control::MPCControllerSubmodule 的协作图:

Public 成员函数

 MPCControllerSubmodule ()
 Construct a new MPCControllerSubmodule object
 
 ~MPCControllerSubmodule ()
 Destructor
 
std::string Name () const
 Get name of the node
 
bool Init () override
 Initialize the node
 
bool Proc (const std::shared_ptr< Preprocessor > &preprocessor_status) override
 generate control command
 
- Public 成员函数 继承自 apollo::cyber::Component< Preprocessor >
 Component ()
 
 ~Component () override
 
bool Initialize (const ComponentConfig &config) override
 init the component by protobuf object.
 
bool Process (const std::shared_ptr< Preprocessor > &msg0, const std::shared_ptr< NullType > &msg1, const std::shared_ptr< NullType > &msg2, const std::shared_ptr< NullType > &msg3)
 
- Public 成员函数 继承自 apollo::cyber::ComponentBase
virtual ~ComponentBase ()
 
virtual bool Initialize (const TimerComponentConfig &config)
 
virtual void Shutdown ()
 
template<typename T >
bool GetProtoConfig (T *config) const
 

额外继承的成员函数

- Public 类型 继承自 apollo::cyber::ComponentBase
template<typename M >
using Reader = cyber::Reader< M >
 
- Protected 成员函数 继承自 apollo::cyber::ComponentBase
virtual void Clear ()
 
const std::string & ConfigFilePath () const
 
void LoadConfigFiles (const ComponentConfig &config)
 
void LoadConfigFiles (const TimerComponentConfig &config)
 
- Protected 属性 继承自 apollo::cyber::ComponentBase
std::atomic< bool > is_shutdown_ = {false}
 
std::shared_ptr< Nodenode_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 mpc_controller_submodule.h40 行定义.

构造及析构函数说明

◆ MPCControllerSubmodule()

apollo::control::MPCControllerSubmodule::MPCControllerSubmodule ( )

◆ ~MPCControllerSubmodule()

apollo::control::MPCControllerSubmodule::~MPCControllerSubmodule ( )

Destructor

在文件 mpc_controller_submodule.cc42 行定义.

42{}

成员函数说明

◆ Init()

bool apollo::control::MPCControllerSubmodule::Init ( )
overridevirtual

Initialize the node

返回
If initialized

实现了 apollo::cyber::ComponentBase.

在文件 mpc_controller_submodule.cc48 行定义.

48 {
49 injector_ = std::make_shared<DependencyInjector>();
50
51 mpc_controller_ = PluginManager::Instance()->CreateInstance<ControlTask>(
52 "apollo::control::MPCController");
53
54 if (!mpc_controller_->Init(injector_).ok()) {
55 monitor_logger_buffer_.ERROR(
56 "Control init MPC controller failed! Stopping...");
57 return false;
58 }
59
60 control_core_writer_ =
61 node_->CreateWriter<ControlCommand>(FLAGS_control_core_command_topic);
62 ACHECK(control_core_writer_ != nullptr);
63 return true;
64}
std::shared_ptr< Node > node_
static PluginManager * Instance()
get singleton instance of PluginManager
std::shared_ptr< Base > CreateInstance(const std::string &derived_class)
create plugin instance of derived class based on Base
#define ACHECK(cond)
Definition log.h:80

◆ Name()

std::string apollo::control::MPCControllerSubmodule::Name ( ) const

Get name of the node

返回
Name of the node

在文件 mpc_controller_submodule.cc44 行定义.

44 {
45 return FLAGS_mpc_controller_submodule_name;
46}

◆ Proc()

bool apollo::control::MPCControllerSubmodule::Proc ( const std::shared_ptr< Preprocessor > &  preprocessor_status)
override

generate control command

返回
true control command is successfully generated
false fail to generate control command

在文件 mpc_controller_submodule.cc66 行定义.

67 {
68 const auto start_time = Clock::Now();
69
70 ControlCommand control_core_command;
71 // recording pad msg
72 if (preprocessor_status->received_pad_msg()) {
73 control_core_command.mutable_pad_msg()->CopyFrom(
74 preprocessor_status->local_view().pad_msg());
75 }
76 ADEBUG << "MPC controller submodule started ....";
77
78 // skip produce control command when estop for MPC controller
79 StatusPb pre_status = preprocessor_status->header().status();
80 if (pre_status.error_code() != ErrorCode::OK) {
81 control_core_command.mutable_header()->mutable_status()->CopyFrom(
82 pre_status);
83 AERROR << "Error in preprocessor submodule.";
84 return false;
85 }
86
87 Status status = ProduceControlCoreCommand(preprocessor_status->local_view(),
88 &control_core_command);
89 AERROR_IF(!status.ok()) << "Failed to produce control command:"
90 << status.error_message();
91
92 control_core_command.mutable_header()->set_lidar_timestamp(
93 preprocessor_status->header().lidar_timestamp());
94 control_core_command.mutable_header()->set_camera_timestamp(
95 preprocessor_status->header().camera_timestamp());
96 control_core_command.mutable_header()->set_radar_timestamp(
97 preprocessor_status->header().radar_timestamp());
98 common::util::FillHeader(Name(), &control_core_command);
99
100 const auto end_time = Clock::Now();
101
102 static apollo::common::LatencyRecorder latency_recorder(
103 FLAGS_control_core_command_topic);
104 latency_recorder.AppendLatencyRecord(
105 control_core_command.header().lidar_timestamp(), start_time, end_time);
106
107 control_core_command.mutable_header()->mutable_status()->set_error_code(
108 status.code());
109 control_core_command.mutable_header()->mutable_status()->set_msg(
110 status.error_message());
111
112 control_core_writer_->Write(control_core_command);
113
114 return status.ok();
115}
std::string Name() const
Get name of the node
static Time Now()
PRECISION >= 1000000 means the precision is at least 1us.
Definition clock.cc:40
#define ADEBUG
Definition log.h:41
#define AERROR
Definition log.h:44
#define AERROR_IF(cond)
Definition log.h:74

该类的文档由以下文件生成: