MPC Component test flaky
Description
mpc_controller_nodes
fails often, see #1031 (closed)
How to Reproduce
colcon test mpc_controller_nodes
Current Behavior
From sanity_check.cpp
:
// Spin
{
rclcpp::executors::SingleThreadedExecutor exec;
exec.add_node(pub);
exec.add_node(sub);
exec.add_node(ctrl);
auto got_enough_commands = false;
auto got_enough_states = false;
auto got_enough_tfs = false;
while (!pub->done() ||
!got_enough_commands ||
!got_enough_states ||
!got_enough_tfs)
{
exec.spin_some(std::chrono::milliseconds(10LL));
got_enough_commands = sub->commands().size() + TOLI > total_msgs;
got_enough_tfs = sub->tfs().size() + TOLI > total_msgs;
got_enough_states = sub->states().size() + TOLI > total_msgs;
}
// spin one more time for good measure
exec.spin_some(std::chrono::milliseconds(100LL));
}
// Check results
The failure happens after this spin section. It looks suspicious because it doesn't really check if messages were sent similar to #1189 (closed) before proceeding to checks.
Expected behavior
Test should wait reliably for messages and could use same fix as suggested in #1189 (closed) when refactoring to use fake_test_node
and waiting excplitly until the desired event has happened rather than waiting 100 ms .