MCPcopy Create free account
hub / github.com/Fields2Cover/Fields2Cover / main

Function main

tutorials/5_route_planning.cpp:11–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <iostream>
10
11int main() {
12
13 std::cout << "####### Tutorial 5.1 Route planning for all swaths ######" << std::endl;
14
15 F2CRobot robot_c (1.0);
16 F2CCells cells_c {
17 F2CCell(F2CLinearRing({
18 F2CPoint(0,0), F2CPoint(2,0),F2CPoint(2,2),F2CPoint(0,2), F2CPoint(0,0)
19 }))
20 };
21 cells_c.addRing(0, F2CLinearRing({
22 F2CPoint(.4,.4), F2CPoint(.4,.6),F2CPoint(.6,.6),F2CPoint(.6,.4), F2CPoint(.4,.4)
23 }));
24 cells_c.addRing(0, F2CLinearRing({
25 F2CPoint(1.2,1.2), F2CPoint(1.2,1.6),F2CPoint(1.6,1.6),F2CPoint(1.6,1.2), F2CPoint(1.2, 1.2)
26 }));
27 cells_c *= 3e1;
28
29 f2c::hg::ConstHL const_hl;
30 F2CCells mid_hl_c = const_hl.generateHeadlands(cells_c, 1.5 * robot_c.getWidth());
31 F2CCells no_hl_c = const_hl.generateHeadlands(cells_c, 3.0 * robot_c.getWidth());
32
33 f2c::sg::BruteForce bf;
34 F2CSwathsByCells swaths_c = bf.generateSwaths(M_PI/2.0, robot_c.getCovWidth(), no_hl_c);
35
36 f2c::rp::RoutePlannerBase route_planner;
37 F2CRoute route = route_planner.genRoute(mid_hl_c, swaths_c);
38
39 f2c::Visualizer::figure();
40 f2c::Visualizer::plot(cells_c);
41 f2c::Visualizer::plot(no_hl_c);
42 f2c::Visualizer::xlim(-5,65);
43 f2c::Visualizer::ylim(-5,65);
44 f2c::Visualizer::save("Tutorial_5_0_field.png");
45
46 f2c::Visualizer::figure();
47 f2c::Visualizer::plot(cells_c);
48 f2c::Visualizer::plot(no_hl_c);
49 f2c::Visualizer::plot(route);
50 f2c::Visualizer::xlim(-5,65);
51 f2c::Visualizer::ylim(-5,65);
52 f2c::Visualizer::save("Tutorial_5_0_route.png");
53
54
55
56
57 std::cout << "####### Tutorial 5.2 Known Patterns ######" << std::endl;
58
59
60 f2c::Random rand(42);
61 F2CRobot robot (2.0, 6.0);
62 F2CCells cells = rand.generateRandField(1e4, 5).getField();
63 F2CCells no_hl = const_hl.generateHeadlands(cells, 3.0 * robot.getWidth());
64 F2CSwaths swaths = bf.generateSwaths(M_PI, robot.getCovWidth(), no_hl.getGeometry(0));
65
66 std::cout << "####### Tutorial 5.2.1 Boustrophedon ######" << std::endl;
67 f2c::rp::BoustrophedonOrder boustrophedon_sorter;
68 auto boustrophedon_swaths = boustrophedon_sorter.genSortedSwaths(swaths);

Callers

nothing calls this directly

Calls 10

to_stringFunction · 0.85
generateHeadlandsMethod · 0.80
generateSwathsMethod · 0.80
getCovWidthMethod · 0.80
genRouteMethod · 0.80
generateRandFieldMethod · 0.80
genSortedSwathsMethod · 0.80
addRingMethod · 0.45
getWidthMethod · 0.45
getGeometryMethod · 0.45

Tested by

no test coverage detected