Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
utils_test.cpp
Go to the documentation of this file.
2
3#include <fstream>
4#include <sstream>
5#include <string>
6#include <vector>
7
8#include "gtest/gtest.h"
10
11using namespace common_lib::structures;
12
16TEST(PointSolverTests, Test_update_closest_point_1) {
17 auto pathpoint_array = create_path_msg("track1");
18 ControlParameters params;
21 params.first_last_max_dist_ = 0.0;
22 Position expected_point = Position(46.5, -12.37);
23 int expected_id = 76;
24
25 auto [path, rear_axis_point, closest_point_velocity] =
26 get_closest_point(pathpoint_array, Position(47.0, -13.0));
27
28 EXPECT_EQ(path.x, expected_point.x);
29 EXPECT_EQ(path.y, expected_point.y);
30 EXPECT_EQ(rear_axis_point, expected_id);
31}
32
37TEST(PointSolverTests, Test_update_lookahead_point_1) {
38 auto pathpoint_array = create_path_msg("track1");
39
40 Position rear_axis_ = Position(47.0, -13.0);
41 int closest_point_id = 76;
42 Position expected_point = Position(48.576, -10.447);
43
44 auto [result_point, result_velocity, result_error] =
45 get_lookahead_point(pathpoint_array, closest_point_id, 3.0, rear_axis_, 1.0);
46
47 EXPECT_NEAR(result_point.x, expected_point.x, 0.01);
48 EXPECT_NEAR(result_point.y, expected_point.y, 0.01);
49 EXPECT_FALSE(result_error);
50}
std::tuple< common_lib::structures::Position, int, double > get_closest_point(const std::vector< custom_interfaces::msg::PathPoint > &pathpoint_array, const common_lib::structures::Position &position)
Find the closest point on the path.
Definition utils.cpp:14
std::tuple< common_lib::structures::Position, double, bool > get_lookahead_point(const std::vector< custom_interfaces::msg::PathPoint > &pathpoint_array, int closest_point_id, double lookahead_distance, common_lib::structures::Position rear_axis_position, double last_to_first_max_dist)
Update Lookahead point.
Definition utils.cpp:35
std::vector< custom_interfaces::msg::PathPoint > create_path_msg(std::string track_file)
Reads track files and creates a PathPointArray message.
Definition utils.cpp:3
TEST(PointSolverTests, Test_update_closest_point_1)
Test Point Solver - get_closest_point()
double pure_pursuit_lookahead_gain_
double pure_pursuit_lookahead_minimum_
double first_last_max_dist_