Apollo 10.0
自动驾驶开放平台
demo_control_task.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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 <algorithm>
20#include <iomanip>
21#include <utility>
22
23namespace apollo {
24namespace control {
25
30
31DemoControlTask::DemoControlTask() : name_("demo control task") {
32 AINFO << "Using " << name_;
33}
34
36
37Status DemoControlTask::Init(std::shared_ptr<DependencyInjector> injector) {
38 if (!ControlTask::LoadConfig<DemoControlTaskConf>(&demo_control_task_conf_)) {
39 AERROR << "failed to load control conf";
40 return Status(ErrorCode::CONTROL_INIT_ERROR,
41 "failed to load lat control_conf");
42 }
43
44 injector_ = injector;
45 low_bound_acceleration_ = demo_control_task_conf_.bound_acc();
46 return Status::OK();
47}
48
50
52
53std::string DemoControlTask::Name() const { return name_; }
54
56 const localization::LocalizationEstimate *localization,
57 const canbus::Chassis *chassis,
58 const planning::ADCTrajectory *planning_published_trajectory,
59 ControlCommand *cmd) {
60 auto debug = cmd->mutable_debug()->mutable_simple_lon_debug();
61
62 double controller_calculate_acceleration = cmd->acceleration();
63 double command_acceleration =
64 abs(controller_calculate_acceleration) < low_bound_acceleration_
65 ? controller_calculate_acceleration /
66 abs(controller_calculate_acceleration) * low_bound_acceleration_
67 : controller_calculate_acceleration;
68
69 cmd->set_acceleration(command_acceleration);
70 debug->set_acceleration_cmd(command_acceleration);
71
72 return Status::OK();
73}
74
75} // namespace control
76} // 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
std::string Name() const override
DemoControlTask name
void Stop() override
stop DemoControlTask
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
common::Status Reset() override
reset demo control task
std::shared_ptr< DependencyInjector > injector_
common::Status Init(std::shared_ptr< DependencyInjector > injector) override
initialize DemoControlTask
Defines the DemoControlTask class.
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
class register implement
Definition arena_queue.h:37