Apollo  6.0
Open source self driving car software
node3d.h
Go to the documentation of this file.
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 
29 #include "modules/planning/proto/planner_open_space_config.pb.h"
30 
31 namespace apollo {
32 namespace planning {
33 
34 class Node3d {
35  public:
36  Node3d(const double x, const double y, const double phi);
37  Node3d(const double x, const double y, const double phi,
38  const std::vector<double>& XYbounds,
39  const PlannerOpenSpaceConfig& open_space_conf);
40  Node3d(const std::vector<double>& traversed_x,
41  const std::vector<double>& traversed_y,
42  const std::vector<double>& traversed_phi,
43  const std::vector<double>& XYbounds,
44  const PlannerOpenSpaceConfig& open_space_conf);
45  virtual ~Node3d() = default;
47  const common::VehicleParam& vehicle_param_, const double x,
48  const double y, const double phi);
49  double GetCost() const { return traj_cost_ + heuristic_cost_; }
50  double GetTrajCost() const { return traj_cost_; }
51  double GetHeuCost() const { return heuristic_cost_; }
52  int GetGridX() const { return x_grid_; }
53  int GetGridY() const { return y_grid_; }
54  int GetGridPhi() const { return phi_grid_; }
55  double GetX() const { return x_; }
56  double GetY() const { return y_; }
57  double GetPhi() const { return phi_; }
58  bool operator==(const Node3d& right) const;
59  const std::string& GetIndex() const { return index_; }
60  size_t GetStepSize() const { return step_size_; }
61  bool GetDirec() const { return direction_; }
62  double GetSteer() const { return steering_; }
63  std::shared_ptr<Node3d> GetPreNode() const { return pre_node_; }
64  const std::vector<double>& GetXs() const { return traversed_x_; }
65  const std::vector<double>& GetYs() const { return traversed_y_; }
66  const std::vector<double>& GetPhis() const { return traversed_phi_; }
67  void SetPre(std::shared_ptr<Node3d> pre_node) { pre_node_ = pre_node; }
68  void SetDirec(bool direction) { direction_ = direction; }
69  void SetTrajCost(double cost) { traj_cost_ = cost; }
70  void SetHeuCost(double cost) { heuristic_cost_ = cost; }
71  void SetSteer(double steering) { steering_ = steering; }
72 
73  private:
74  static std::string ComputeStringIndex(int x_grid, int y_grid, int phi_grid);
75 
76  private:
77  double x_ = 0.0;
78  double y_ = 0.0;
79  double phi_ = 0.0;
80  size_t step_size_ = 1;
81  std::vector<double> traversed_x_;
82  std::vector<double> traversed_y_;
83  std::vector<double> traversed_phi_;
84  int x_grid_ = 0;
85  int y_grid_ = 0;
86  int phi_grid_ = 0;
87  std::string index_;
88  double traj_cost_ = 0.0;
89  double heuristic_cost_ = 0.0;
90  double cost_ = 0.0;
91  std::shared_ptr<Node3d> pre_node_ = nullptr;
92  double steering_ = 0.0;
93  // true for moving forward and false for moving backward
94  bool direction_ = true;
95 };
96 
97 } // namespace planning
98 } // namespace apollo
Definition: node3d.h:34
const std::vector< double > & GetPhis() const
Definition: node3d.h:66
double GetY() const
Definition: node3d.h:56
double GetTrajCost() const
Definition: node3d.h:50
void SetTrajCost(double cost)
Definition: node3d.h:69
double GetX() const
Definition: node3d.h:55
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool operator==(const Node3d &right) const
Planning module main class. It processes GPS and IMU as input, to generate planning info...
void SetSteer(double steering)
Definition: node3d.h:71
Node3d(const double x, const double y, const double phi)
double GetPhi() const
Definition: node3d.h:57
Rectangular (undirected) bounding box in 2-D.
Definition: box2d.h:52
double GetSteer() const
Definition: node3d.h:62
void SetHeuCost(double cost)
Definition: node3d.h:70
const std::vector< double > & GetYs() const
Definition: node3d.h:65
const std::vector< double > & GetXs() const
Definition: node3d.h:64
static apollo::common::math::Box2d GetBoundingBox(const common::VehicleParam &vehicle_param_, const double x, const double y, const double phi)
void SetDirec(bool direction)
Definition: node3d.h:68
double GetCost() const
Definition: node3d.h:49
std::shared_ptr< Node3d > GetPreNode() const
Definition: node3d.h:63
bool GetDirec() const
Definition: node3d.h:61
virtual ~Node3d()=default
int GetGridPhi() const
Definition: node3d.h:54
int GetGridX() const
Definition: node3d.h:52
size_t GetStepSize() const
Definition: node3d.h:60
int GetGridY() const
Definition: node3d.h:53
The class of Box2d. Here, the x/y axes are respectively Forward/Left, as opposed to what happens in e...
const std::string & GetIndex() const
Definition: node3d.h:59
double GetHeuCost() const
Definition: node3d.h:51
void SetPre(std::shared_ptr< Node3d > pre_node)
Definition: node3d.h:67