hivemind 1.0.0
Loading...
Searching...
No Matches
Routemaker::Routemaker Class Reference

Main class responsible for handling creation of routes between keyframes. More...

#include <routemaker.h>

Inheritance diagram for Routemaker::Routemaker:
Inheritance graph
Collaboration diagram for Routemaker::Routemaker:
Collaboration graph

Public Member Functions

 Routemaker (const Core::UTMCoordinate &origin, int size)
 Instatiates a routemaker object, along with it's Heightmap member.
 
std::vector< Core::CartesianCoordinateMakeRoute (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 ()
 
- Public Member Functions inherited from Routemaker::Graph< Cell2D >
virtual std::vector< NodePtrGetNeighbors (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< NodePtrGetNeighbors (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< NodePtrBresenhamLine (const NodePtr &a, const NodePtr &b) const
 Calculates the Bresenham Line between two nodes.
 

Private Attributes

std::vector< NodePtrm_Nodes
 All the nodes that make up the graph.
 
std::unique_ptr< HeightManagement::HeightManagerm_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

- Public Types inherited from Routemaker::Graph< Cell2D >
using NodePtr = std::shared_ptr< Node< Cell2D > >
 Helper alias to make code more readable.
 

Detailed Description

Main class responsible for handling creation of routes between keyframes.

Definition at line 22 of file routemaker.h.

Constructor & Destructor Documentation

◆ Routemaker()

Routemaker::Routemaker::Routemaker ( const Core::UTMCoordinate origin,
int  size 
)
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.

Parameters
originThe origin of the scenario in UTM coordinate space.
sizeThe size of the scenario in meters

Definition at line 15 of file routemaker.cpp.

Member Function Documentation

◆ BresenhamLine()

std::list< Routemaker::NodePtr > Routemaker::Routemaker::BresenhamLine ( const NodePtr a,
const NodePtr b 
) const
private

Calculates the Bresenham Line between two nodes.

Parameters
aPointer to first node
bPointer to seconds node
Returns
A list of pointers to the nodes that make up the Bresenham Line between a and b.

Definition at line 203 of file routemaker.cpp.

◆ GetCost()

double Routemaker::Routemaker::GetCost ( NodePtr  a,
NodePtr  b 
)
overrideprivatevirtual

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.

Parameters
aPointer to the first Node
bPointer to the second Node
Returns
Cost between node a and node b.

Implements Routemaker::Graph< Cell2D >.

Definition at line 168 of file routemaker.cpp.

◆ GetNeighbors()

std::vector< Routemaker::NodePtr > Routemaker::Routemaker::GetNeighbors ( NodePtr  node)
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.

Parameters
nodeA pointer to the node from which to collect all neighbors
Returns
A vector of pointers to all the neighbors of node

Implements Routemaker::Graph< Cell2D >.

Definition at line 103 of file routemaker.cpp.

◆ GetNode()

Routemaker::NodePtr Routemaker::Routemaker::GetNode ( uint32_t  x,
uint32_t  y 
) const

Get a node at a position.

Parameters
xx-coordinate of position
yy-coordinate of position
Returns
A shared pointer to the node at the specified location

Definition at line 250 of file routemaker.cpp.

◆ HasLineOfSight()

bool Routemaker::Routemaker::HasLineOfSight ( NodePtr  a,
NodePtr  b 
)
overrideprivatevirtual

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.

Parameters
aPointer to the first Node
bPointer to the second Node
Returns
bool specifying whether or not there is a direct line of sight

Implements Routemaker::Graph< Cell2D >.

Definition at line 184 of file routemaker.cpp.

◆ MakeRoute()

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.

Parameters
aFirst keyframe to create to create path from
bSecond 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.

Here is the call graph for this function:

◆ ResetNodes()

void Routemaker::Routemaker::ResetNodes ( void  )
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.

◆ UpdateOrigin()

void Routemaker::Routemaker::UpdateOrigin ( Core::UTMCoordinate  UTMOrigin,
int  size 
)

Updates the origin coordinate and the size of the map.

Parameters
UTMOriginThe new origin coordinate for the map
sizeThe new size of the map in meters

Definition at line 64 of file routemaker.cpp.

References Routemaker::Node< T >::Data, and DRONE_FLIGHT_HEIGHT.

◆ UpdateResolution()

void Routemaker::Routemaker::UpdateResolution ( )

Definition at line 44 of file routemaker.cpp.

Member Data Documentation

◆ m_HeightMap

std::unique_ptr<HeightManagement::HeightManager> Routemaker::Routemaker::m_HeightMap
private

HeightManager instance owned by Routemaker.

Definition at line 93 of file routemaker.h.

◆ m_MapWidth

int Routemaker::Routemaker::m_MapWidth
private

Width (and height) of the active scenario.

Definition at line 96 of file routemaker.h.

◆ m_Nodes

std::vector<NodePtr> Routemaker::Routemaker::m_Nodes
private

All the nodes that make up the graph.

Definition at line 90 of file routemaker.h.

◆ m_RoutemakerRes

int Routemaker::Routemaker::m_RoutemakerRes
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.

◆ m_RoutemakerWidth

int Routemaker::Routemaker::m_RoutemakerWidth
private

Width (and height) of the routemaker.

Will always equal m_MapWidth divided by m_RoutemakerRes

Definition at line 109 of file routemaker.h.


The documentation for this class was generated from the following files: