Skip to content

Commit 1fffc28

Browse files
authored
fix(vehicle_cmd_gate): colcon test failure due to heavy process (autowarefoundation#7678)
Signed-off-by: Takamasa Horibe <horibe.takamasa@gmail.com>
1 parent 7685d8a commit 1fffc28

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

control/autoware_vehicle_cmd_gate/test/src/test_filter_in_vehicle_cmd_gate_node.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,12 @@ class PubSubNode : public rclcpp::Node
294294
const auto max_lat_acc_lim = *std::max_element(lat_acc_lim.begin(), lat_acc_lim.end());
295295
const auto max_lat_jerk_lim = *std::max_element(lat_jerk_lim.begin(), lat_jerk_lim.end());
296296

297+
// This test is designed to verify that the filter is applied correctly. However, if topic
298+
// communication is delayed, the allowable range of change in the command values between the
299+
// sender and receiver of the topic will vary, making the results dependent on processing time.
300+
// We define the allowable error margin to account for this.
297301
constexpr auto threshold_scale = 1.1;
302+
298303
// Output command must be smaller than maximum limit.
299304
// TODO(Horibe): check for each velocity range.
300305
if (std::abs(lon_vel) > 0.01) {
@@ -433,7 +438,7 @@ TEST_P(TestFixture, CheckFilterForSinCmd)
433438
// << cmd_generator_.p_.steering.freq << " * dt + " << cmd_generator_.p_.steering.bias
434439
// << ")" << std::endl;
435440

436-
for (size_t i = 0; i < 100; ++i) {
441+
for (size_t i = 0; i < 30; ++i) {
437442
auto start_time = std::chrono::steady_clock::now();
438443

439444
const bool reset_clock = (i == 0);
@@ -449,7 +454,13 @@ TEST_P(TestFixture, CheckFilterForSinCmd)
449454
std::chrono::milliseconds elapsed =
450455
std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
451456

452-
std::chrono::milliseconds sleep_duration = std::chrono::milliseconds{10} - elapsed;
457+
// The value determines the period of the topic. The filter logic of vehicle_cmd_gate depends on
458+
// real-time, and if the time from publishing to subscribing becomes too long, this test will
459+
// fail (the test specification itself should be improved). To prevent processing bottlenecks,
460+
// please set this value appropriately. It is set to 30ms because it occasionally fails at 10ms.
461+
constexpr int running_ms = 30;
462+
463+
std::chrono::milliseconds sleep_duration = std::chrono::milliseconds{running_ms} - elapsed;
453464
if (sleep_duration.count() > 0) {
454465
std::this_thread::sleep_for(sleep_duration);
455466
}

0 commit comments

Comments
 (0)