Apollo 11.0
自动驾驶开放平台
constant_deceleration_trajectory1d.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
22
23#include <cmath>
24
25#include "cyber/common/log.h"
27
28namespace apollo {
29namespace planning {
30
32 const double init_s, const double init_v, const double a)
33 : init_s_(init_s), init_v_(init_v), deceleration_(-a) {
34 if (init_v_ < -FLAGS_numerical_epsilon) {
35 AERROR << "negative init v = " << init_v_;
36 }
37 init_v_ = std::fabs(init_v_);
38 ACHECK(deceleration_ > 0.0);
39 end_t_ = init_v_ / deceleration_;
40 end_s_ = init_v_ * init_v_ / (2.0 * deceleration_) + init_s_;
41}
42
43double ConstantDecelerationTrajectory1d::Evaluate_s(const double t) const {
44 if (t < end_t_) {
45 double curr_v = init_v_ - deceleration_ * t;
46 double delta_s = (curr_v + init_v_) * t * 0.5;
47 return init_s_ + delta_s;
48 } else {
49 return end_s_;
50 }
51}
52
53double ConstantDecelerationTrajectory1d::Evaluate_v(const double t) const {
54 if (t < end_t_) {
55 return init_v_ - deceleration_ * t;
56 } else {
57 return 0.0;
58 }
59}
60
61double ConstantDecelerationTrajectory1d::Evaluate_a(const double t) const {
62 if (t < end_t_) {
63 return -deceleration_;
64 } else {
65 return 0.0;
66 }
67}
68
69double ConstantDecelerationTrajectory1d::Evaluate_j(const double t) const {
70 return 0.0;
71}
72
73double ConstantDecelerationTrajectory1d::ParamLength() const { return end_t_; }
74
75std::string ConstantDecelerationTrajectory1d::ToString() const { return ""; }
76
77double ConstantDecelerationTrajectory1d::Evaluate(const std::uint32_t order,
78 const double param) const {
79 switch (order) {
80 case 0:
81 return Evaluate_s(param);
82 case 1:
83 return Evaluate_v(param);
84 case 2:
85 return Evaluate_a(param);
86 case 3:
87 return Evaluate_j(param);
88 }
89 return 0.0;
90}
91
92} // namespace planning
93} // namespace apollo
ConstantDecelerationTrajectory1d(const double init_s, const double init_v, const double a)
double Evaluate(const std::uint32_t order, const double param) const override
Planning module main class.
#define ACHECK(cond)
Definition log.h:80
#define AERROR
Definition log.h:44
class register implement
Definition arena_queue.h:37