提交 1ce05f67 编写于 作者: Z Zhang Liangliang 提交者: Jiangtao Hu

Planning: added initial definitions of reference line provider. This class...

Planning: added initial definitions of reference line provider. This class will run in a seperate thread and smooth reference lines, so that the time cost for reference line smoother can be amortized to each planning cycle.
上级 69d1a458
......@@ -149,7 +149,7 @@ void Planning::PublishPlanningPb(ADCTrajectory* trajectory_pb,
}
void Planning::RunOnce() {
double start_timestamp = Clock::NowInSecond();
const double start_timestamp = Clock::NowInSecond();
AdapterManager::Observe();
ADCTrajectory not_ready_pb;
auto* not_ready = not_ready_pb.mutable_decision()
......
......@@ -47,6 +47,20 @@ cc_library(
],
)
cc_library(
name = "reference_line_provider",
srcs = [
"reference_line_provider.cc",
],
hdrs = [
"reference_line_provider.h",
],
deps = [
"reference_line",
"reference_line_smoother",
],
)
cc_test(
name = "reference_line_smoother_test",
size = "small",
......
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file reference_line_provider.cc
*
* @brief Implementation of the class ReferenceLineProvider.
*/
#include "modules/planning/reference_line/reference_line_provider.h"
/**
* @namespace apollo::planning
* @brief apollo::planning
*/
namespace apollo {
namespace planning {
void ReferenceLineProvider::Init() {
// TODO: implement this function.
is_initialized_ = true;
}
bool ReferenceLineProvider::Start() {
if (!is_initialized_) {
AERROR << "LincolnController has NOT been initiated.";
return false;
}
const auto &func = [this] { Generate(); };
thread_.reset(new std::thread(func));
return false;
}
void ReferenceLineProvider::Generate() {
// TODO: implement this function.
}
std::vector<ReferenceLine> ReferenceLineProvider::GetReferenceLines() {
// TODO: implement this function.
return reference_line_groups_.back();
}
} // namespace planning
} // namespace apollo
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file reference_line_provider.h
*
* @brief Declaration of the class ReferenceLineProvider.
*/
#ifndef MODULES_PLANNING_REFERENCE_LINE_REFERENCE_LINE_PROVIDER_H_
#define MODULES_PLANNING_REFERENCE_LINE_REFERENCE_LINE_PROVIDER_H_
#include <memory>
#include <thread>
#include <vector>
#include "modules/planning/reference_line/reference_line.h"
#include "modules/planning/reference_line/reference_line_smoother.h"
/**
* @namespace apollo::planning
* @brief apollo::planning
*/
namespace apollo {
namespace planning {
/**
* @class ReferenceLineProvider
* @brief The class of ReferenceLineProvider.
* It provides smoothed reference line to planning.
*/
class ReferenceLineProvider {
public:
/**
* @brief Default destructor.
*/
virtual ~ReferenceLineProvider() = default;
void Init();
bool Start();
std::vector<ReferenceLine> GetReferenceLines();
private:
DECLARE_SINGLETON(ReferenceLineProvider);
void Generate();
bool is_initialized_ = false;
std::unique_ptr<std::thread> thread_;
std::vector<std::vector<ReferenceLine>> reference_line_groups_;
};
} // namespace planning
} // namespace apollo
#endif // MODULES_PLANNING_REFERENCE_LINE_REFERENCE_LINE_PROVIDER_H_
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册