tests
cpp
swath_generator
brute_force_test.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
#include <gtest/gtest.h>
8
#include <iostream>
9
#include <fstream>
10
#include "
fields2cover/utils/random.h
"
11
#include "
fields2cover/types.h
"
12
#include "
fields2cover/objectives/sg_obj/n_swath.h
"
13
#include "
fields2cover/swath_generator/brute_force.h
"
14
#include "../test_helpers/swath_generator_checker.hpp"
15
16
17
TEST
(fields2cover_swath_brute_gen, generate_swaths) {
18
f2c::Random
rand
(4);
19
f2c::sg::BruteForce
sw_gen;
20
auto
poly =
rand
.genConvexCell(1e3);
21
22
for
(
int
i = 0; i < 10; ++i) {
23
double
ang =
rand
.getAngleRandom();
24
auto
swaths
= sw_gen.
generateSwaths
(ang, 1, poly);
25
for
(
auto
&& s :
swaths
) {
26
EXPECT_NEAR(s.getInAngle(), ang, 1e-3);
27
EXPECT_NEAR(s.getOutAngle(), ang, 1e-3);
28
}
29
}
30
}
31
32
TEST
(fields2cover_swath_brute_gen, best_angle) {
33
f2c::Random
rand
(4);
34
f2c::obj::NSwath
n_swath
;
35
f2c::sg::BruteForce
sw_gen;
36
37
sw_gen.
setStepAngle
(1);
38
EXPECT_EQ(sw_gen.
getStepAngle
(), 1.0);
39
auto
poly =
rand
.genConvexCell(1e3);
40
isSwathGenerationCorrect
(sw_gen,
n_swath
, poly);
41
isSwathGenerationCorrect
(sw_gen,
n_swath
,
F2CCells
(poly));
42
isSwathGenerationCorrect
(sw_gen,
n_swath
,
F2CCell
());
43
isSwathGenerationCorrect
(sw_gen,
n_swath
,
F2CCells
());
44
}
5_route_planning.swaths
swaths
Definition:
5_route_planning.py:58
f2c::obj::NSwath
SG cost function as the number of swaths.
Definition:
n_swath.h:20
types.h
f2c::sg::BruteForce::setStepAngle
void setStepAngle(double d)
Definition:
brute_force.cpp:22
brute_force.h
F2CCell
f2c::types::Cell F2CCell
Definition:
types.h:43
3_headland_generator.rand
rand
Definition:
3_headland_generator.py:11
F2CCells
f2c::types::Cells F2CCells
Definition:
types.h:44
random.h
TEST
TEST(fields2cover_swath_brute_gen, generate_swaths)
Definition:
brute_force_test.cpp:17
isSwathGenerationCorrect
testing::AssertionResult isSwathGenerationCorrect(f2c::sg::SwathGeneratorBase &sw_gen, f2c::obj::SGObjective &obj, const F2CCell &poly, double swath_width=1.0, int checks=100)
Definition:
swath_generator_checker.hpp:15
4_swath_generator.n_swath
n_swath
Definition:
4_swath_generator.py:19
f2c::Random
Definition:
random.h:23
f2c::sg::SwathGeneratorBase::generateSwaths
virtual F2CSwaths generateSwaths(double angle, double op_width, const F2CCell &poly)
Definition:
swath_generator_base.cpp:43
n_swath.h
f2c::sg::BruteForce
Definition:
brute_force.h:20
f2c::sg::BruteForce::getStepAngle
double getStepAngle() const
Definition:
brute_force.cpp:18
fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31