8 #ifndef PATH_PLANNING_CHECKER_HPP_
9 #define PATH_PLANNING_CHECKER_HPP_
11 #include <gtest/gtest.h>
17 if (
path.size() < 1) {
18 return testing::AssertionFailure() <<
19 "Error 3001: The path do not have any state";
20 }
else if (
path.size() > 1) {
22 int errors_big_dist {0};
23 int errors_big_angle {0};
24 for (
size_t i = 0; i <
path.size() - 1; ++i) {
26 if (
p2.distance(
path[i + 1].point) > 5e-3) {
27 std::cerr <<
"Path checker Error 3009: dist between end of state " << i <<
28 " " <<
p2 <<
" and start of next one " <<
29 path[i + 1].point <<
" is " <<
30 p2.distance(
path[i + 1].point) << std::endl;
34 path[i + 1].angle,
path[i].angle) > M_PI / 8.0) {
35 std::cerr <<
"Path checker Error 3010: Angle between state " << i <<
36 " " <<
p2 <<
" and start of next one " <<
37 path[i + 1].point <<
" is " <<
39 path[i + 1].angle,
path[i].angle) << std::endl;
43 if (errors_big_dist) {
44 return testing::AssertionFailure() <<
45 "Error 3009: The end of one state and the next one doesn't connect on" <<
46 errors_big_dist <<
" states";
48 if (errors_big_angle) {
49 return testing::AssertionFailure() <<
50 "Error 3010: The end of one state and the next one doesn't connect on" <<
51 errors_big_angle <<
" states";
54 return testing::AssertionSuccess();
59 F2CPoint end,
double end_ang,
bool check_y_lower_limit =
true) {
60 if (
path.size() < 1) {
61 return testing::AssertionFailure() <<
62 "Error 3001: The path do not have any state";
63 }
else if (check_y_lower_limit &&
64 std::any_of(
path.begin(),
path.end(),
66 return testing::AssertionFailure() <<
67 "Error 3002: Lower limit on Y axis is crossed.";
68 }
else if (
path[0].point.distance(start) > 1e-2) {
69 return testing::AssertionFailure() <<
70 "Error 3003: Start point should be " << start <<
", but is " <<
72 }
else if (
path.atEnd().distance(
end) > 1e-2) {
73 return testing::AssertionFailure() <<
74 "Error 3004: End point should be " <<
end <<
", but is " <<
77 return testing::AssertionFailure() <<
78 "Error 3006: Start angle should be " << start_ang <<
79 ", but computed angle is " <<
path[0].angle <<
".";
81 return testing::AssertionFailure() <<
82 "Error 3007: End angle should be " << end_ang <<
83 ", but computed angle is " <<
path.back().angle <<
".";
85 return testing::AssertionFailure() <<
86 "Error 3008: Length of the curve (" <<
path.length() <<
87 ") is smaller than the distance between start to end points (" <<
93 #endif // PATH_PLANNING_CHECKER_HPP_