Apollo 11.0
自动驾驶开放平台
reference_point.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 "absl/strings/str_cat.h"
25
26namespace apollo {
27namespace planning {
28
29namespace {
30// Minimum distance to remove duplicated points.
31const double kDuplicatedPointsEpsilon = 1e-7;
32} // namespace
33
35 const double kappa, const double dkappa)
36 : hdmap::MapPathPoint(map_path_point), kappa_(kappa), dkappa_(dkappa) {}
37
40 kappa_, dkappa_);
41}
42
43double ReferencePoint::kappa() const { return kappa_; }
44
45double ReferencePoint::dkappa() const { return dkappa_; }
46
47std::string ReferencePoint::DebugString() const {
48 return absl::StrCat("{x: ", x(), ", y: ", y(), ", theta: ", heading(),
49 ", kappa: ", kappa(), ", dkappa: ", dkappa(), "}");
50}
51
52void ReferencePoint::RemoveDuplicates(std::vector<ReferencePoint>* points) {
53 CHECK_NOTNULL(points);
54 int count = 0;
55 for (size_t i = 0; i < points->size(); ++i) {
56 auto& last_point = (*points)[count - 1];
57 const auto& this_point = (*points)[i];
58 // Use manhattan distance for save computation time.
59 if (count == 0 ||
60 std::abs(last_point.x() - this_point.x()) > kDuplicatedPointsEpsilon ||
61 std::abs(last_point.y() - this_point.y()) > kDuplicatedPointsEpsilon) {
62 (*points)[count++] = this_point;
63 } else {
64 last_point.add_lane_waypoints(this_point.lane_waypoints());
65 }
66 }
67 points->resize(count);
68}
69
70} // namespace planning
71} // namespace apollo
double y() const
Getter for y component
Definition vec2d.h:57
double x() const
Getter for x component
Definition vec2d.h:54
static PathPoint ToPathPoint(const double x, const double y, const double z=0, const double s=0, const double theta=0, const double kappa=0, const double dkappa=0, const double ddkappa=0)
double heading() const
Definition path.h:118
common::PathPoint ToPathPoint(double s) const
static void RemoveDuplicates(std::vector< ReferencePoint > *points)
Planning module main class.
class register implement
Definition arena_queue.h:37