Apollo 10.0
自动驾驶开放平台
external_command_process_component.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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
22
23#include "modules/external_command/process_component/proto/process_component_config.pb.h"
26
31namespace apollo {
32namespace external_command {
33
35 // Load the external command processors according to the config.
37 if (!GetProtoConfig(&config)) {
38 AERROR << "Unable to load ExternalCommandProcessComponent conf file: "
39 << ConfigFilePath();
40 return false;
41 }
42 const auto& plugin_manager = cyber::plugin_manager::PluginManager::Instance();
43 for (const auto& processor_class_name : config.processor()) {
44 command_processors_.emplace_back(
45 plugin_manager->CreateInstance<CommandProcessorBase>(
46 processor_class_name));
47 command_processors_.back()->Init(node_);
48 }
49 command_status_service_ =
52 [this](const std::shared_ptr<CommandStatusRequest>& request,
53 std::shared_ptr<CommandStatus>& response) {
54 bool is_get_status = false;
55 // Get the command status from command processors.
56 for (const auto& processor : command_processors_) {
57 if (processor->GetCommandStatus(request->command_id(),
58 response.get())) {
59 is_get_status = true;
60 break;
61 }
62 }
63 if (!is_get_status) {
64 response->set_status(CommandStatusType::UNKNOWN);
65 response->set_message("Cannot get the status of command.");
66 }
67 });
68 AINFO << "ExternalCommandProcessComponent init finished.";
69 return true;
70}
71
72} // namespace external_command
73} // namespace apollo
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
static PluginManager * Instance()
get singleton instance of PluginManager
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37