Node.h
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <experimental/memory>
5#include <memory>
6#include <optional>
7#include <vector>
8
9#include <Eigen/Geometry>
10
12
14{
15
16 struct Costs
17 {
18 float euclidian = 0.F;
19 float obstacleProximity = 0.F; // penalty for moving closer to obstacles
20 float obstacleProximity2 = 0.F; // continuous penalty for being close to obstacles
22 float forwardMovement = 0.F;
23 float smoothnessCosts = 0.F;
24
25 float
32
33 Costs
34 operator+(const Costs& other) const
35 {
36 return Costs{
37 .euclidian = this->euclidian + other.euclidian,
38 .obstacleProximity = this->obstacleProximity + other.obstacleProximity,
39 .obstacleProximity2 = this->obstacleProximity2 + other.obstacleProximity2,
40 .orientationDifference = this->orientationDifference + other.orientationDifference,
41 .forwardMovement = this->forwardMovement + other.forwardMovement,
42 .smoothnessCosts = this->smoothnessCosts + other.smoothnessCosts,
43 };
44 }
45 };
46
47 class Node;
48 using NodePtr = std::shared_ptr<Node>;
49
50 /**
51 * A Node can store data to all valid neighbors (successors) and a precessor.
52 * It offers methods to determine the complete path to the starting point.
53 */
54 class Node
55 {
56 public:
57 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
58
59 Node(const Eigen::Vector2f& position, float obstacleDistance, float orientation_deg);
60 Node() = default;
61
62 void
63 initialize(const Eigen::Vector2f& position, float obstacleDistance, float orientation_deg);
64
65 Eigen::Vector2f position;
66 float orientation_deg = -1.F;
67 // Maybe replace orientation_deg with orientation_index and reference costmap somehow? (maybe reference is not needed because it is already used in a*-planning class)
68
69 /// All nodes that are adjacent to this one.
70 std::vector<std::experimental::observer_ptr<Node>> successors;
71 /// For traversal.
73 std::optional<Costs> predecessorCosts;
74
76
77 /// Collects all predecessors in order to generate path to starting point.
78 std::vector<const Node*> traversePredecessors() const;
79
80 // algorithm runtime information
81 bool inClosedSet = false;
82 bool inOpenSet = false;
83 float fScore = -1.F;
84 float gScore = -1.F;
85 };
86
87} // namespace armarx::navigation::algorithms::orientation_aware
std::vector< const Node * > traversePredecessors() const
Collects all predecessors in order to generate path to starting point.
Definition Node.cpp:24
void initialize(const Eigen::Vector2f &position, float obstacleDistance, float orientation_deg)
Definition Node.cpp:16
std::experimental::observer_ptr< Node > predecessor
For traversal.
Definition Node.h:72
std::vector< std::experimental::observer_ptr< Node > > successors
All nodes that are adjacent to this one.
Definition Node.h:70
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Node(const Eigen::Vector2f &position, float obstacleDistance, float orientation_deg)
Definition Node.cpp:10
Costs operator+(const Costs &other) const
Definition Node.h:34