8 import fields2cover
as f2c
10 print(
"####### Tutorial 7.1 Why and when decompose ######")
12 cells = f2c.Cells(f2c.Cell(f2c.LinearRing(f2c.VectorPoint([
19 f2c.Point( 0, 0)]))));
27 robot = f2c.Robot(1.0, 1.0);
28 r_w = robot.getCovWidth();
30 const_hl = f2c.HG_Const_gen()
31 bf = f2c.SG_BruteForce();
32 obj = f2c.OBJ_NSwathModified();
34 no_hl_wo_decomp = const_hl.generateHeadlands(cells, 3.0 * r_w);
35 swaths_wo_decomp = bf.generateBestSwaths(obj, r_w, no_hl_wo_decomp);
36 print(
"Without decomposition >> ", obj.computeCost(swaths_wo_decomp));
38 decomp = f2c.DECOMP_TrapezoidalDecomp();
39 decomp.setSplitAngle(0.5*math.pi);
40 decomp_cell = decomp.decompose(cells);
42 no_hl_decomp = const_hl.generateHeadlands(decomp_cell, 3.0 * r_w);
43 swaths_decomp = bf.generateBestSwaths(obj, r_w, no_hl_decomp);
44 print(
"With decomposition >> ", obj.computeCost(swaths_decomp));
63 print(
"####### Tutorial 7.2 Decomposition with route planner ######");
65 mid_hl = const_hl.generateHeadlands(cells, 1.5 * r_w);
66 decomp_mid_hl = decomp.decompose(mid_hl);
67 no_hl = const_hl.generateHeadlands(decomp_mid_hl, 1.5 * r_w);
68 swaths = bf.generateBestSwaths(obj, r_w, no_hl);
70 route_planner = f2c.RP_RoutePlannerBase();
71 route = route_planner.genRoute(mid_hl, swaths);