added several grid-walks
added new helper methods/classes (e.g. for heading) new test cases optimize the dijkstra cleanups/refactoring added timed-benchmarks to the log many more...
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "../../grid/factory/GridFactory.h"
|
||||
#include "../../floorplan/FloorplanFactorySVG.h"
|
||||
#include "../../nav/dijkstra/Dijkstra.h"
|
||||
#include "../../grid/walk/GridWalkWeighted.h"
|
||||
|
||||
#include "Plot.h"
|
||||
|
||||
@@ -29,38 +30,55 @@ TEST(TestAll, Nav) {
|
||||
} tmp(g);
|
||||
|
||||
GridFactory<20, GP> gf(g);
|
||||
FloorplanFactorySVG fpf(getDataFile("fp1.svg"), 6);
|
||||
|
||||
// load floorplan
|
||||
FloorplanFactorySVG fpf(getDataFile("fp1.svg"), 6);
|
||||
Floor f1 = fpf.getFloor("1");
|
||||
Floor f2 = fpf.getFloor("2");
|
||||
Stairs s1_2 = fpf.getStairs("1_2");
|
||||
|
||||
// build the grid
|
||||
gf.addFloor(f1, 20);
|
||||
gf.addFloor(f2, 340);
|
||||
gf.addStairs(s1_2, 20, 340);
|
||||
gf.removeIsolated();
|
||||
|
||||
|
||||
// calculate node importance based on the floorplan (walls, ...)
|
||||
GridImportance gi;
|
||||
gi.addImportance(g, 20);
|
||||
gi.addImportance(g, 340);
|
||||
//gi.addImportance(g, 20);
|
||||
//gi.addImportance(g, 340);
|
||||
|
||||
// calculate dijkstra using aforementioned importance
|
||||
Dijkstra<GP> d;
|
||||
const GP& start = g.getNodeFor(GridPoint(500,200,20));
|
||||
//const GP& end = g.getNodeFor(GridPoint(1400,1400,20));
|
||||
const GP& end = g.getNodeFor(GridPoint(1200,200,340));
|
||||
//const GP& end = g.getNodeFor(GridPoint(1300,1300,20));
|
||||
d.build(start, end, tmp);
|
||||
|
||||
// add the path's importance to the grid
|
||||
gi.addImportance(g, d.getNode(start), d.getNode(end));
|
||||
|
||||
// plot path
|
||||
K::GnuplotSplotElementLines path; path.setColorHex("#0000ff"); path.setLineWidth(2);
|
||||
DijkstraNode<GP>* dn = d.getNode(end);
|
||||
while (dn->previous != nullptr) {
|
||||
path.add(K::GnuplotPoint3(dn->element->x_cm, dn->element->y_cm, dn->element->z_cm));
|
||||
path.add(K::GnuplotPoint3(dn->element->x_cm, dn->element->y_cm, dn->element->z_cm+50));
|
||||
dn = dn->previous;
|
||||
}
|
||||
|
||||
// // walk
|
||||
// GridWalkWeighted<GP> walk;
|
||||
// Log::add("test", "walking");
|
||||
// for (int i = 0; i < 5000; ++i) {
|
||||
// walk.getDestination(g, &start, 1.0, Headings::UP);
|
||||
// }
|
||||
// Log::add("test", "done");
|
||||
|
||||
Plot p;
|
||||
p.build(g);
|
||||
//p.showGrid(g);
|
||||
p.addFloor(f1, 20);
|
||||
p.addFloor(f2, 340);
|
||||
p.splot.add(&path);
|
||||
p.fire();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user