Apollo 11.0
自动驾驶开放平台
node3d.h
浏览该文件的文档.
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
17/*
18 * @file
19 */
20
21#pragma once
22
23#include <memory>
24#include <string>
25#include <vector>
26
27#include "modules/common_msgs/config_msgs/vehicle_config.pb.h"
28#include "modules/planning/planning_open_space/proto/planner_open_space_config.pb.h"
29
31
32namespace apollo {
33namespace planning {
34
35class Node3d {
36public:
37 Node3d(const double x, const double y, const double phi);
38 Node3d(const double x,
39 const double y,
40 const double phi,
41 const std::vector<double>& XYbounds,
42 const PlannerOpenSpaceConfig& open_space_conf);
43 Node3d(const std::vector<double>& traversed_x,
44 const std::vector<double>& traversed_y,
45 const std::vector<double>& traversed_phi,
46 const std::vector<double>& XYbounds,
47 const PlannerOpenSpaceConfig& open_space_conf);
48 virtual ~Node3d() = default;
50 const common::VehicleParam& vehicle_param_,
51 const double x,
52 const double y,
53 const double phi);
54 double GetCost() const {
55 return traj_cost_ + heuristic_cost_;
56 }
57 double GetTrajCost() const {
58 return traj_cost_;
59 }
60 double GetHeuCost() const {
61 return heuristic_cost_;
62 }
63 int GetGridX() const {
64 return x_grid_;
65 }
66 int GetGridY() const {
67 return y_grid_;
68 }
69 double GetX() const {
70 return x_;
71 }
72 double GetY() const {
73 return y_;
74 }
75 double GetPhi() const {
76 return phi_;
77 }
78 bool operator==(const Node3d& right) const;
79 const std::string& GetIndex() const {
80 return index_;
81 }
82 size_t GetStepSize() const {
83 return step_size_;
84 }
85 bool GetDirec() const {
86 return direction_;
87 }
88 double GetSteer() const {
89 return steering_;
90 }
91 std::shared_ptr<Node3d> GetPreNode() const {
92 return pre_node_;
93 }
94 const std::vector<double>& GetXs() const {
95 return traversed_x_;
96 }
97 const std::vector<double>& GetYs() const {
98 return traversed_y_;
99 }
100 const std::vector<double>& GetPhis() const {
101 return traversed_phi_;
102 }
103 const double& GetTravelDist() const {
104 return travel_distance_;
105 }
106 void SetPre(std::shared_ptr<Node3d> pre_node) {
107 pre_node_ = pre_node;
108 }
109 void SetDirec(bool direction) {
110 direction_ = direction;
111 }
112 void SetTrajCost(double cost) {
113 traj_cost_ = cost;
114 }
115 void SetHeuCost(double cost) {
116 heuristic_cost_ = cost;
117 }
118 void SetSteer(double steering) {
119 steering_ = steering;
120 }
121 void SetTravelDist(double dist) {
122 travel_distance_ = dist;
123 }
124
125private:
126 static std::string ComputeStringIndex(int x_grid, int y_grid, int phi_grid);
127
128private:
129 double x_ = 0.0;
130 double y_ = 0.0;
131 double phi_ = 0.0;
132 size_t step_size_ = 1;
133 std::vector<double> traversed_x_;
134 std::vector<double> traversed_y_;
135 std::vector<double> traversed_phi_;
136 int x_grid_ = 0;
137 int y_grid_ = 0;
138 int phi_grid_ = 0;
139 std::string index_;
140 double traj_cost_ = 0.0;
141 double heuristic_cost_ = 0.0;
142 double cost_ = 0.0;
143 std::shared_ptr<Node3d> pre_node_ = nullptr;
144 double steering_ = 0.0;
145 // true for moving forward and false for moving backward
146 bool direction_ = true;
147 // travel distance in direction_
148 double travel_distance_ = 0.0;
149
150 // park generic
151public:
152 Node3d(const double x,
153 const double y,
154 const double phi,
155 const std::vector<double>& XYbounds,
156 const WarmStartConfig& warm_start_conf);
157
158 Node3d(const std::vector<double>& traversed_x,
159 const std::vector<double>& traversed_y,
160 const std::vector<double>& traversed_phi,
161 const std::vector<double>& XYbounds,
162 const WarmStartConfig& warm_start_conf);
163};
164
165} // namespace planning
166} // namespace apollo
The class of Box2d.
Rectangular (undirected) bounding box in 2-D.
Definition box2d.h:52
bool operator==(const Node3d &right) const
Definition node3d.cc:150
const std::vector< double > & GetYs() const
Definition node3d.h:97
const std::vector< double > & GetPhis() const
Definition node3d.h:100
double GetSteer() const
Definition node3d.h:88
const std::string & GetIndex() const
Definition node3d.h:79
double GetX() const
Definition node3d.h:69
size_t GetStepSize() const
Definition node3d.h:82
virtual ~Node3d()=default
double GetPhi() const
Definition node3d.h:75
void SetHeuCost(double cost)
Definition node3d.h:115
void SetTravelDist(double dist)
Definition node3d.h:121
static apollo::common::math::Box2d GetBoundingBox(const common::VehicleParam &vehicle_param_, const double x, const double y, const double phi)
Definition node3d.cc:138
void SetTrajCost(double cost)
Definition node3d.h:112
void SetDirec(bool direction)
Definition node3d.h:109
double GetY() const
Definition node3d.h:72
void SetPre(std::shared_ptr< Node3d > pre_node)
Definition node3d.h:106
int GetGridX() const
Definition node3d.h:63
bool GetDirec() const
Definition node3d.h:85
double GetTrajCost() const
Definition node3d.h:57
double GetHeuCost() const
Definition node3d.h:60
const double & GetTravelDist() const
Definition node3d.h:103
const std::vector< double > & GetXs() const
Definition node3d.h:94
std::shared_ptr< Node3d > GetPreNode() const
Definition node3d.h:91
void SetSteer(double steering)
Definition node3d.h:118
double GetCost() const
Definition node3d.h:54
int GetGridY() const
Definition node3d.h:66
Planning module main class.
class register implement
Definition arena_queue.h:37