6_path_planning.py
Go to the documentation of this file.
1 #=============================================================================
2 # Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3 # Author: Gonzalo Mier
4 # BSD-3 License
5 #=============================================================================
6 
7 import math
8 import fields2cover as f2c
9 
10 rand = f2c.Random(42)
11 robot = f2c.Robot(2.0, 6.0)
12 field = rand.generateRandField(1e4, 5);
13 cells = field.getField();
14 const_hl = f2c.HG_Const_gen()
15 no_hl = const_hl.generateHeadlands(cells, 3.0 * robot.getWidth())
16 bf = f2c.SG_BruteForce()
17 
18 swaths = bf.generateSwaths(math.pi, robot.getCovWidth(), no_hl.getGeometry(0))
19 
20 snake_sorter = f2c.RP_Snake()
21 swaths = snake_sorter.genSortedSwaths(swaths)
22 swaths.at(0).getPath().exportToWkt()
23 
24 
25 robot.setMinTurningRadius(2) # m
26 robot.setMaxDiffCurv(0.1) # 1/m^2
27 path_planner = f2c.PP_PathPlanning()
28 
29 print("####### Tutorial 6.1 Dubins curves ######")
30 dubins = f2c.PP_DubinsCurves()
31 path_dubins = path_planner.planPath(robot, swaths, dubins);
32 
33 
35 f2c.Visualizer.plot(cells);
36 f2c.Visualizer.plot(no_hl);
37 f2c.Visualizer.plot(path_dubins);
38 f2c.Visualizer.plot(swaths);
39 f2c.Visualizer.save("Tutorial_6_1_Dubins.png");
40 
41 print("\n\n####### Tutorial 6.2 Dubins curves with Continuous curvature ######");
42 dubins_cc = f2c.PP_DubinsCurvesCC();
43 path_dubins_cc = path_planner.planPath(robot, swaths, dubins_cc);
44 
46 f2c.Visualizer.plot(cells);
47 f2c.Visualizer.plot(no_hl);
48 f2c.Visualizer.plot(path_dubins_cc);
49 f2c.Visualizer.plot(swaths);
50 f2c.Visualizer.save("Tutorial_6_2_Dubins_CC.png");
51 
52 print("\n\n####### Tutorial 6.3 Reeds-Shepp curves ######")
53 reeds_shepp = f2c.PP_ReedsSheppCurves();
54 path_reeds_shepp = path_planner.planPath(robot, swaths, reeds_shepp);
55 
57 f2c.Visualizer.plot(cells);
58 f2c.Visualizer.plot(no_hl);
59 f2c.Visualizer.plot(path_reeds_shepp);
60 f2c.Visualizer.plot(swaths);
61 f2c.Visualizer.save("Tutorial_6_3_Reeds_Shepp.png");
62 
63 print("\n\n####### Tutorial 6.4 Reeds-Shepp curves with Continuous curvature ######")
64 reeds_shepp_hc = f2c.PP_ReedsSheppCurvesHC();
65 path_reeds_shepp_hc = path_planner.planPath(robot, swaths, reeds_shepp_hc);
66 
68 f2c.Visualizer.plot(cells);
69 f2c.Visualizer.plot(no_hl);
70 f2c.Visualizer.plot(path_reeds_shepp_hc);
71 f2c.Visualizer.plot(swaths);
72 f2c.Visualizer.save("Tutorial_6_4_Reeds_Shepp_HC.png");
73 
f2c::Visualizer::plot
static void plot(double x, double y, const std::vector< double > &color={})
Definition: visualizer.cpp:23
f2c::Random
Definition: random.h:23
f2c::Visualizer::figure
static void figure()
Create figure to plot on.
Definition: visualizer.cpp:254
f2c::Visualizer::save
static void save(const std::string &file)
Definition: visualizer.cpp:272


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31