| 9 | #include <iostream> |
| 10 | |
| 11 | int main() { |
| 12 | std::cout << "####### Tutorial 7.1 Why and when decompose ######" << std::endl; |
| 13 | |
| 14 | F2CCells cells(F2CCell(F2CLinearRing({ |
| 15 | F2CPoint( 0, 0), |
| 16 | F2CPoint( 90, 0), |
| 17 | F2CPoint( 90, 20), |
| 18 | F2CPoint( 20, 20), |
| 19 | F2CPoint( 20, 90), |
| 20 | F2CPoint( 0, 90), |
| 21 | F2CPoint( 0, 0)}))); |
| 22 | |
| 23 | f2c::Visualizer::figure(); |
| 24 | f2c::Visualizer::plot(cells); |
| 25 | f2c::Visualizer::xlim(-5,95); |
| 26 | f2c::Visualizer::ylim(-5,95); |
| 27 | f2c::Visualizer::save("Tutorial_7_1_field.png"); |
| 28 | |
| 29 | F2CRobot robot (1.0, 1.0); |
| 30 | double r_w = robot.getCovWidth(); |
| 31 | |
| 32 | f2c::hg::ConstHL const_hl; |
| 33 | f2c::sg::BruteForce bf; |
| 34 | f2c::obj::NSwathModified obj; |
| 35 | |
| 36 | F2CCells no_hl_wo_decomp = const_hl.generateHeadlands(cells, 3.0 * r_w); |
| 37 | F2CSwathsByCells swaths_wo_decomp = bf.generateBestSwaths(obj, r_w, no_hl_wo_decomp); |
| 38 | std::cout << "Without decomposition >> " << obj.computeCost(swaths_wo_decomp) << std::endl; |
| 39 | |
| 40 | f2c::decomp::TrapezoidalDecomp decomp; |
| 41 | decomp.setSplitAngle(0.5*M_PI); |
| 42 | F2CCells decomp_cell = decomp.decompose(cells); |
| 43 | |
| 44 | F2CCells no_hl_decomp = const_hl.generateHeadlands(decomp_cell, 3.0 * r_w); |
| 45 | F2CSwathsByCells swaths_decomp = bf.generateBestSwaths(obj, r_w, no_hl_decomp); |
| 46 | std::cout << "With decomposition >> " << obj.computeCost(swaths_decomp) << std::endl; |
| 47 | |
| 48 | |
| 49 | f2c::Visualizer::figure(); |
| 50 | f2c::Visualizer::plot(cells); |
| 51 | f2c::Visualizer::plot(no_hl_wo_decomp); |
| 52 | f2c::Visualizer::plot(swaths_wo_decomp); |
| 53 | f2c::Visualizer::xlim(-5,95); |
| 54 | f2c::Visualizer::ylim(-5,95); |
| 55 | f2c::Visualizer::save("Tutorial_7_1_without_decomposition.png"); |
| 56 | |
| 57 | f2c::Visualizer::figure(); |
| 58 | f2c::Visualizer::plot(decomp_cell); |
| 59 | f2c::Visualizer::plot(no_hl_decomp); |
| 60 | f2c::Visualizer::plot(swaths_decomp); |
| 61 | f2c::Visualizer::xlim(-5,95); |
| 62 | f2c::Visualizer::ylim(-5,95); |
| 63 | f2c::Visualizer::save("Tutorial_7_1_with_decomposition.png"); |
| 64 | |
| 65 | std::cout << "####### Tutorial 7.2 Decomposition with route planner ######" << std::endl; |
| 66 | |
| 67 | |
| 68 | F2CCells mid_hl = const_hl.generateHeadlands(cells, 1.5 * r_w); |
nothing calls this directly
no test coverage detected