Apollo 11.0
自动驾驶开放平台
control_task_extend.h
浏览该文件的文档.
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
22#pragma once
23
24#include <memory>
25#include <string>
26
27#include "modules/common_msgs/config_msgs/vehicle_config.pb.h"
28#include "modules/common_msgs/control_msgs/control_cmd.pb.h"
29#include "modules/common_msgs/localization_msgs/localization.pb.h"
30#include "modules/common_msgs/planning_msgs/planning.pb.h"
31#include "modules/control/control_component/proto/control_debug.pb.h"
32
33#include "cyber/common/file.h"
38
43namespace apollo {
44namespace control {
45
52public:
57
61 virtual ~ControlTaskExtend() {}
62
72 std::string Name() const;
73
74protected:
75 template <typename T>
76 bool LoadParamsPipelineConfig(T *pipeline_config);
77
78 bool LoadCalibrationTable(const std::string &calibration_table_path, calibration_table *calibration_table_conf);
79
81 const localization::LocalizationEstimate *localization,
82 const canbus::Chassis *chassis,
83 const planning::ADCTrajectory *trajectory);
84 bool IsForwardModel();
85 bool IsEdgeFollow();
86 bool CheckInPit(double pit_replan_check_time, double pit_replan_check_count, double vehicle_speed, bool replan);
87 bool IsLargeCurvature(const double ref_curvature, const double min_large_ref_curvature, bool *is_in_large_curvature);
88 bool IsLeftCurvature(const double ref_curvature);
89 double GetVehicleSpeed(
90 std::shared_ptr<DependencyInjector> injector,
91 const bool &use_filter,
92 const double &filter_coeff);
93 double ThrottleCmdFilter(const bool &use_filter, const double &filter_coeff, const double &throttle);
94
95private:
96 const localization::LocalizationEstimate *localization_ = nullptr;
97 const canbus::Chassis *chassis_ = nullptr;
98 const planning::ADCTrajectory *trajectory_message_ = nullptr;
99 const std::string name_;
100
101 double vehicle_speed_last_ = 0.0;
102 double throttle_last_ = 0.0;
103};
104
105template <typename T>
107 int status;
108 std::string class_name = abi::__cxa_demangle(typeid(*this).name(), 0, 0, &status);
109 AINFO << "class_name is " << class_name;
110 // Generate the default task config path from PluginManager.
111 std::string pipeline_config_path
113 class_name, "conf/params_pipeline.pb.txt");
114 AINFO << "pipeline_config_path is " << pipeline_config_path;
115
116 if (!apollo::cyber::common::GetProtoFromFile(pipeline_config_path, pipeline_config)) {
117 AERROR << "Load config of " << class_name << " failed!";
118 return false;
119 }
120 AINFO << "Load the [" << class_name << "] params pipeline file successfully, file path: " << pipeline_config_path;
121 return true;
122}
123
124} // namespace control
125} // namespace apollo
bool IsLargeCurvature(const double ref_curvature, const double min_large_ref_curvature, bool *is_in_large_curvature)
double ThrottleCmdFilter(const bool &use_filter, const double &filter_coeff, const double &throttle)
bool VehicleStatusIdentificationUpdate(const localization::LocalizationEstimate *localization, const canbus::Chassis *chassis, const planning::ADCTrajectory *trajectory)
bool IsLeftCurvature(const double ref_curvature)
bool LoadParamsPipelineConfig(T *pipeline_config)
std::string Name() const
reset ControlTaskAgent
bool LoadCalibrationTable(const std::string &calibration_table_path, calibration_table *calibration_table_conf)
bool CheckInPit(double pit_replan_check_time, double pit_replan_check_count, double vehicle_speed, bool replan)
double GetVehicleSpeed(std::shared_ptr< DependencyInjector > injector, const bool &use_filter, const double &filter_coeff)
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
Defines the Controller base class.
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
class register implement
Definition arena_queue.h:37