9 import fields2cover
as f2c
11 print(
"####### Tutorial 5.1 Route planning for all swaths ######");
13 robot_c = f2c.Robot(1.0);
14 cells_c = f2c.Cells(f2c.Cell(f2c.LinearRing(f2c.VectorPoint([
15 f2c.Point(0,0), f2c.Point(60,0),f2c.Point(60,60),f2c.Point(0,60), f2c.Point(0,0)]))));
16 cells_c.addRing(0, f2c.LinearRing(f2c.VectorPoint([
17 f2c.Point(12,12), f2c.Point(12,18),f2c.Point(18,18),f2c.Point(18,12), f2c.Point(12,12)])));
18 cells_c.addRing(0, f2c.LinearRing(f2c.VectorPoint([
19 f2c.Point(36,36), f2c.Point(36,48),f2c.Point(48,48),f2c.Point(48,36), f2c.Point(36, 36)])));
21 const_hl = f2c.HG_Const_gen();
22 mid_hl_c = const_hl.generateHeadlands(cells_c, 1.5 * robot_c.getWidth());
23 no_hl_c = const_hl.generateHeadlands(cells_c, 3.0 * robot_c.getWidth());
25 bf = f2c.SG_BruteForce();
26 swaths_c = bf.generateSwaths(math.pi/2.0, robot_c.getCovWidth(), no_hl_c);
28 route_planner = f2c.RP_RoutePlannerBase();
29 route = route_planner.genRoute(mid_hl_c, swaths_c);
47 print(
"####### Tutorial 5.2 Known Patterns ######");
52 robot = f2c.Robot(2.0, 6.0);
53 field = rand.generateRandField(1e4, 5);
54 cells = field.getField();
55 const_hl = f2c.HG_Const_gen();
56 no_hl = const_hl.generateHeadlands(cells, 3.0 * robot.getWidth());
57 bf = f2c.SG_BruteForce();
58 swaths = bf.generateSwaths(math.pi, robot.getCovWidth(), no_hl.getGeometry(0));
60 print(
"####### Tutorial 5.2.1 Boustrophedon ######");
61 boustrophedon_sorter = f2c.RP_Boustrophedon();
62 swaths = boustrophedon_sorter.genSortedSwaths(swaths);
80 print(
"####### Tutorial 5.2.2 Snake order ######");
81 snake_sorter = f2c.RP_Snake();
82 swaths = snake_sorter.genSortedSwaths(swaths);
97 swaths = bf.generateSwaths(math.pi, robot.getCovWidth(), no_hl.getGeometry(0));
98 print(
"####### Tutorial 5.2.3 Spiral order ######");
99 spiral_sorter = f2c.RP_Spiral(6);
100 swaths = spiral_sorter.genSortedSwaths(swaths);
108 for i
in range(1, 4):