Hybrid A* Planner
 All Classes Namespaces Files Functions Variables Friends Pages
node3d.h
1 #ifndef NODE3D_H
2 #define NODE3D_H
3 
4 #include <cmath>
5 
6 #include "constants.h"
7 #include "helper.h"
8 namespace HybridAStar {
14 class Node3D {
15  public:
16 
18  Node3D(): Node3D(0, 0, 0, 0, 0, nullptr) {}
20  Node3D(float x, float y, float t, float g, float h, const Node3D* pred, int prim = 0) {
21  this->x = x;
22  this->y = y;
23  this->t = t;
24  this->g = g;
25  this->h = h;
26  this->pred = pred;
27  this->o = false;
28  this->c = false;
29  this->idx = -1;
30  this->prim = prim;
31  }
32 
33  // GETTER METHODS
35  float getX() const { return x; }
37  float getY() const { return y; }
39  float getT() const { return t; }
41  float getG() const { return g; }
43  float getH() const { return h; }
45  float getC() const { return g + h; }
47  int getIdx() const { return idx; }
49  int getPrim() const { return prim; }
51  bool isOpen() const { return o; }
53  bool isClosed() const { return c; }
55  const Node3D* getPred() const { return pred; }
56 
57  // SETTER METHODS
59  void setX(const float& x) { this->x = x; }
61  void setY(const float& y) { this->y = y; }
63  void setT(const float& t) { this->t = t; }
65  void setG(const float& g) { this->g = g; }
67  void setH(const float& h) { this->h = h; }
69  int setIdx(int width, int height) { this->idx = (int)(t / Constants::deltaHeadingRad) * width * height + (int)(y) * width + (int)(x); return idx;}
71  void setPrim(const int& prim) { this->prim = prim; }
73  void open() { o = true; c = false;}
75  void close() { c = true; o = false; }
77  void setPred(const Node3D* pred) { this->pred = pred; }
78 
79  // UPDATE METHODS
81  void updateG();
82 
83  // CUSTOM OPERATORS
85  bool operator == (const Node3D& rhs) const;
86 
87  // RANGE CHECKING
89  bool isInRange(const Node3D& goal) const;
90 
91  // GRID CHECKING
93  bool isOnGrid(const int width, const int height) const;
94 
95  // SUCCESSOR CREATION
97  Node3D* createSuccessor(const int i);
98 
99  // CONSTANT VALUES
101  static const int dir;
103  static const float dx[];
105  static const float dy[];
107  static const float dt[];
108 
109  private:
111  float x;
113  float y;
115  float t;
117  float g;
119  float h;
121  int idx;
123  bool o;
125  bool c;
127  int prim;
129  const Node3D* pred;
130 };
131 }
132 #endif // NODE3D_H
float y
the y position
Definition: node3d.h:113
int setIdx(int width, int height)
set and get the index of the node in the 3D grid
Definition: node3d.h:69
const Node3D * getPred() const
determine whether the node is open
Definition: node3d.h:55
bool isInRange(const Node3D &goal) const
Determines whether it is appropriate to find a analytical solution.
Definition: node3d.cpp:38
A three dimensional node class that is at the heart of the algorithm.
Definition: node3d.h:14
void setPred(const Node3D *pred)
set a pointer to the predecessor of the node
Definition: node3d.h:77
float getX() const
get the x position
Definition: node3d.h:35
float h
the cost-to-go
Definition: node3d.h:119
float getC() const
get the total estimated cost
Definition: node3d.h:45
This is a collection of constants that are used throughout the project.
bool isOnGrid(const int width, const int height) const
Validity check to test, whether the node is in the 3D array.
Definition: node3d.cpp:30
float getH() const
get the cost-to-come (heuristic value)
Definition: node3d.h:43
float g
the cost-so-far
Definition: node3d.h:117
bool isOpen() const
determine whether the node is open
Definition: node3d.h:51
void setY(const float &y)
set the y position
Definition: node3d.h:61
void updateG()
Updates the cost-so-far for the node x' coming from its predecessor. It also discovers the node...
Definition: node3d.cpp:73
static const float dt[]
Possible movements regarding heading theta.
Definition: node3d.h:107
Node3D(float x, float y, float t, float g, float h, const Node3D *pred, int prim=0)
Constructor for a node with the given arguments.
Definition: node3d.h:20
int prim
the motion primitive of the node
Definition: node3d.h:127
const Node3D * pred
the predecessor pointer
Definition: node3d.h:129
Node3D * createSuccessor(const int i)
Creates a successor in the continous space.
Definition: node3d.cpp:48
void setH(const float &h)
set the cost-to-come (heuristic value)
Definition: node3d.h:67
void setX(const float &x)
set the x position
Definition: node3d.h:59
void setT(const float &t)
set the heading theta
Definition: node3d.h:63
void close()
close the node
Definition: node3d.h:75
void open()
open the node
Definition: node3d.h:73
bool isClosed() const
determine whether the node is closed
Definition: node3d.h:53
float t
the heading theta
Definition: node3d.h:115
bool operator==(const Node3D &rhs) const
Custom operator to compare nodes. Nodes are equal if their x and y position as well as heading is sim...
Definition: node3d.cpp:297
bool o
the open value
Definition: node3d.h:123
static const float dx[]
Possible movements in the x direction.
Definition: node3d.h:103
float getY() const
get the y position
Definition: node3d.h:37
static const float dy[]
Possible movements in the y direction.
Definition: node3d.h:105
void setG(const float &g)
set the cost-so-far (real value)
Definition: node3d.h:65
int getIdx() const
get the index of the node in the 3D array
Definition: node3d.h:47
float getG() const
get the cost-so-far (real value)
Definition: node3d.h:41
float getT() const
get the heading theta
Definition: node3d.h:39
int idx
the index of the node in the 3D array
Definition: node3d.h:121
float x
the x position
Definition: node3d.h:111
static const int dir
Number of possible directions.
Definition: node3d.h:101
bool c
the closed value
Definition: node3d.h:125
int getPrim() const
get the number associated with the motion primitive of the node
Definition: node3d.h:49
Node3D()
The default constructor for 3D array initialization.
Definition: node3d.h:18
void setPrim(const int &prim)
set the primitive
Definition: node3d.h:71
This is a collection of helper functions that are used throughout the project.