![]() |
hivemind 1.0.0
|
Main class responsible for handling creation of routes between keyframes. More...
#include <routemaker.h>
Public Member Functions | |
Routemaker (const Core::UTMCoordinate &origin, int size) | |
Instatiates a routemaker object, along with it's Heightmap member. | |
std::vector< Core::CartesianCoordinate > | MakeRoute (const Core::Keyframe &a, const Core::Keyframe &b) |
Creates a a vector of coordinates defining a path between two keyframes. | |
NodePtr | GetNode (uint32_t x, uint32_t y) const |
Get a node at a position. | |
void | UpdateOrigin (Core::UTMCoordinate UTMOrigin, int size) |
Updates the origin coordinate and the size of the map. | |
void | UpdateResolution () |
![]() | |
virtual std::vector< NodePtr > | GetNeighbors (NodePtr node)=0 |
Collects all neighbor nodes of node . | |
virtual double | GetCost (NodePtr a, NodePtr b)=0 |
Returns the cost between a and b . | |
virtual bool | HasLineOfSight (NodePtr a, NodePtr b)=0 |
Determines if there is a direct line of sight between node a and node b . | |
virtual void | ResetNodes (void)=0 |
Resets all local and global goals and parent relationships of all nodes. | |
void | SolveAStar (NodePtr start, NodePtr goal) |
Finds cheapest path from start to goal . | |
void | PostSmooth (NodePtr start, NodePtr goal) |
Simplifies the path from start to goal . | |
Private Member Functions | |
std::vector< NodePtr > | GetNeighbors (NodePtr node) override |
Collects all neighbor nodes of node . | |
double | GetCost (NodePtr a, NodePtr b) override |
Returns the cost between a and b . | |
bool | HasLineOfSight (NodePtr a, NodePtr b) override |
Determines if there is a direct line of sight between node a and node b . | |
void | ResetNodes () override |
Resets all local and global goals and parent relationships of all nodes. | |
std::list< NodePtr > | BresenhamLine (const NodePtr &a, const NodePtr &b) const |
Calculates the Bresenham Line between two nodes. | |
Private Attributes | |
std::vector< NodePtr > | m_Nodes |
All the nodes that make up the graph. | |
std::unique_ptr< HeightManagement::HeightManager > | m_HeightMap |
HeightManager instance owned by Routemaker. | |
int | m_MapWidth |
Width (and height) of the active scenario. | |
int | m_RoutemakerRes |
Resolution of the routemaker in meters. | |
int | m_RoutemakerWidth |
Width (and height) of the routemaker. | |
Additional Inherited Members | |
![]() | |
using | NodePtr = std::shared_ptr< Node< Cell2D > > |
Helper alias to make code more readable. | |
Main class responsible for handling creation of routes between keyframes.
Definition at line 22 of file routemaker.h.
|
explicit |
Instatiates a routemaker object, along with it's Heightmap member.
The origin
and size
of the scenario are simply passed to the HeightMap member. In the case that the HeightMap class is converted to a singleton or the scenario class gains ownership over the Heightmap, they should not be necessary.
origin | The origin of the scenario in UTM coordinate space. |
size | The size of the scenario in meters |
Definition at line 15 of file routemaker.cpp.
|
private |
Calculates the Bresenham Line between two nodes.
a | Pointer to first node |
b | Pointer to seconds node |
a
and b
. Definition at line 203 of file routemaker.cpp.
Returns the cost between a
and b
.
Implemented by sub-classes of Graph. The a* path-finding algorithm uses cost to efficiently find the best path between two nodes. In order to do this, it requires some method of calculating the cost of moving between any two nodes. It is up to the sub-class to define how this is calulated. An example of this cost may be the euclidean distance between two nodes.
a
and node b
. Implements Routemaker::Graph< Cell2D >.
Definition at line 168 of file routemaker.cpp.
|
overrideprivatevirtual |
Collects all neighbor nodes of node
.
Implemented by sub-classes of Graph. The neighbor relationship between nodes define the edges of the graph. It is up to the subclass to define these relationships. For a 2D grid, the neighbors would simply be the nodes directly to the north, south, east and west, in addition to the corners between them. For a road network, the relationships may be more complex.
node | A pointer to the node from which to collect all neighbors |
node
Implements Routemaker::Graph< Cell2D >.
Definition at line 103 of file routemaker.cpp.
Routemaker::NodePtr Routemaker::Routemaker::GetNode | ( | uint32_t | x, |
uint32_t | y | ||
) | const |
Get a node at a position.
x | x-coordinate of position |
y | y-coordinate of position |
Definition at line 250 of file routemaker.cpp.
Determines if there is a direct line of sight between node a
and node b
.
Implemented by sub-classes of Graph. The Graph::PostSmooth method traverses the already found path through the A* path-finding algorithm and simplifies it by using this method. In a graph representing a 2D grid, a Bresenham implementation or ray-casting can be used to determine line of sight.
Implements Routemaker::Graph< Cell2D >.
Definition at line 184 of file routemaker.cpp.
std::vector< Core::CartesianCoordinate > Routemaker::Routemaker::MakeRoute | ( | const Core::Keyframe & | a, |
const Core::Keyframe & | b | ||
) |
Creates a a vector of coordinates defining a path between two keyframes.
Utilizes methods from the Graph interface, namely GetNeighbors, GetCost, HasLineOfSight and BresenhamLine, to generate a path between a
and b
.
a | First keyframe to create to create path from |
b | Second keyframe to create path from |
returns A vector of coordinates in symmetrical cartesian coordinate system space, which together forms a path.
Definition at line 257 of file routemaker.cpp.
References Core::Keyframe::AgentId, CoordinateConverter::CoordConv::AsymmetricToSymmetric(), DRONE_FLIGHT_HEIGHT, Core::Keyframe::Position, CoordinateConverter::CoordConv::SymmetricToAsymmetric(), Core::Keyframe::TimeStamp, and Core::CartesianCoordinate::X.
|
overrideprivatevirtual |
Resets all local and global goals and parent relationships of all nodes.
Implemented by sub-classes of Graph. In order to be able to re-use the same graph for several A* searches, the Graph::SolveAStar method needs to be able to reset all the nodes. As this interface does not contain the actual collection of nodes, this needs to be implemented in the sub-classes.
Implements Routemaker::Graph< Cell2D >.
Definition at line 26 of file routemaker.cpp.
void Routemaker::Routemaker::UpdateOrigin | ( | Core::UTMCoordinate | UTMOrigin, |
int | size | ||
) |
Updates the origin coordinate and the size of the map.
UTMOrigin | The new origin coordinate for the map |
size | The new size of the map in meters |
Definition at line 64 of file routemaker.cpp.
References Routemaker::Node< T >::Data, and DRONE_FLIGHT_HEIGHT.
void Routemaker::Routemaker::UpdateResolution | ( | ) |
Definition at line 44 of file routemaker.cpp.
|
private |
HeightManager instance owned by Routemaker.
Definition at line 93 of file routemaker.h.
|
private |
Width (and height) of the active scenario.
Definition at line 96 of file routemaker.h.
|
private |
All the nodes that make up the graph.
Definition at line 90 of file routemaker.h.
|
private |
Resolution of the routemaker in meters.
A resolution of 3 meters would mean that any one move in vertical or horizontal direction would correspond to a 3 meter movement. A higher value increases performance of the routemaker, but decreases route fidelity.
Definition at line 104 of file routemaker.h.
|
private |
Width (and height) of the routemaker.
Will always equal m_MapWidth divided by m_RoutemakerRes
Definition at line 109 of file routemaker.h.