complete_turn_path_obj_test.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 pytest
8 import fields2cover as f2c
9 import math
10 
11 def near(a, b, error = 1e-7):
12  assert abs(a - b) < error
13 
14 
16  swath1 = f2c.Swath(f2c.LineString(f2c.VectorPoint(
17  [f2c.Point(0.0, 0.0), f2c.Point(0.0, 1.0)])));
18  swath2 = f2c.Swath(f2c.LineString(f2c.VectorPoint(
19  [f2c.Point(1.0, 1.0), f2c.Point(1.0, 0.0)])));
20  swaths1 = f2c.Swaths();
21  [swaths1.push_back(i) for i in [swath1]]
22  swaths2 = f2c.Swaths();
23  [swaths2.push_back(i) for i in [swath2]]
24 
25  robot = f2c.Robot(2.1, 2.5);
26  robot.setMaxCurv(2.0);
27 
28  length = f2c.OBJ_CompleteTurnPathObj_Dubins(robot);
29 
30  # Precision is quite low so this is just checking a prediction is done
31  near(length.computeCost(swath1, swath2), math.pi/2, 0.1);
32 
34  robot = f2c.Robot(2.1, 2.5);
35  objective = f2c.OBJ_CompleteTurnPathObj_Dubins(robot);
36  assert not (objective.isMaximizing());
37  assert (objective.isMinimizing());
38 
complete_turn_path_obj_test.test_fields2cover_complete_pred_turn_path_obj_paramsCheck
def test_fields2cover_complete_pred_turn_path_obj_paramsCheck()
Definition: complete_turn_path_obj_test.py:33
complete_turn_path_obj_test.near
def near(a, b, error=1e-7)
Definition: complete_turn_path_obj_test.py:11
complete_turn_path_obj_test.test_fields2cover_obj_complete_turn_path_obj_computeCost
def test_fields2cover_obj_complete_turn_path_obj_computeCost()
Definition: complete_turn_path_obj_test.py:15


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