tutorials
6_path_planning.cpp
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
#include "
fields2cover.h
"
9
#include <iostream>
10
11
int
main
() {
12
f2c::Random
rand
(42);
13
F2CRobot
robot
(2.0, 6.0);
14
f2c::hg::ConstHL
const_hl
;
15
F2CCells
cells
=
rand
.generateRandField(1e4, 5).getField();
16
F2CCells
no_hl
=
const_hl
.generateHeadlands(
cells
, 3.0 *
robot
.getWidth());
17
f2c::sg::BruteForce
bf
;
18
F2CSwaths
swaths
=
bf
.generateSwaths(M_PI,
robot
.getCovWidth(),
no_hl
.getGeometry(0));
19
f2c::rp::SnakeOrder
snake_sorter
;
20
swaths
=
snake_sorter
.genSortedSwaths(
swaths
);
21
22
23
f2c::pp::PathPlanning
path_planner
;
24
robot
.setMinTurningRadius(2);
// m
25
robot
.setMaxDiffCurv(0.1);
// 1/m^2
26
27
28
std::cout <<
"####### Tutorial 6.1 Dubins curves ######"
<< std::endl;
29
f2c::pp::DubinsCurves
dubins
;
30
F2CPath
path_dubins
=
path_planner
.planPath(
robot
,
swaths
,
dubins
);
31
32
f2c::Visualizer::figure
();
33
f2c::Visualizer::plot
(
cells
);
34
f2c::Visualizer::plot
(
no_hl
);
35
f2c::Visualizer::plot
(
path_dubins
);
36
f2c::Visualizer::plot
(
swaths
);
37
f2c::Visualizer::save
(
"Tutorial_6_1_Dubins.png"
);
38
39
std::cout <<
"####### Tutorial 6.2 Dubins curves with Continuous curvature ######"
<< std::endl;
40
f2c::pp::DubinsCurvesCC
dubins_cc
;
41
F2CPath
path_dubins_cc
=
path_planner
.planPath(
robot
,
swaths
,
dubins_cc
);
42
43
f2c::Visualizer::figure
();
44
f2c::Visualizer::plot
(
cells
);
45
f2c::Visualizer::plot
(
no_hl
);
46
f2c::Visualizer::plot
(
path_dubins_cc
);
47
f2c::Visualizer::plot
(
swaths
);
48
f2c::Visualizer::save
(
"Tutorial_6_2_Dubins_CC.png"
);
49
50
std::cout <<
"####### Tutorial 6.3 Reeds-Shepp curves ######"
<< std::endl;
51
f2c::pp::ReedsSheppCurves
reeds_shepp
;
52
F2CPath
path_reeds_shepp
=
path_planner
.planPath(
robot
,
swaths
,
reeds_shepp
);
53
54
f2c::Visualizer::figure
();
55
f2c::Visualizer::plot
(
cells
);
56
f2c::Visualizer::plot
(
no_hl
);
57
f2c::Visualizer::plot
(
path_reeds_shepp
);
58
f2c::Visualizer::plot
(
swaths
);
59
f2c::Visualizer::save
(
"Tutorial_6_3_Reeds_Shepp.png"
);
60
61
std::cout <<
"####### Tutorial 6.4 Reeds-Shepp curves with Continuous curvature ######"
<< std::endl;
62
f2c::pp::ReedsSheppCurvesHC
reeds_shepp_hc
;
63
F2CPath
path_reeds_shepp_hc
=
path_planner
.planPath(
robot
,
swaths
,
reeds_shepp_hc
);
64
65
f2c::Visualizer::figure
();
66
f2c::Visualizer::plot
(
cells
);
67
f2c::Visualizer::plot
(
no_hl
);
68
f2c::Visualizer::plot
(
path_reeds_shepp_hc
);
69
f2c::Visualizer::plot
(
swaths
);
70
f2c::Visualizer::save
(
"Tutorial_6_4_Reeds_Shepp_HC.png"
);
71
72
return
0;
73
}
74
75
f2c::pp::DubinsCurves
Dubins' curves planner.
Definition:
dubins_curves.h:17
f2c::hg::ConstHL
Class to generate headlands with equal width in each border.
Definition:
constant_headland.h:18
5_route_planning.swaths
swaths
Definition:
5_route_planning.py:58
f2c::rp::SnakeOrder
Definition:
snake_order.h:16
6_path_planning.path_reeds_shepp_hc
path_reeds_shepp_hc
Definition:
6_path_planning.py:65
1_basic_types.cells
cells
Definition:
1_basic_types.py:93
f2c::Visualizer::plot
static void plot(double x, double y, const std::vector< double > &color={})
Definition:
visualizer.cpp:23
6_path_planning.path_planner
path_planner
Definition:
6_path_planning.py:27
main
int main()
Definition:
6_path_planning.cpp:11
f2c::pp::DubinsCurvesCC
Dubins' curves planner with continuous curves.
Definition:
dubins_curves_cc.h:17
6_path_planning.path_reeds_shepp
path_reeds_shepp
Definition:
6_path_planning.py:54
6_path_planning.path_dubins_cc
path_dubins_cc
Definition:
6_path_planning.py:43
3_headland_generator.rand
rand
Definition:
3_headland_generator.py:11
f2c::pp::PathPlanning
Path planning class to connect a path using a TurningBase class method.
Definition:
path_planning.h:19
f2c::pp::ReedsSheppCurves
Reeds-Shepp's curves planner.
Definition:
reeds_shepp_curves.h:17
2_objective_functions.robot
robot
Definition:
2_objective_functions.py:76
fields2cover.h
f2c::pp::ReedsSheppCurvesHC
Reeds-Shepp's curves planner with continuous curves.
Definition:
reeds_shepp_curves_hc.h:17
6_path_planning.dubins
dubins
Definition:
6_path_planning.py:30
3_headland_generator.const_hl
const_hl
Definition:
3_headland_generator.py:17
6_path_planning.dubins_cc
dubins_cc
Definition:
6_path_planning.py:42
f2c::types::Path
Definition:
Path.h:23
f2c::types::Cells
Definition:
Cells.h:21
6_path_planning.path_dubins
path_dubins
Definition:
6_path_planning.py:31
5_route_planning.snake_sorter
snake_sorter
Definition:
5_route_planning.py:81
f2c::types::Robot
Definition:
Robot.h:25
f2c::Random
Definition:
random.h:23
3_headland_generator.no_hl
no_hl
Definition:
3_headland_generator.py:18
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::types::Swaths
Definition:
Swaths.h:20
5_route_planning.bf
bf
Definition:
5_route_planning.py:25
6_path_planning.reeds_shepp
reeds_shepp
Definition:
6_path_planning.py:53
f2c::sg::BruteForce
Definition:
brute_force.h:20
6_path_planning.reeds_shepp_hc
reeds_shepp_hc
Definition:
6_path_planning.py:64
fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31