hivemind 1.0.0
Loading...
Searching...
No Matches
routemaker.h
Go to the documentation of this file.
1#pragma once
2
3#include "core/types.h"
5#include "routemaker/graph.h"
6
7#include <cstdint>
8#include <list>
9#include <vector>
10
11namespace Routemaker
12{
13
14 struct Cell2D
15 {
16 uint32_t X, Y;
18 };
19
20 /// \brief Main class responsible for handling creation of routes between
21 /// keyframes.
22 class Routemaker : public Graph<Cell2D>
23 {
24 public:
25 /// \brief Instatiates a routemaker object, along with it's Heightmap
26 /// member.
27 ///
28 /// The \p origin and \p size of the scenario are simply passed to the
29 /// HeightMap member. In the case that the HeightMap class is converted
30 /// to a singleton or the scenario class gains ownership over the
31 /// Heightmap, they should not be necessary.
32 ///
33 /// \param origin The origin of the scenario in UTM coordinate space.
34 /// \param size The size of the scenario in meters
35 explicit Routemaker(const Core::UTMCoordinate& origin, int size);
36
37 /// \brief Creates a a vector of coordinates defining a path between two
38 /// keyframes.
39 ///
40 /// Utilizes methods from the Graph interface, namely GetNeighbors,
41 /// GetCost, HasLineOfSight and BresenhamLine, to generate a path
42 /// between \p a and \p b.
43 ///
44 /// \param a First keyframe to create to create path from
45 /// \param b Second keyframe to create path from
46 ///
47 /// returns A vector of coordinates in symmetrical cartesian coordinate
48 /// system space, which together forms a path.
49 std::vector<Core::CartesianCoordinate>
50 MakeRoute(const Core::Keyframe& a, const Core::Keyframe& b);
51
52 /// \brief Get a node at a position
53 ///
54 /// \param x x-coordinate of position
55 /// \param y y-coordinate of position
56 /// \returns A shared pointer to the node at the specified location
57 NodePtr GetNode(uint32_t x, uint32_t y) const;
58
59 /// \brief Updates the origin coordinate and the size of the map
60 ///
61 /// \param UTMOrigin The new origin coordinate for the map
62 /// \param size The new size of the map in meters
63 void UpdateOrigin(Core::UTMCoordinate UTMOrigin, int size);
64
65 void UpdateResolution();
66
67 private:
68 std::vector<NodePtr> GetNeighbors(NodePtr node) override;
69
70 double GetCost(NodePtr a, NodePtr b) override;
71
72 bool HasLineOfSight(NodePtr a, NodePtr b) override;
73
74 void ResetNodes() override;
75
76 /// \brief Calculates the <a
77 /// href="https://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html">Bresenham
78 /// Line</a> between two nodes
79 ///
80 /// \param a Pointer to first node
81 /// \param b Pointer to seconds node
82 /// \returns A list of pointers to the nodes that make up the <a
83 /// href="https://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html">Bresenham
84 /// Line</a> between \p a and \p b.
85 std::list<NodePtr> BresenhamLine(const NodePtr& a,
86 const NodePtr& b) const;
87
88 private:
89 /// \brief All the nodes that make up the graph
90 std::vector<NodePtr> m_Nodes;
91
92 /// \brief HeightManager instance owned by Routemaker
93 std::unique_ptr<HeightManagement::HeightManager> m_HeightMap;
94
95 /// \brief Width (and height) of the active scenario
97
98 /// \brief Resolution of the routemaker in meters.
99 ///
100 /// A resolution of 3 meters would mean that any one move in vertical or
101 /// horizontal direction would correspond to a 3 meter movement. A
102 /// higher value increases performance of the routemaker, but decreases
103 /// route fidelity.
105
106 /// \brief Width (and height) of the routemaker
107 ///
108 /// Will always equal \a m_MapWidth divided by \a m_RoutemakerRes
110 };
111
112} // namespace Routemaker
Abstract graph interface optimized for path-finding.
Definition: graph.h:74
std::vector< NodePtr > m_Nodes
All the nodes that make up the graph.
Definition: routemaker.h:90
int m_RoutemakerRes
Resolution of the routemaker in meters.
Definition: routemaker.h:104
int m_RoutemakerWidth
Width (and height) of the routemaker.
Definition: routemaker.h:109
int m_MapWidth
Width (and height) of the active scenario.
Definition: routemaker.h:96
std::unique_ptr< HeightManagement::HeightManager > m_HeightMap
HeightManager instance owned by Routemaker.
Definition: routemaker.h:93
A structure representing an agent's position in cartesian space at a given point in time.
Definition: types.h:69
\ A structure that represents a coordinate in the Universal Transverse Mercator coordinate system
Definition: types.h:46