Apollo 11.0
自动驾驶开放平台
debug_info_control_task.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
18
19#include "cyber/common/log.h"
22
23namespace apollo {
24namespace control {
25
30
31DebugInfoControlTask::DebugInfoControlTask() : name_("Debug Info Control Task") {
32 AINFO << "Using " << name_;
33}
34
35Status DebugInfoControlTask::Init(std::shared_ptr<DependencyInjector> injector) {
36 // hook: Apollo License Verification: v_apollo_park
37 injector_ = injector;
38 node_ = ::apollo::cyber::CreateNode("control_debug");
39 control_debug_info_writer_
40 = node_->CreateWriter<::apollo::control::ControlDebugInfo>(FLAGS_control_debug_info_topic);
41 ACHECK(control_debug_info_writer_ != nullptr);
42 return Status::OK();
43}
44
46 const localization::LocalizationEstimate *localization,
47 const canbus::Chassis *chassis,
48 const planning::ADCTrajectory *planning_published_trajectory,
49 ControlCommand *cmd) {
50 control_debug_info_msg_.Clear();
51 if (injector_->control_process() && FLAGS_publish_control_debug_info) {
52 control_debug_info_msg_.CopyFrom(injector_->control_debug_info());
53 common::util::FillHeader(node_->Name(), &control_debug_info_msg_);
54 if (FLAGS_sim_by_record) {
55 control_debug_info_msg_.mutable_header()->set_timestamp_sec(chassis->header().timestamp_sec());
56 }
57 ADEBUG << "control debug msg is: " << control_debug_info_msg_.ShortDebugString();
58 control_debug_info_writer_->Write(control_debug_info_msg_);
59 }
60 return Status::OK();
61}
62
64
66 control_debug_info_msg_.Clear();
67 return Status::OK();
68}
69
70std::string DebugInfoControlTask::Name() const {
71 return name_;
72}
73
74} // namespace control
75} // namespace apollo
A general class to denote the return status of an API call.
Definition status.h:43
static Status OK()
generate a success status.
Definition status.h:60
common::Status Reset() override
reset demo control task
void Stop() override
stop DebugInfoControlTask
std::shared_ptr< DependencyInjector > injector_
common::Status Init(std::shared_ptr< DependencyInjector > injector) override
initialize DebugInfoControlTask
std::string Name() const override
DebugInfoControlTask name
common::Status ComputeControlCommand(const localization::LocalizationEstimate *localization, const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory, control::ControlCommand *cmd) override
compute brake / throttle values based on current vehicle status and target trajectory
Defines the DebugInfoControlTask class.
#define ACHECK(cond)
Definition log.h:80
#define ADEBUG
Definition log.h:41
#define AINFO
Definition log.h:42
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
Definition cyber.cc:33
class register implement
Definition arena_queue.h:37
optional apollo::common::Header header
optional double timestamp_sec
Definition header.proto:9