4_swath_generator.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 
8 import math
9 import fields2cover as f2c
10 
11 rand = f2c.Random(42);
12 robot = f2c.Robot(2.0, 6.0);
13 field = rand.generateRandField(1e4, 5);
14 cells = field.getField();
15 const_hl = f2c.HG_Const_gen();
16 no_hl = const_hl.generateHeadlands(cells, 3.0 * robot.getWidth());
17 
18 print("####### Tutorial 4.1 Brute force swath generator ######");
19 n_swath = f2c.OBJ_NSwath();
20 bf_sw_gen = f2c.SG_BruteForce();
21 swaths_bf_nswath = bf_sw_gen.generateBestSwaths(n_swath, robot.getCovWidth(), no_hl.getGeometry(0));
22 
24 f2c.Visualizer.plot(cells);
25 f2c.Visualizer.plot(no_hl);
26 f2c.Visualizer.plot(swaths_bf_nswath);
27 f2c.Visualizer.save("Tutorial_4_1_Brute_force_NSwath.png");
28 
29 swath_length = f2c.OBJ_SwathLength();
30 
31 swaths_bf_swathlength = bf_sw_gen.generateBestSwaths(swath_length, robot.getCovWidth(), no_hl.getGeometry(0));
32 
33 
35 f2c.Visualizer.plot(cells);
36 f2c.Visualizer.plot(no_hl);
37 f2c.Visualizer.plot(swaths_bf_swathlength);
38 f2c.Visualizer.save("Tutorial_4_1_Brute_force_SwathLength.png");
39 
40 swaths_bf_angle = bf_sw_gen.generateSwaths(math.pi, robot.getCovWidth(), no_hl.getGeometry(0));
42 f2c.Visualizer.plot(cells);
43 f2c.Visualizer.plot(no_hl);
44 f2c.Visualizer.plot(swaths_bf_angle);
45 f2c.Visualizer.save("Tutorial_4_1_Brute_force_Angle.png");
46 
47 
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