35 if (control_pipeline.controller_size() == 0) {
36 AERROR <<
"control_pipeline is empty";
37 return Status(ErrorCode::CONTROL_INIT_ERROR,
"Empty control_pipeline");
41 for (
int i = 0; i < control_pipeline.controller_size(); i++) {
44 if (!controller->Init(injector_).ok()) {
45 AERROR <<
"Can not init controller " << controller->
Name();
47 ErrorCode::CONTROL_INIT_ERROR,
48 "Failed to init Controller:" + control_pipeline.
controller(i).
name());
50 controller_list_.push_back(controller);
51 AINFO <<
"Controller <" << controller->Name() <<
"> init done!";
60 for (
auto &controller : controller_list_) {
61 ADEBUG <<
"controller:" << controller->Name() <<
" processing ...";
63 Status controller_status = controller->ComputeControlCommand(
64 localization, chassis, trajectory, cmd);
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);
71 return controller_status;
78 for (
auto &controller : controller_list_) {
79 ADEBUG <<
"controller:" << controller->Name() <<
" reset...";
A general class to denote the return status of an API call.
static Status OK()
generate a success status.
common::Status Reset()
reset ControlTaskAgent
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
virtual std::string Name() const =0
controller name
a singleton clock that can be used to get the current timestamp.
static double NowInSeconds()
gets the current time in second.
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
Defines the ControlTaskAgent class.
repeated PluginDeclareInfo controller