@@ -121,6 +121,49 @@ TEST_F(LongitudinalSpeedPlannerTest, getAccelerationDuration_acceleration)
121
121
8.5 , constraints, makeTwistWithLinearX (1.0 ), makeAccelWithLinearX (1.0 )),
122
122
4.0 , 1e-5 );
123
123
}
124
+ /* *
125
+ * @note Test calculations correctness when difference between getVelocityWithConstantJerk
126
+ * and target_speed is more than 0.01, https://github.com/tier4/scenario_simulator_v2/issues/1395
127
+ */
128
+
129
+ TEST_F (LongitudinalSpeedPlannerTest, getAccelerationDuration_targetSpeed_difference)
130
+ {
131
+ geometry_msgs::msg::Twist current_twist{};
132
+ geometry_msgs::msg::Accel current_accel{};
133
+ current_twist.linear .x = 1.0 ;
134
+ current_accel.linear .x = 1.0 ;
135
+
136
+ const auto constraints =
137
+ traffic_simulator_msgs::build<traffic_simulator_msgs::msg::DynamicConstraints>()
138
+ .max_acceleration (1.0 )
139
+ .max_acceleration_rate (1.0 )
140
+ .max_deceleration (1.0 )
141
+ .max_deceleration_rate (1.0 )
142
+ .max_speed (10.0 );
143
+
144
+ constexpr double epsilon = 1e-5 ;
145
+ {
146
+ const double target_speed = current_twist.linear .x + epsilon;
147
+ const double result_duration =
148
+ planner.getAccelerationDuration (target_speed, constraints, current_twist, current_accel);
149
+ EXPECT_GE (result_duration, 0.0 );
150
+ EXPECT_LE (result_duration, epsilon);
151
+ }
152
+ {
153
+ const double target_speed = current_twist.linear .x + 0.0100 ;
154
+ const double result_duration =
155
+ planner.getAccelerationDuration (target_speed, constraints, current_twist, current_accel);
156
+ EXPECT_GE (result_duration, 0.0 );
157
+ EXPECT_LE (result_duration, 0.0100 + epsilon);
158
+ }
159
+ {
160
+ const double target_speed = current_twist.linear .x + 0.0099 ;
161
+ const double result_duration =
162
+ planner.getAccelerationDuration (target_speed, constraints, current_twist, current_accel);
163
+ EXPECT_GE (result_duration, 0.0 );
164
+ EXPECT_LE (result_duration, 0.0099 + epsilon);
165
+ }
166
+ }
124
167
125
168
/* *
126
169
* @note Test functionality aggregation used in other classes.
0 commit comments