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

Function main

tutorials/6_path_planning.cpp:11–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <iostream>
10
11int main() {
12 f2c::Random rand(42);
13 F2CRobot robot (2.0, 6.0);
14 f2c::hg::ConstHL const_hl;
15 F2CCells cells = rand.generateRandField(1e4, 5).getField();
16 F2CCells no_hl = const_hl.generateHeadlands(cells, 3.0 * robot.getWidth());
17 f2c::sg::BruteForce bf;
18 F2CSwaths swaths = bf.generateSwaths(M_PI, robot.getCovWidth(), no_hl.getGeometry(0));
19 f2c::rp::SnakeOrder snake_sorter;
20 swaths = snake_sorter.genSortedSwaths(swaths);
21
22
23 f2c::pp::PathPlanning path_planner;
24 robot.setMinTurningRadius(2); // m
25 robot.setMaxDiffCurv(0.1); // 1/m^2
26
27
28 std::cout << "####### Tutorial 6.1 Dubins curves ######" << std::endl;
29 f2c::pp::DubinsCurves dubins;
30 F2CPath path_dubins = path_planner.planPath(robot, swaths, dubins);
31
32 f2c::Visualizer::figure();
33 f2c::Visualizer::plot(cells);
34 f2c::Visualizer::plot(no_hl);
35 f2c::Visualizer::plot(path_dubins);
36 f2c::Visualizer::plot(swaths);
37 f2c::Visualizer::save("Tutorial_6_1_Dubins.png");
38
39 std::cout << "####### Tutorial 6.2 Dubins curves with Continuous curvature ######" << std::endl;
40 f2c::pp::DubinsCurvesCC dubins_cc;
41 F2CPath path_dubins_cc = path_planner.planPath(robot, swaths, dubins_cc);
42
43 f2c::Visualizer::figure();
44 f2c::Visualizer::plot(cells);
45 f2c::Visualizer::plot(no_hl);
46 f2c::Visualizer::plot(path_dubins_cc);
47 f2c::Visualizer::plot(swaths);
48 f2c::Visualizer::save("Tutorial_6_2_Dubins_CC.png");
49
50 std::cout << "####### Tutorial 6.3 Reeds-Shepp curves ######" << std::endl;
51 f2c::pp::ReedsSheppCurves reeds_shepp;
52 F2CPath path_reeds_shepp = path_planner.planPath(robot, swaths, reeds_shepp);
53
54 f2c::Visualizer::figure();
55 f2c::Visualizer::plot(cells);
56 f2c::Visualizer::plot(no_hl);
57 f2c::Visualizer::plot(path_reeds_shepp);
58 f2c::Visualizer::plot(swaths);
59 f2c::Visualizer::save("Tutorial_6_3_Reeds_Shepp.png");
60
61 std::cout << "####### Tutorial 6.4 Reeds-Shepp curves with Continuous curvature ######" << std::endl;
62 f2c::pp::ReedsSheppCurvesHC reeds_shepp_hc;
63 F2CPath path_reeds_shepp_hc = path_planner.planPath(robot, swaths, reeds_shepp_hc);
64
65 f2c::Visualizer::figure();
66 f2c::Visualizer::plot(cells);
67 f2c::Visualizer::plot(no_hl);
68 f2c::Visualizer::plot(path_reeds_shepp_hc);

Callers

nothing calls this directly

Calls 10

generateRandFieldMethod · 0.80
generateHeadlandsMethod · 0.80
generateSwathsMethod · 0.80
getCovWidthMethod · 0.80
genSortedSwathsMethod · 0.80
setMinTurningRadiusMethod · 0.80
setMaxDiffCurvMethod · 0.80
planPathMethod · 0.80
getWidthMethod · 0.45
getGeometryMethod · 0.45

Tested by

no test coverage detected