3#include <ompl/util/Console.h>
5#include "../../base/PlannerSettings.h"
6#include "../../utils/PlannerUtils.hpp"
75 GNode(
double xx,
double yy,
double tt) {
106 GNode(
double xx,
double yy,
double tt,
int type) {
138 GNode(
double xx,
double yy,
double tt,
int type,
double steer_c) {
170 GNode(
double xx,
double yy,
double tt,
int type,
double steer_c,
double *c,
204 GNode(
double xx,
double yy,
double tt,
int type,
double steer_c,
double *c,
205 double *orien,
double xxx,
double yyy) {
276 if (
this == &n)
return *
this;
331 local_cost[i] = 1000;
343 double parent_x = parent_node->
x;
344 double parent_y = parent_node->
y;
346 theta = atan2((
y - parent_y) / dt, (
x - parent_x) / dt);
348 OMPL_INFORM(
"setOrientation %f instead of %f",
theta, parent_node->
theta);
357 return (this->
x == rhs.
x) && (this->
y == rhs.
y);
366 sprintf(str,
"Node position : (%d,%d,%f)\n",
x,
y,
theta);
379 float xd = ((float)
x - (
float)nodeGoal.
x);
380 float yd = ((float)
y - (
float)nodeGoal.
y);
383 return sqrt(xd * xd + yd * yd);
394 if ((
x == nodeGoal.
x) && (
y == nodeGoal.
y)) {
395 OMPL_DEBUG(
"Goal reached");
411 GNode *parent_node) {
414 double th = this->
theta;
419 parent_x = parent_node->
x;
420 parent_y = parent_node->
y;
422 OMPL_ERROR(
"GNode has no parent node.");
432 int cnt_successors = 0;
434 auto *th1 =
new GNode(
x,
y, th);
435 auto *pr1 =
new GNode(
x - 1,
y, 1.0 * M_PI);
436 pr1->CHECK_SUCCESSOR = 1;
437 th1->CHECK_SUCCESSOR = 1;
438 if (
lineofsight(th1, pr1) && !((parent_x ==
x - 1) && (parent_y ==
y))) {
440 NewNode =
GNode(
x - 1,
y, pr1->theta);
448 auto *th2 =
new GNode(
x,
y, th);
449 auto *pr2 =
new GNode(
x,
y - 1, 1.5 * M_PI);
451 pr2->CHECK_SUCCESSOR = 1;
452 th2->CHECK_SUCCESSOR = 1;
453 if (
lineofsight(th2, pr2) && !((parent_x ==
x) && (parent_y ==
y - 1))) {
455 NewNode =
GNode(
x,
y - 1, pr2->theta);
464 auto *th3 =
new GNode(
x,
y, th);
465 auto *pr3 =
new GNode(
x + 1,
y, 0.0 * M_PI);
467 pr3->CHECK_SUCCESSOR = 1;
468 th3->CHECK_SUCCESSOR = 1;
469 if (
lineofsight(th3, pr3) && !((parent_x ==
x + 1) && (parent_y ==
y))) {
471 NewNode =
GNode(
x + 1,
y, pr3->theta);
480 auto *th4 =
new GNode(
x,
y, th);
481 auto *pr4 =
new GNode(
x + 1,
y + 1, 0.25 * M_PI);
483 pr4->CHECK_SUCCESSOR = 1;
484 th4->CHECK_SUCCESSOR = 1;
486 !((parent_x ==
x + 1) && (parent_y ==
y + 1))) {
488 NewNode =
GNode(
x + 1,
y + 1, pr4->theta);
497 auto *th5 =
new GNode(
x,
y, th);
498 auto *pr5 =
new GNode(
x - 1,
y - 1, 1.25 * M_PI);
500 pr5->CHECK_SUCCESSOR = 1;
501 th5->CHECK_SUCCESSOR = 1;
503 !((parent_x ==
x - 1) && (parent_y ==
y - 1))) {
506 NewNode =
GNode(
x - 1,
y - 1, pr5->theta);
515 auto *th6 =
new GNode(
x,
y, th);
516 auto *pr6 =
new GNode(
x + 1,
y - 1, 1.75 * M_PI);
518 pr6->CHECK_SUCCESSOR = 1;
519 th6->CHECK_SUCCESSOR = 1;
521 !((parent_x ==
x + 1) && (parent_y ==
y - 1))) {
524 NewNode =
GNode(
x + 1,
y - 1, pr6->theta);
533 auto *th7 =
new GNode(
x,
y, th);
534 auto *pr7 =
new GNode(
x - 1,
y + 1, 0.75 * M_PI);
536 pr7->CHECK_SUCCESSOR = 1;
537 th7->CHECK_SUCCESSOR = 1;
539 !((parent_x ==
x - 1) && (parent_y ==
y + 1))) {
542 NewNode =
GNode(
x - 1,
y + 1, pr7->theta);
551 auto *th8 =
new GNode(
x,
y, th);
552 auto *pr8 =
new GNode(
x,
y + 1, 0.5 * M_PI);
554 pr8->CHECK_SUCCESSOR = 1;
555 th8->CHECK_SUCCESSOR = 1;
556 if (
lineofsight(th8, pr8) && !((parent_x ==
x) && (parent_y ==
y + 1))) {
559 NewNode =
GNode(
x,
y + 1, pr8->theta);
568 if (cnt_successors < 1) {
582 double dx = (successor.
x -
x) * unit;
583 double dy = (successor.
y -
y) * unit;
585 return std::sqrt(dx * dx + dy * dy);
597 return static_cast<float>(
625 return static_cast<double>(
667 GNode *parent_node) {
679 return line(parent_node, successor);
Definition: gnode_base.h:9
double x_r
Definition: gnode_base.h:39
double theta
Orientation associated to the best node.
Definition: gnode_base.h:45
bool hasParent
Definition: gnode_base.h:47
int start_y
Definition: gnode_base.h:34
double steer_cost
Cost associated to the best Node selected.
Definition: gnode_base.h:14
int CHECK_SUCCESSOR
Definition: gnode_base.h:28
int goal_x
Definition: gnode_base.h:30
GNode_base * parent
Definition: gnode_base.h:49
int x
X and Y coordinates of the Node.
Definition: gnode_base.h:37
int nEdges
Number of outgoing edges per node.
Definition: gnode_base.h:17
static bool line(const GNode_base *parent_node, const GNode_base *successor)
line(GNode *successor,GNode *parent_node)
Definition: gnode_base.cpp:43
double * orientations
array of possible orientations
Definition: gnode_base.h:23
int goal_y
Definition: gnode_base.h:31
bool steer
Flag to indicate if node hase been generated by a steering function.
Definition: gnode_base.h:42
double y_r
Definition: gnode_base.h:39
int READ_OR
flag to read orientations from Map
Definition: gnode_base.h:26
int y
Definition: gnode_base.h:37
int start_x
Definition: gnode_base.h:33
double * costs
Cost per each orientation associated to the node.
Definition: gnode_base.h:20
GNode_base * child
Definition: gnode_base.h:50
GNode(double xx, double yy, double tt, int type)
Definition: gnode.h:106
GNode(double xx, double yy, double tt, int type, double steer_c, double *c, double *orien, double xxx, double yyy)
Definition: gnode.h:204
GNode()
Different constructors.
Definition: gnode.h:15
GNode(double xx, double yy, double tt, int type, double steer_c)
Definition: gnode.h:138
bool IsGoal(const GNode &nodeGoal)
============================================================================================ bool IsG...
Definition: gnode.h:390
bool operator<(const GNode &n) const
Definition: gnode.h:321
bool operator!=(const GNode &n)
Definition: gnode.h:316
float GoalDistanceEstimate(GNode &nodeGoal)
============================================================================================ GoalDist...
Definition: gnode.h:375
bool IsSameState(GNode &rhs)
============================================================================================ bool IsS...
Definition: gnode.h:356
bool lineofsight(GNode *parent_node, GNode *successor)
============================================================================================ lineofsi...
Definition: gnode.h:678
float GetCostTraj(GNode &successor)
float GetCostTraj( GNode &successor ) get the cost of the trajectory that connect the current node to...
Definition: gnode.h:593
bool GetSuccessors_or(ThetaStarSearch< GNode > *thetastarsearch, GNode *parent_node)
=========================================== bool GetSuccessors( ThetaStarSearch<GNode> <em>thetastars...
Definition: gnode.h:410
bool operator==(const GNode &n)
Definition: gnode.h:311
GNode(double xx, double yy)
Definition: gnode.h:44
double * getLineCost()
============================================================================================
Definition: gnode.h:326
GNode(double xx, double yy, double tt, int type, double steer_c, double *c, double *orien)
Definition: gnode.h:170
double GetCost(GNode &successor)
============================================================================================ float Ge...
Definition: gnode.h:580
bool setOrientation(GNode *parent_node)
============================================================================================ setOrien...
Definition: gnode.h:342
bool setType(int type)
============================================================================================ setType(...
Definition: gnode.h:653
GNode(double xx, double yy, double tt)
Definition: gnode.h:75
bool GetSuccessors(ThetaStarSearch< GNode > *thetastarsearch, GNode *parent_node)
=========================================== bool GetSuccessors( ThetaStarSearch<GNode> <em>thetastars...
Definition: gnode.h:666
GNode(const GNode &n)
Definition: gnode.h:238
GNode & operator=(const GNode &n)
Definition: gnode.h:275
void PrintNodeInfo()
============================================================================================ void Pri...
Definition: gnode.h:364
double GetCostTrajFromParent(GNode &parent, GNode &successor)
float GetCostTraj( GNode &successor ) get the cost of the trajectory that connect the current node to...
Definition: gnode.h:623
~GNode() override
Definition: gnode.h:270
Definition: stl_thetastar.h:58
virtual bool AddSuccessor(UserState &State)
Definition: stl_thetastar.h:678
ob::State * StateFromXY(double x, double y)
Definition: Primitives.cpp:14
ompl::base::OptimizationObjectivePtr objective
Definition: PlannerSettings.h:409
std::shared_ptr< Environment > environment
Environment used for planning.
Definition: PlannerSettings.h:73
PlannerSettings::GlobalSettings::OmplSettings ompl
static PlannerSettings::GlobalSettings settings
Definition: PlannerSettings.h:699