Apollo 11.0
自动驾驶开放平台
lattice_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 "cyber/common/log.h"
24
25namespace apollo {
26namespace planning {
27
29 std::shared_ptr<Curve1d> ptr_trajectory1d) {
30 ptr_trajectory1d_ = ptr_trajectory1d;
31}
32
33double LatticeTrajectory1d::Evaluate(const std::uint32_t order,
34 const double param) const {
35 double param_length = ptr_trajectory1d_->ParamLength();
36 if (param < param_length) {
37 return ptr_trajectory1d_->Evaluate(order, param);
38 }
39
40 // do constant acceleration extrapolation;
41 // to align all the trajectories with time.
42 double p = ptr_trajectory1d_->Evaluate(0, param_length);
43 double v = ptr_trajectory1d_->Evaluate(1, param_length);
44 double a = ptr_trajectory1d_->Evaluate(2, param_length);
45
46 double t = param - param_length;
47
48 switch (order) {
49 case 0:
50 return p + v * t + 0.5 * a * t * t;
51 case 1:
52 return v + a * t;
53 case 2:
54 return a;
55 default:
56 return 0.0;
57 }
58}
59
61 return ptr_trajectory1d_->ParamLength();
62}
63
64std::string LatticeTrajectory1d::ToString() const {
65 return ptr_trajectory1d_->ToString();
66}
67
69 return has_target_position_;
70}
71
73 return has_target_velocity_;
74}
75
76bool LatticeTrajectory1d::has_target_time() const { return has_target_time_; }
77
79 ACHECK(has_target_position_);
80 return target_position_;
81}
82
84 ACHECK(has_target_velocity_);
85 return target_velocity_;
86}
87
89 ACHECK(has_target_time_);
90 return target_time_;
91}
92
93void LatticeTrajectory1d::set_target_position(double target_position) {
94 target_position_ = target_position;
95 has_target_position_ = true;
96}
97
98void LatticeTrajectory1d::set_target_velocity(double target_velocity) {
99 target_velocity_ = target_velocity;
100 has_target_velocity_ = true;
101}
102
103void LatticeTrajectory1d::set_target_time(double target_time) {
104 target_time_ = target_time;
105 has_target_time_ = true;
106}
107
108} // namespace planning
109} // namespace apollo
void set_target_velocity(double target_velocity)
virtual double Evaluate(const std::uint32_t order, const double param) const
void set_target_position(double target_position)
LatticeTrajectory1d(std::shared_ptr< Curve1d > ptr_trajectory1d)
Planning module main class.
#define ACHECK(cond)
Definition log.h:80
class register implement
Definition arena_queue.h:37