MCPcopy Create free account
hub / github.com/Fields2Cover/Fields2Cover / main

Function main

tutorials/8_complete_flow.cpp:11–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <iostream>
10
11int main() {
12 // Import field
13 F2CField field = f2c::Parser::importFieldGml(std::string(DATA_PATH) + "test1.xml");
14 F2CField orig_field = field.clone();
15 // Transform into UTM to work in meters
16 f2c::Transform::transformToUTM(field);
17
18 F2CRobot robot (2.0, 6.0);
19 f2c::hg::ConstHL const_hl;
20 F2CCells no_hl = const_hl.generateHeadlands(field.getField(), 3.0 * robot.getWidth());
21 f2c::sg::BruteForce bf;
22 F2CSwaths swaths = bf.generateSwaths(M_PI, robot.getCovWidth(), no_hl.getGeometry(0));
23 f2c::rp::SnakeOrder snake_sorter;
24 swaths = snake_sorter.genSortedSwaths(swaths);
25 f2c::pp::PathPlanning path_planner;
26 robot.setMinTurningRadius(2); // m
27 f2c::pp::DubinsCurves dubins;
28 F2CPath path = path_planner.planPath(robot, swaths, dubins);
29
30
31 f2c::Visualizer::figure();
32 f2c::Visualizer::plot(field);
33 f2c::Visualizer::plot(no_hl);
34 f2c::Visualizer::plot(path);
35 f2c::Visualizer::save("Tutorial_8_1_UTM.png");
36
37
38 // Transform the generated path back to the previousa CRS.
39 F2CPath path_gps = f2c::Transform::transformToPrevCRS(path, field);
40 f2c::Transform::transformToPrevCRS(field);
41
42 f2c::Visualizer::figure();
43 f2c::Visualizer::plot(orig_field.getCellsAbsPosition());
44 f2c::Visualizer::plot(path_gps);
45 f2c::Visualizer::save("Tutorial_8_1_GPS.png");
46
47 return 0;
48}
49
50

Callers

nothing calls this directly

Calls 10

generateHeadlandsMethod · 0.80
generateSwathsMethod · 0.80
getCovWidthMethod · 0.80
genSortedSwathsMethod · 0.80
setMinTurningRadiusMethod · 0.80
planPathMethod · 0.80
getCellsAbsPositionMethod · 0.80
cloneMethod · 0.45
getWidthMethod · 0.45
getGeometryMethod · 0.45

Tested by

no test coverage detected