Apollo 10.0
自动驾驶开放平台
apollo::external_command::ActionCommandProcessor类 参考

#include <action_command_processor.h>

类 apollo::external_command::ActionCommandProcessor 继承关系图:
apollo::external_command::ActionCommandProcessor 的协作图:

Public 成员函数

bool Init (const std::shared_ptr< cyber::Node > &node) override
 
bool GetCommandStatus (int64_t command_id, CommandStatus *status) const override
 Get the command status.
 
- Public 成员函数 继承自 apollo::external_command::CommandProcessorBase
 CommandProcessorBase ()
 
virtual ~CommandProcessorBase ()=default
 

额外继承的成员函数

- Protected 成员函数 继承自 apollo::external_command::CommandProcessorBase
const CommandProcessorConfigGetProcessorConfig () const
 
const std::shared_ptr< cyber::Node > & Node () const
 

详细描述

在文件 action_command_processor.h43 行定义.

成员函数说明

◆ GetCommandStatus()

bool apollo::external_command::ActionCommandProcessor::GetCommandStatus ( int64_t  command_id,
CommandStatus status 
) const
overridevirtual

Get the command status.

参数
command_idId of the command.
statusOutput command status.

实现了 apollo::external_command::CommandProcessorBase.

在文件 action_command_processor.cc86 行定义.

87 {
88 CHECK_NOTNULL(status);
89 if (nullptr == last_command_) {
90 return false;
91 }
92 if (last_command_->command_id() != command_id) {
93 return false;
94 }
95 std::string module_name = "UNKNOWN";
96 if (last_command_->has_header()) {
97 module_name = last_command_->header().module_name();
98 }
99 common::util::FillHeader(module_name, status);
100 status->set_command_id(command_id);
101 switch (last_command_->command()) {
102 // Get status of "FOLLOW", "CHANGE_LEFT", "CHANGE_RIGHT".
106 // todo: Check the real planning status and set command status.
108 status->set_message("Cannot execute the command!");
109 } break;
110 // Get status of "PULL_OVER".
112 // When planning is in PullOverScenario and the scenario is finished,
113 // command status is finished.
114 CheckScenarioFinished(special_config_.pull_over_scenario_name(), status);
115 } break;
116 // Get status of "STOP".
118 CheckScenarioFinished(special_config_.stop_scenario_name(), status);
119 } break;
120 // Get status of "START".
122 auto* latest_chassis_status =
123 message_reader_->GetMessage<apollo::canbus::Chassis>(
124 chassis_status_name_);
125 if (nullptr == latest_chassis_status) {
127 status->set_message("Cannot get chassis status!");
128 return true;
129 }
130 // If the vehicle is moving, the command is considered as finished.
131 if (latest_chassis_status->speed_mps() >
132 special_config_.minimun_non_zero_speed()) {
133 status->set_status(
135 }
137 } break;
138 // Get status of "CLEAR_PLANNING".
141 } break;
142 // Get status of "SWITCH_TO_MANUAL".
144 CheckModeSwitchFinished(canbus::Chassis::COMPLETE_MANUAL, status);
145 } break;
146 // Get status of "SWITCH_TO_AUTO".
148 CheckModeSwitchFinished(canbus::Chassis::COMPLETE_AUTO_DRIVE, status);
149 } break;
150 // Get status of "VIN_REQ".
151 default: {
152 // todo: Get the real result of control.
154 } break;
155 }
156 return true;
157}
const T * GetMessage(const std::string &channel_name) const
Get the message with the channel name.

◆ Init()

bool apollo::external_command::ActionCommandProcessor::Init ( const std::shared_ptr< cyber::Node > &  node)
overridevirtual

重载 apollo::external_command::CommandProcessorBase .

在文件 action_command_processor.cc36 行定义.

36 {
37 if (!CommandProcessorBase::Init(node)) {
38 return false;
39 }
40 message_reader_ = MessageReader::Instance();
41 const auto& config = GetProcessorConfig();
42 // Get special config for ActionCommandProcessor.
43 int status = 0;
44 std::string class_name =
45 abi::__cxa_demangle(typeid(*this).name(), nullptr, nullptr, &status);
46 std::string special_config_path =
49 class_name, "conf/special_config.pb.txt");
50 if (!cyber::common::LoadConfig<ActionCommandConfig>(special_config_path,
51 &special_config_)) {
52 AERROR << "Cannot get special config of ActionCommandProcessor";
53 return false;
54 }
55 // Create service for input command.
56 command_service_ = node->CreateService<ActionCommand, CommandStatus>(
57 config.input_command_name(),
58 [this](const std::shared_ptr<ActionCommand>& command,
59 std::shared_ptr<CommandStatus>& status) {
60 this->OnCommand(command, status);
61 });
62 // Create writers for output command.
63 CHECK_GT(config.output_command_name().size(), 1);
64 auto message_writer = MessageWriter::Instance();
65 planning_action_writer_ =
66 message_writer->RegisterMessage<apollo::planning::PadMessage>(
67 config.output_command_name().Get(0));
68 control_action_writer_ =
69 message_writer->RegisterMessage<apollo::control::PadMessage>(
70 config.output_command_name().Get(1));
71 // Create reader for input command status.
72 CHECK_GT(config.input_command_status_name().size(), 2);
73
74 chassis_status_name_ = config.input_command_status_name().Get(0);
75 planning_status_name_ = config.input_command_status_name().Get(1);
76 planning_command_status_name_ = config.input_command_status_name().Get(2);
78 chassis_status_name_);
80 planning_status_name_);
81 message_reader_->RegisterMessage<CommandStatus>(
82 planning_command_status_name_);
83 return true;
84}
std::string GetPluginConfPath(const std::string &class_name, const std::string &conf_name)
get plugin configuration file location
static PluginManager * Instance()
get singleton instance of PluginManager
virtual bool Init(const std::shared_ptr< cyber::Node > &node)
const CommandProcessorConfig & GetProcessorConfig() const
void RegisterMessage(const std::string &channel_name)
Register the message reader with the given channel name.
#define AERROR
Definition log.h:44

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