28 auto new_inspection = std::make_unique<InspectionFunctions>(
29 M_PI / 6.0, 4.0, 0.254, 26,
false, 0.5, 1.0);
30 for (
unsigned int i = 0; i < 260; i++) {
31 double steering = new_inspection->calculate_steering(i);
33 steering, sin(i * 2 * M_PI / new_inspection->turning_period_) * new_inspection->max_angle_);
42 auto new_inspection = std::make_unique<InspectionFunctions>(
43 M_PI / 6.0, 4.0, 0.254, 26,
false, 0.5, 1.0);
44 double initial_velocity = 5;
46 for (
unsigned int i = 0; i < 260; i++) {
47 initial_velocity += 0.1 * (new_inspection->calculate_throttle(initial_velocity));
49 EXPECT_NEAR(initial_velocity, 1, 0.01);
57 auto new_inspection = std::make_unique<InspectionFunctions>(
58 M_PI / 6.0, 4.0, 0.254, 26,
false, 0.5, 1.0);
59 double initial_velocity = -4;
61 for (
unsigned int i = 0; i < 260; i++) {
62 initial_velocity += 0.1 * (new_inspection->calculate_throttle(initial_velocity));
64 EXPECT_NEAR(initial_velocity, 1, 0.01);
72 auto new_inspection = std::make_unique<InspectionFunctions>(
73 M_PI / 6.0, 4.0, 0.254, 26,
false, 0.5, 1.0);
74 double initial_velocity = 1.1;
76 for (
unsigned int i = 0; i < 260; i++) {
77 initial_velocity += 0.1 * (new_inspection->calculate_throttle(initial_velocity));
79 EXPECT_NEAR(initial_velocity, 1, 0.01);
87 double max_angle = M_PI / 6.0;
88 double ideal_velocity = 10.0;
90 double wheel_radius = 0.254;
92 double stop_time = 30;
93 auto new_inspection = std::make_unique<InspectionFunctions>(
94 max_angle, turn_time, wheel_radius, stop_time,
true, gain, ideal_velocity);
96 double current_velocity = 0;
97 double max_velocity = -1;
98 double min_velocity = 1000;
101 for (
unsigned int i = 0; i < static_cast<unsigned int>(stop_time) * 10; i++) {
103 max_velocity = current_velocity > max_velocity ? current_velocity : max_velocity;
104 min_velocity = current_velocity < min_velocity ? current_velocity : min_velocity;
107 current_velocity += 0.1 * (new_inspection->calculate_throttle(current_velocity));
110 if (fabs(current_velocity - new_inspection->current_goal_velocity_) < 0.2) {
111 new_inspection->redefine_goal_velocity(current_velocity);
119 double rounded_min_velocity = std::round(min_velocity * 10.0) / 10.0;
120 double rounded_max_velocity = std::round(max_velocity * 10.0) / 10.0;
122 EXPECT_NEAR(rounded_min_velocity, 0.0, 0.1);
123 EXPECT_NEAR(rounded_max_velocity, 9.9, 0.2);
131 auto new_inspection = std::make_unique<InspectionFunctions>(
132 M_PI / 6.0, 4.0, 0.254, 26,
false, 0.5, 1.0);
134 EXPECT_DOUBLE_EQ(0.39898226700590372, new_inspection->rpm_to_velocity(rpm));