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

manage all controllers declared in control config file. 更多...

#include <control_task_agent.h>

apollo::control::ControlTaskAgent 的协作图:

Public 成员函数

common::Status Init (std::shared_ptr< DependencyInjector > injector, const ControlPipeline &control_pipeline)
 initialize ControlTaskAgent
 
common::Status ComputeControlCommand (const localization::LocalizationEstimate *localization, const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory, control::ControlCommand *cmd)
 compute control command based on current vehicle status and target trajectory
 
common::Status Reset ()
 reset ControlTaskAgent
 

详细描述

manage all controllers declared in control config file.

在文件 control_task_agent.h48 行定义.

成员函数说明

◆ ComputeControlCommand()

Status apollo::control::ControlTaskAgent::ComputeControlCommand ( const localization::LocalizationEstimate localization,
const canbus::Chassis chassis,
const planning::ADCTrajectory trajectory,
control::ControlCommand cmd 
)

compute control command based on current vehicle status and target trajectory

参数
localizationvehicle location
chassisvehicle status e.g., speed, acceleration
trajectorytrajectory generated by planning
cmdcontrol command
返回
Status computation status

在文件 control_task_agent.cc56 行定义.

59 {
60 for (auto &controller : controller_list_) {
61 ADEBUG << "controller:" << controller->Name() << " processing ...";
62 double start_timestamp = Clock::NowInSeconds();
63 Status controller_status = controller->ComputeControlCommand(
64 localization, chassis, trajectory, cmd);
65 double end_timestamp = Clock::NowInSeconds();
66 const double time_diff_ms = (end_timestamp - start_timestamp) * 1000;
67 ADEBUG << "controller: " << controller->Name()
68 << " calculation time is: " << time_diff_ms << " ms.";
69 cmd->mutable_latency_stats()->add_controller_time_ms(time_diff_ms);
70 if (controller_status != Status::OK()) {
71 return controller_status;
72 }
73 }
74 return Status::OK();
75}
static Status OK()
generate a success status.
Definition status.h:60
static double NowInSeconds()
gets the current time in second.
Definition clock.cc:56
#define ADEBUG
Definition log.h:41

◆ Init()

Status apollo::control::ControlTaskAgent::Init ( std::shared_ptr< DependencyInjector injector,
const ControlPipeline control_pipeline 
)

initialize ControlTaskAgent

参数
control_confcontrol configurations
返回
Status initialization status

在文件 control_task_agent.cc33 行定义.

34 {
35 if (control_pipeline.controller_size() == 0) {
36 AERROR << "control_pipeline is empty";
37 return Status(ErrorCode::CONTROL_INIT_ERROR, "Empty control_pipeline");
38 }
39
40 injector_ = injector;
41 for (int i = 0; i < control_pipeline.controller_size(); i++) {
42 auto controller = PluginManager::Instance()->CreateInstance<ControlTask>(
43 "apollo::control::" + control_pipeline.controller(i).type());
44 if (!controller->Init(injector_).ok()) {
45 AERROR << "Can not init controller " << controller->Name();
46 return Status(
47 ErrorCode::CONTROL_INIT_ERROR,
48 "Failed to init Controller:" + control_pipeline.controller(i).name());
49 }
50 controller_list_.push_back(controller);
51 AINFO << "Controller <" << controller->Name() << "> init done!";
52 }
53 return Status::OK();
54}
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 AERROR
Definition log.h:44
#define AINFO
Definition log.h:42

◆ Reset()

Status apollo::control::ControlTaskAgent::Reset ( )

reset ControlTaskAgent

返回
Status reset status

在文件 control_task_agent.cc77 行定义.

77 {
78 for (auto &controller : controller_list_) {
79 ADEBUG << "controller:" << controller->Name() << " reset...";
80 controller->Reset();
81 }
82 return Status::OK();
83}

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