Apollo 11.0
自动驾驶开放平台
piecewise_jerk_trajectory1d.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 <algorithm>
24
25#include "cyber/common/log.h"
27
28namespace apollo {
29namespace planning {
30
32 const double v,
33 const double a) {
34 last_p_ = p;
35 last_v_ = v;
36 last_a_ = a;
37 param_.push_back(0.0);
38}
39
41 const double param) {
42 CHECK_GT(param, FLAGS_numerical_epsilon);
43
44 param_.push_back(param_.back() + param);
45
46 segments_.emplace_back(last_p_, last_v_, last_a_, jerk, param);
47
48 last_p_ = segments_.back().end_position();
49
50 last_v_ = segments_.back().end_velocity();
51
52 last_a_ = segments_.back().end_acceleration();
53}
54
55double PiecewiseJerkTrajectory1d::Evaluate(const std::uint32_t order,
56 const double param) const {
57 auto it_lower = std::lower_bound(param_.begin(), param_.end(), param);
58
59 if (it_lower == param_.begin()) {
60 return segments_[0].Evaluate(order, param);
61 }
62
63 if (it_lower == param_.end()) {
64 auto index = std::max(0, static_cast<int>(param_.size() - 2));
65 return segments_.back().Evaluate(order, param - param_[index]);
66 }
67
68 auto index = std::distance(param_.begin(), it_lower);
69 return segments_[index - 1].Evaluate(order, param - param_[index - 1]);
70}
71
72double PiecewiseJerkTrajectory1d::ParamLength() const { return param_.back(); }
73
74std::string PiecewiseJerkTrajectory1d::ToString() const { return ""; }
75
76} // namespace planning
77} // namespace apollo
void AppendSegment(const double jerk, const double param)
double Evaluate(const std::uint32_t order, const double param) const
PiecewiseJerkTrajectory1d(const double p, const double v, const double a)
Planning module main class.
class register implement
Definition arena_queue.h:37