8_complete_flow.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 import os
10 DATA_PATH = os.path.dirname(os.path.realpath(__file__))+"/" + 2 * "../"+"data/";
11 
12 # Import field
13 field = f2c.Parser().importFieldGml(DATA_PATH + "test1.xml");
14 orig_field = field.clone();
15 # Transform into UTM to work in meters
17 
18 robot = f2c.Robot(2.0, 6.0);
19 const_hl = f2c.HG_Const_gen()
20 no_hl = const_hl.generateHeadlands(field.getField(), 3.0 * robot.getWidth())
21 bf = f2c.SG_BruteForce()
22 swaths = bf.generateSwaths(math.pi, robot.getCovWidth(), no_hl.getGeometry(0))
23 snake_sorter = f2c.RP_Snake()
24 swaths = snake_sorter.genSortedSwaths(swaths)
25 
26 robot.setMinTurningRadius(2)
27 path_planner = f2c.PP_PathPlanning()
28 dubins = f2c.PP_DubinsCurves()
29 path = path_planner.planPath(robot, swaths, dubins);
30 
31 
33 f2c.Visualizer.plot(field);
34 f2c.Visualizer.plot(no_hl);
36 f2c.Visualizer.save("Tutorial_8_1_UTM.png");
37 
38 
39 # Transform the generated path back to the previousa CRS.
40 path_gps = f2c.Transform.transformToPrevCRS(path, field);
42 
43 ps = [path_gps.getState(i).point for i in range(path_gps.size())]
44 L = f2c.LineString(f2c.VectorPoint(ps))
45 
47 f2c.Visualizer.plot(orig_field.getCellsAbsPosition());
49 #f2c.Visualizer.plot(path_gps);
50 #f2c.Visualizer.axis_equal();
51 f2c.Visualizer.save("Tutorial_8_1_GPS.png");
52 
53 
54 
f2c::Visualizer::plot
static void plot(double x, double y, const std::vector< double > &color={})
Definition: visualizer.cpp:23
f2c::Transform::transformToPrevCRS
static void transformToPrevCRS(F2CField &field)
Definition: transformation.cpp:197
f2c::Parser
Class to parse files of the OGC Standards to our custom format.
Definition: parser.h:20
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
f2c::Transform::transformToUTM
static void transformToUTM(F2CField &field, bool is_etrs89_opt=true)
Definition: transformation.cpp:149


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