17 std::shared_ptr<rclcpp::Publisher<custom_interfaces::msg::ConeArray>>
map_publisher;
19 std::shared_ptr<rclcpp::Subscription<custom_interfaces::msg::PathPointArray>>
control_sub;
22 rclcpp::init(0,
nullptr);
38 "/state_estimation/map", 10);
41 locmap_sender->create_publisher<custom_interfaces::msg::Pose>(
42 "/state_estimation/vehicle_pose", 10);
46 "/path_planning/path", 10,
47 [
this](
const custom_interfaces::msg::PathPointArray::SharedPtr msg) {
48 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Received path in mock control node");
50 (void)rclcpp::shutdown();
51 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Ended control callback in mock control");
62 (void)rclcpp::shutdown();
65 std::chrono::duration<double, std::milli>
run_nodes(
66 const custom_interfaces::msg::ConeArray &track_msg,
67 const custom_interfaces::msg::Pose &state_msg) {
68 this->map_publisher->publish(track_msg);
69 this->vehicle_pose_publisher_->publish(state_msg);
72 rclcpp::executors::MultiThreadedExecutor
executor;
73 executor.add_node(this->locmap_sender);
74 executor.add_node(this->control_receiver);
75 executor.add_node(this->planning_test_);
77 this->map_publisher->publish(track_msg);
78 this->vehicle_pose_publisher_->publish(state_msg);
80 auto start_time = std::chrono::high_resolution_clock::now();
82 auto end_time = std::chrono::high_resolution_clock::now();
83 return std::chrono::duration<double, std::milli>(end_time - start_time);
94 std::vector<Cone> cone_array = {
95 Cone(19, 2),
Cone(22, 2),
Cone(25, 2),
Cone(28, 2),
Cone(31, 2),
Cone(34, 2),
96 Cone(1, 2),
Cone(4, 2),
Cone(7, 2),
Cone(10, 2),
Cone(13, 2),
Cone(16, 2),
97 Cone(19, -2),
Cone(22, -2),
Cone(25, -2),
Cone(28, -2),
Cone(31, -2),
Cone(34, -2),
98 Cone(1, -2),
Cone(4, -2),
Cone(7, -2),
Cone(10, -2),
Cone(13, -2),
Cone(16, -2)};
100 custom_interfaces::msg::Pose vehicle_pose;
103 vehicle_pose.theta = 0;
105 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Publishing cone array with size: %ld",
106 cone_array_msg.cone_array.size());
108 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
110 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
111 for (
const auto &p : received_path.pathpoint_array) {
112 EXPECT_NEAR(p.y, 0, 1e-10);
113 EXPECT_LE(p.x, 35.5);
116 EXPECT_GE(
static_cast<long unsigned>(received_path.pathpoint_array.size()),
117 (
long unsigned int)100);
125 std::vector<Cone> cone_array = {
126 Cone((
float)1.414, (
float)-1.414),
Cone((
float)3.184, (
float)0.356),
127 Cone((
float)4.954, (
float)2.126),
Cone((
float)6.724, (
float)3.896),
128 Cone((
float)8.494, (
float)5.666),
Cone((
float)10.264, (
float)7.436),
129 Cone((
float)12.034, (
float)9.206),
Cone((
float)13.804, (
float)10.976),
130 Cone((
float)15.574, (
float)12.746),
Cone((
float)17.344, (
float)14.516),
131 Cone((
float)19.114, (
float)16.286),
Cone((
float)20.884, (
float)18.056),
132 Cone((
float)-1.414, (
float)1.414),
Cone((
float)0.356, (
float)3.184),
133 Cone((
float)2.126, (
float)4.954),
Cone((
float)3.896, (
float)6.724),
134 Cone((
float)5.666, (
float)8.494),
Cone((
float)7.436, (
float)10.264),
135 Cone((
float)9.206, (
float)12.034),
Cone((
float)10.976, (
float)13.804),
136 Cone((
float)12.746, (
float)15.574),
Cone((
float)14.516, (
float)17.344),
137 Cone((
float)16.286, (
float)19.114),
Cone((
float)18.056, (
float)20.884)};
140 custom_interfaces::msg::Pose vehicle_pose;
143 vehicle_pose.theta = 0.785398;
145 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Publishing cone array with size: %ld",
146 cone_array_msg.cone_array.size());
147 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
149 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
150 for (
const auto &p : received_path.pathpoint_array) {
151 EXPECT_LE(p.y - p.x, 0.1);
153 EXPECT_GE(
static_cast<long unsigned>(received_path.pathpoint_array.size()),
154 (
long unsigned int)100);
162 custom_interfaces::msg::Cone cone_to_send;
164 std::vector<Cone> cone_array = {
165 Cone((
float)-1.414, (
float)-1.414),
Cone((
float)-3.184, (
float)0.356),
166 Cone((
float)-4.954, (
float)2.126),
Cone((
float)-6.724, (
float)3.896),
167 Cone((
float)-8.494, (
float)5.666),
Cone((
float)-10.264, (
float)7.436),
168 Cone((
float)-12.034, (
float)9.206),
Cone((
float)-13.804, (
float)10.976),
169 Cone((
float)-15.574, (
float)12.746),
Cone((
float)-17.344, (
float)14.516),
170 Cone((
float)-19.114, (
float)16.286),
Cone((
float)-20.884, (
float)18.056),
171 Cone((
float)1.414, (
float)1.414),
Cone((
float)-0.356, (
float)3.184),
172 Cone((
float)-2.126, (
float)4.954),
Cone((
float)-3.896, (
float)6.724),
173 Cone((
float)-5.666, (
float)8.494),
Cone((
float)-7.436, (
float)10.264),
174 Cone((
float)-9.206, (
float)12.034),
Cone((
float)-10.976, (
float)13.804),
175 Cone((
float)-12.746, (
float)15.574),
Cone((
float)-14.516, (
float)17.344),
176 Cone((
float)-16.286, (
float)19.114),
Cone((
float)-18.056, (
float)20.884)};
179 custom_interfaces::msg::Pose vehicle_pose;
182 vehicle_pose.theta = 2.3561945;
184 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Publishing cone array with size: %ld",
185 cone_array_msg.cone_array.size());
186 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
187 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
188 for (
const auto &p : received_path.pathpoint_array) {
189 EXPECT_LE(p.y + p.x, 0.1);
191 EXPECT_GE(
static_cast<long unsigned>(received_path.pathpoint_array.size()),
192 (
long unsigned int)100);
200 std::vector<Cone> cone_array = {
201 Cone((
float)-1.414, (
float)1.414),
Cone((
float)-3.184, (
float)-0.356),
202 Cone((
float)-4.954, (
float)-2.126),
Cone((
float)-6.724, (
float)-3.896),
203 Cone((
float)-8.494, (
float)-5.666),
Cone((
float)-10.264, (
float)-7.436),
204 Cone((
float)-12.034, (
float)-9.206),
Cone((
float)-13.804, (
float)-10.976),
205 Cone((
float)-15.574, (
float)-12.746),
Cone((
float)-17.344, (
float)-14.516),
206 Cone((
float)-19.114, (
float)-16.286),
Cone((
float)-20.884, (
float)-18.056),
207 Cone((
float)1.414, (
float)-1.414),
Cone((
float)-0.356, (
float)-3.184),
208 Cone((
float)-2.126, (
float)-4.954),
Cone((
float)-3.896, (
float)-6.724),
209 Cone((
float)-5.666, (
float)-8.494),
Cone((
float)-7.436, (
float)-10.264),
210 Cone((
float)-9.206, (
float)-12.034),
Cone((
float)-10.976, (
float)-13.804),
211 Cone((
float)-12.746, (
float)-15.574),
Cone((
float)-14.516, (
float)-17.344),
212 Cone((
float)-16.286, (
float)-19.114),
Cone((
float)-18.056, (
float)-20.884)};
214 custom_interfaces::msg::Pose vehicle_pose;
217 vehicle_pose.theta = 3.92699;
219 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Publishing cone array with size: %ld",
220 cone_array_msg.cone_array.size());
221 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
223 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
224 for (
const auto &p : received_path.pathpoint_array) {
225 EXPECT_LE(p.y - p.x, 0.1);
227 EXPECT_GE(
static_cast<long unsigned>(received_path.pathpoint_array.size()),
228 (
long unsigned int)100);
236 std::vector<Cone> cone_array = {
237 Cone((
float)1.414, (
float)1.414),
Cone((
float)3.184, (
float)-0.356),
238 Cone((
float)4.954, (
float)-2.126),
Cone((
float)6.724, (
float)-3.896),
239 Cone((
float)8.494, (
float)-5.666),
Cone((
float)10.264, (
float)-7.436),
240 Cone((
float)12.034, (
float)-9.206),
Cone((
float)13.804, (
float)-10.976),
241 Cone((
float)15.574, (
float)-12.746),
Cone((
float)17.344, (
float)-14.516),
242 Cone((
float)19.114, (
float)-16.286),
Cone((
float)20.884, (
float)-18.056),
243 Cone((
float)-1.414, (
float)-1.414),
Cone((
float)0.356, (
float)-3.184),
244 Cone((
float)2.126, (
float)-4.954),
Cone((
float)3.896, (
float)-6.724),
245 Cone((
float)5.666, (
float)-8.494),
Cone((
float)7.436, (
float)-10.264),
246 Cone((
float)9.206, (
float)-12.034),
Cone((
float)10.976, (
float)-13.804),
247 Cone((
float)12.746, (
float)-15.574),
Cone((
float)14.516, (
float)-17.344),
248 Cone((
float)16.286, (
float)-19.114),
Cone((
float)18.056, (
float)-20.884)};
250 custom_interfaces::msg::Pose vehicle_pose;
253 vehicle_pose.theta = 5.49779;
255 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Publishing cone array with size: %ld",
256 cone_array_msg.cone_array.size());
257 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
259 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
260 for (
const auto &p : received_path.pathpoint_array) {
261 EXPECT_LE(p.y + p.x, 0.1);
263 EXPECT_GE(
static_cast<long unsigned>(received_path.pathpoint_array.size()),
264 (
long unsigned int)100);
272 std::vector<Cone> cone_array = {
273 Cone(2, 19),
Cone(2, 22),
Cone(2, 25),
Cone(2, 28),
Cone(2, 31),
Cone(2, 34),
274 Cone(2, 1),
Cone(2, 4),
Cone(2, 7),
Cone(2, 10),
Cone(2, 13),
Cone(2, 16),
275 Cone(-2, 1),
Cone(-2, 4),
Cone(-2, 7),
Cone(-2, 25),
Cone(-2, 28),
Cone(-2, 31),
276 Cone(-2, 34),
Cone(-2, 10),
Cone(-2, 13),
Cone(-2, 16),
Cone(-2, 19),
Cone(-2, 22)};
278 custom_interfaces::msg::Pose vehicle_pose;
281 vehicle_pose.theta = 1.5708;
283 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Publishing cone array with size: %ld",
284 cone_array_msg.cone_array.size());
285 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
287 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
288 for (
const auto &p : received_path.pathpoint_array) {
289 EXPECT_LE(fabs(p.x), 0.1);
290 EXPECT_LE(p.y, 35.5);
293 EXPECT_GE(
static_cast<long unsigned>(received_path.pathpoint_array.size()),
294 (
long unsigned int)100);
302 custom_interfaces::msg::Pose vehicle_pose;
305 vehicle_pose.theta = 1.5708;
307 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Publishing cone array with size: %ld",
308 cone_array_msg.cone_array.size());
310 const auto duration = run_nodes(this->cone_array_msg, vehicle_pose);
312 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
313 EXPECT_EQ(
static_cast<long unsigned>(received_path.pathpoint_array.size()), (
long unsigned int)0);
321 custom_interfaces::msg::Cone cone_to_send;
323 cone_to_send.position.x = 2;
324 cone_to_send.position.y = 19;
325 cone_to_send.color =
"yellow_cone";
326 cone_array_msg.cone_array.push_back(cone_to_send);
328 custom_interfaces::msg::Pose vehicle_pose;
331 vehicle_pose.theta = 1.5708;
333 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Publishing cone array with size: %ld",
334 cone_array_msg.cone_array.size());
335 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
337 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
338 EXPECT_EQ(
static_cast<long unsigned>(received_path.pathpoint_array.size()), (
long unsigned int)0);
358void read_from_file(std::ifstream &file,
double &finalxi,
double &finalxf,
double &finalyi,
359 double &finalyf, std::vector<Cone> &cone_array,
360 custom_interfaces::msg::Pose &vehicle_pose) {
363 while (std::getline(file, line)) {
364 std::istringstream iss(line);
369 iss >> vehicle_pose.x >> vehicle_pose.y >> vehicle_pose.theta;
370 }
else if (flag ==
"C") {
375 cone_array.push_back(cone);
376 }
else if (flag ==
"F") {
378 iss >> finalxi >> finalxf >> finalyi >> finalyf;
399 const custom_interfaces::msg::PathPointArray received_path,
400 const custom_interfaces::msg::Pose vehicle_pose) {
401 std::ofstream debug_file(
"../../src/planning/test/integration_tests/results/" + filename);
402 if (debug_file.is_open()) {
403 for (
const auto &point : received_path.pathpoint_array) {
405 <<
" " << point.x <<
" " << point.y <<
"\n";
408 for (
const auto &cone : cone_array) {
409 debug_file <<
"C " << cone.position.x <<
" " << cone.position.y <<
" "
412 debug_file <<
"V " << vehicle_pose.x <<
" " << vehicle_pose.y <<
" "
413 << vehicle_pose.theta <<
"\n";
416 std::cerr <<
"Failed to open debug file for writing.\n";
426 const std::string filename =
"straight_1.txt";
429 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
432 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
434 if (!file.is_open()) {
435 FAIL() <<
"Failed to open file: straight_1.txt";
439 std::vector<Cone> cone_array;
440 custom_interfaces::msg::Pose vehicle_pose;
446 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
448 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
453 if ((this->received_path.pathpoint_array.back().x >= x1 &&
454 this->received_path.pathpoint_array.back().x <= x2) &&
455 (this->received_path.pathpoint_array.back().y >= y1 &&
456 this->received_path.pathpoint_array.back().y <= y2)) {
459 FAIL() <<
"The final point is not in the expected range. "
460 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
461 << this->received_path.pathpoint_array.back().x <<
", "
462 << this->received_path.pathpoint_array.back().y <<
")\n\n";
471 const std::string filename =
"straight_2.txt";
474 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
477 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
479 if (!file.is_open()) {
480 FAIL() <<
"Failed to open file: straight_1.txt";
484 std::vector<Cone> cone_array;
485 custom_interfaces::msg::Pose vehicle_pose;
491 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
492 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
497 if ((this->received_path.pathpoint_array.back().x >= x1 &&
498 this->received_path.pathpoint_array.back().x <= x2) &&
499 (this->received_path.pathpoint_array.back().y >= y1 &&
500 this->received_path.pathpoint_array.back().y <= y2)) {
503 FAIL() <<
"The final point is not in the expected range. "
504 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
505 << this->received_path.pathpoint_array.back().x <<
", "
506 << this->received_path.pathpoint_array.back().y <<
")\n\n";
515 const std::string filename =
"curve_1.txt";
518 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
521 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
523 if (!file.is_open()) {
524 FAIL() <<
"Failed to open file: straight_1.txt";
528 std::vector<Cone> cone_array;
529 custom_interfaces::msg::Pose vehicle_pose;
535 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
536 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
541 if ((this->received_path.pathpoint_array.back().x >= x1 &&
542 this->received_path.pathpoint_array.back().x <= x2) &&
543 (this->received_path.pathpoint_array.back().y >= y1 &&
544 this->received_path.pathpoint_array.back().y <= y2)) {
547 FAIL() <<
"The final point is not in the expected range. "
548 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
549 << this->received_path.pathpoint_array.back().x <<
", "
550 << this->received_path.pathpoint_array.back().y <<
")\n\n";
560 const std::string filename =
"curve_2.txt";
563 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
566 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
568 if (!file.is_open()) {
569 FAIL() <<
"Failed to open file: straight_1.txt";
573 std::vector<Cone> cone_array;
574 custom_interfaces::msg::Pose vehicle_pose;
580 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
581 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
586 if ((this->received_path.pathpoint_array.back().x >= x1 &&
587 this->received_path.pathpoint_array.back().x <= x2) &&
588 (this->received_path.pathpoint_array.back().y >= y1 &&
589 this->received_path.pathpoint_array.back().y <= y2)) {
592 FAIL() <<
"The final point is not in the expected range. "
593 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
594 << this->received_path.pathpoint_array.back().x <<
", "
595 << this->received_path.pathpoint_array.back().y <<
")\n\n";
604 const std::string filename =
"curve_3.txt";
607 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
610 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
612 if (!file.is_open()) {
613 FAIL() <<
"Failed to open file: straight_1.txt";
617 std::vector<Cone> cone_array;
618 custom_interfaces::msg::Pose vehicle_pose;
624 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
625 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
630 if ((this->received_path.pathpoint_array.back().x >= x1 &&
631 this->received_path.pathpoint_array.back().x <= x2) &&
632 (this->received_path.pathpoint_array.back().y >= y1 &&
633 this->received_path.pathpoint_array.back().y <= y2)) {
636 FAIL() <<
"The final point is not in the expected range. "
637 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
638 << this->received_path.pathpoint_array.back().x <<
", "
639 << this->received_path.pathpoint_array.back().y <<
")\n\n";
648 const std::string filename =
"rosbag_1.txt";
651 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
654 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
656 if (!file.is_open()) {
657 FAIL() <<
"Failed to open file: straight_1.txt";
661 std::vector<Cone> cone_array;
662 custom_interfaces::msg::Pose vehicle_pose;
668 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
669 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
674 if ((this->received_path.pathpoint_array.back().x >= x1 &&
675 this->received_path.pathpoint_array.back().x <= x2) &&
676 (this->received_path.pathpoint_array.back().y >= y1 &&
677 this->received_path.pathpoint_array.back().y <= y2)) {
680 FAIL() <<
"The final point is not in the expected range. "
681 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
682 << this->received_path.pathpoint_array.back().x <<
", "
683 << this->received_path.pathpoint_array.back().y <<
")\n\n";
692 const std::string filename =
"rosbag_2.txt";
695 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
698 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
700 if (!file.is_open()) {
701 FAIL() <<
"Failed to open file: straight_1.txt";
705 std::vector<Cone> cone_array;
706 custom_interfaces::msg::Pose vehicle_pose;
712 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
713 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
718 if ((this->received_path.pathpoint_array.back().x >= x1 &&
719 this->received_path.pathpoint_array.back().x <= x2) &&
720 (this->received_path.pathpoint_array.back().y >= y1 &&
721 this->received_path.pathpoint_array.back().y <= y2)) {
724 FAIL() <<
"The final point is not in the expected range. "
725 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
726 << this->received_path.pathpoint_array.back().x <<
", "
727 << this->received_path.pathpoint_array.back().y <<
")\n\n";
737 const std::string filename =
"rosbag_3.txt";
740 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
743 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
745 if (!file.is_open()) {
746 FAIL() <<
"Failed to open file: straight_1.txt";
750 std::vector<Cone> cone_array;
751 custom_interfaces::msg::Pose vehicle_pose;
757 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
758 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
763 if ((this->received_path.pathpoint_array.back().x >= x1 &&
764 this->received_path.pathpoint_array.back().x <= x2) &&
765 (this->received_path.pathpoint_array.back().y >= y1 &&
766 this->received_path.pathpoint_array.back().y <= y2)) {
769 FAIL() <<
"The final point is not in the expected range. "
770 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
771 << this->received_path.pathpoint_array.back().x <<
", "
772 << this->received_path.pathpoint_array.back().y <<
")\n\n";
781 const std::string filename =
"rosbag_4.txt";
784 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
787 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
789 if (!file.is_open()) {
790 FAIL() <<
"Failed to open file: straight_1.txt";
794 std::vector<Cone> cone_array;
795 custom_interfaces::msg::Pose vehicle_pose;
801 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
802 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
807 if ((this->received_path.pathpoint_array.back().x >= x1 &&
808 this->received_path.pathpoint_array.back().x <= x2) &&
809 (this->received_path.pathpoint_array.back().y >= y1 &&
810 this->received_path.pathpoint_array.back().y <= y2)) {
813 FAIL() <<
"The final point is not in the expected range. "
814 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
815 << this->received_path.pathpoint_array.back().x <<
", "
816 << this->received_path.pathpoint_array.back().y <<
")\n\n";
825 const std::string filename =
"rosbag_5.txt";
828 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
831 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
833 if (!file.is_open()) {
834 FAIL() <<
"Failed to open file: straight_1.txt";
838 std::vector<Cone> cone_array;
839 custom_interfaces::msg::Pose vehicle_pose;
845 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
846 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
851 if ((this->received_path.pathpoint_array.back().x >= x1 &&
852 this->received_path.pathpoint_array.back().x <= x2) &&
853 (this->received_path.pathpoint_array.back().y >= y1 &&
854 this->received_path.pathpoint_array.back().y <= y2)) {
857 FAIL() <<
"The final point is not in the expected range. "
858 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
859 << this->received_path.pathpoint_array.back().x <<
", "
860 << this->received_path.pathpoint_array.back().y <<
")\n\n";
869 const std::string filename =
"circle.txt";
872 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
875 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
877 if (!file.is_open()) {
878 FAIL() <<
"Failed to open file: straight_1.txt";
882 std::vector<Cone> cone_array;
883 custom_interfaces::msg::Pose vehicle_pose;
889 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
890 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
895 if ((this->received_path.pathpoint_array.back().x >= x1 &&
896 this->received_path.pathpoint_array.back().x <= x2) &&
897 (this->received_path.pathpoint_array.back().y >= y1 &&
898 this->received_path.pathpoint_array.back().y <= y2)) {
901 FAIL() <<
"The final point is not in the expected range. "
902 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
903 << this->received_path.pathpoint_array.back().x <<
", "
904 << this->received_path.pathpoint_array.back().y <<
")\n\n";
913 const std::string filename =
"straight_3.txt";
916 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
919 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
921 if (!file.is_open()) {
922 FAIL() <<
"Failed to open file: straight_1.txt";
926 std::vector<Cone> cone_array;
927 custom_interfaces::msg::Pose vehicle_pose;
933 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
934 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
939 if ((this->received_path.pathpoint_array.back().x >= x1 &&
940 this->received_path.pathpoint_array.back().x <= x2) &&
941 (this->received_path.pathpoint_array.back().y >= y1 &&
942 this->received_path.pathpoint_array.back().y <= y2)) {
945 FAIL() <<
"The final point is not in the expected range. "
946 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
947 << this->received_path.pathpoint_array.back().x <<
", "
948 << this->received_path.pathpoint_array.back().y <<
")\n\n";
958 const std::string filename =
"track.txt";
961 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
964 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
966 if (!file.is_open()) {
967 FAIL() <<
"Failed to open file: straight_1.txt";
971 std::vector<Cone> cone_array;
972 custom_interfaces::msg::Pose vehicle_pose;
978 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
979 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
984 if ((this->received_path.pathpoint_array.back().x >= x1 &&
985 this->received_path.pathpoint_array.back().x <= x2) &&
986 (this->received_path.pathpoint_array.back().y >= y1 &&
987 this->received_path.pathpoint_array.back().y <= y2)) {
990 FAIL() <<
"The final point is not in the expected range. "
991 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
992 << this->received_path.pathpoint_array.back().x <<
", "
993 << this->received_path.pathpoint_array.back().y <<
")\n\n";
1002 const std::string filename =
"track_2.txt";
1005 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
1008 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
1010 if (!file.is_open()) {
1011 FAIL() <<
"Failed to open file: straight_1.txt";
1015 std::vector<Cone> cone_array;
1016 custom_interfaces::msg::Pose vehicle_pose;
1022 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
1023 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
1028 if ((this->received_path.pathpoint_array.back().x >= x1 &&
1029 this->received_path.pathpoint_array.back().x <= x2) &&
1030 (this->received_path.pathpoint_array.back().y >= y1 &&
1031 this->received_path.pathpoint_array.back().y <= y2)) {
1034 FAIL() <<
"The final point is not in the expected range. "
1035 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
1036 << this->received_path.pathpoint_array.back().x <<
", "
1037 << this->received_path.pathpoint_array.back().y <<
")\n\n";
1046 const std::string filename =
"outliers_1.txt";
1049 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
1052 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
1054 if (!file.is_open()) {
1055 FAIL() <<
"Failed to open file: straight_1.txt";
1059 std::vector<Cone> cone_array;
1060 custom_interfaces::msg::Pose vehicle_pose;
1066 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
1067 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
1072 if ((this->received_path.pathpoint_array.back().x >= x1 &&
1073 this->received_path.pathpoint_array.back().x <= x2) &&
1074 (this->received_path.pathpoint_array.back().y >= y1 &&
1075 this->received_path.pathpoint_array.back().y <= y2)) {
1078 FAIL() <<
"The final point is not in the expected range. "
1079 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
1080 << this->received_path.pathpoint_array.back().x <<
", "
1081 << this->received_path.pathpoint_array.back().y <<
")\n\n";
1090 const std::string filename =
"outliers_2.txt";
1093 double x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0;
1096 std::ifstream file(
"../../src/planning/test/integration_tests/tests/" + filename);
1098 if (!file.is_open()) {
1099 FAIL() <<
"Failed to open file: straight_1.txt";
1103 std::vector<Cone> cone_array;
1104 custom_interfaces::msg::Pose vehicle_pose;
1110 const auto duration = run_nodes(cone_array_msg, vehicle_pose);
1111 RCLCPP_DEBUG(rclcpp::get_logger(
"rclcpp"),
"Execution time: %f ms", duration.count());
1116 if ((this->received_path.pathpoint_array.back().x >= x1 &&
1117 this->received_path.pathpoint_array.back().x <= x2) &&
1118 (this->received_path.pathpoint_array.back().y >= y1 &&
1119 this->received_path.pathpoint_array.back().y <= y2)) {
1122 FAIL() <<
"The final point is not in the expected range. "
1123 <<
"Expected range: (" << x1 <<
", " << x2 <<
", " << y1 <<
", " << y2 <<
"), but got: ("
1124 << this->received_path.pathpoint_array.back().x <<
", "
1125 << this->received_path.pathpoint_array.back().y <<
")\n\n";
std::shared_ptr< rclcpp::Node > control_receiver
custom_interfaces::msg::PathPointArray received_path
std::shared_ptr< rclcpp::Node > locmap_sender
std::shared_ptr< rclcpp::Publisher< custom_interfaces::msg::Pose > > vehicle_pose_publisher_
std::shared_ptr< Planning > planning_test_
std::shared_ptr< rclcpp::Subscription< custom_interfaces::msg::PathPointArray > > control_sub
std::shared_ptr< rclcpp::Publisher< custom_interfaces::msg::ConeArray > > map_publisher
custom_interfaces::msg::ConeArray cone_array_msg
std::chrono::duration< double, std::milli > run_nodes(const custom_interfaces::msg::ConeArray &track_msg, const custom_interfaces::msg::Pose &state_msg)
static PlanningParameters load_config(std::string &adapter)
Loads planning configuration from YAML files.
common_lib::structures::Cone Cone
void save_debug_file(const std::string filename, const std::vector< Cone > cone_array, const custom_interfaces::msg::PathPointArray received_path, const custom_interfaces::msg::Pose vehicle_pose)
Saves debug information to a file.
void read_from_file(std::ifstream &file, double &finalxi, double &finalxf, double &finalyi, double &finalyf, std::vector< Cone > &cone_array, custom_interfaces::msg::Pose &vehicle_pose)
Reads a file and processes its contents to initialize vehicle state, cones, and final position range.
TEST_F(IntegrationTest, PUBLISH_PATH1)
Tests the full pipeline with a simple track of 24 cones placed in two straight lines parallel to the ...
custom_interfaces::msg::ConeArray custom_interfaces_array_from_vector(const std::vector< common_lib::structures::Cone > &input_cones)
Color get_color_enum(const std::string &color)
std::string get_color_string(int color)
std::shared_ptr< rclcpp::executors::SingleThreadedExecutor > executor
common_lib::competition_logic::Color color