Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for spin_until_complete (take 2) #2475

Open
wants to merge 5 commits into
base: rolling
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix test
Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
christophebedard-apexai committed Apr 9, 2024
commit c76d80694aa4e5c5893e5a2287cbb67284c4312b
7 changes: 3 additions & 4 deletions rclcpp/test/rclcpp/test_executor.cpp
Original file line number Diff line number Diff line change
@@ -528,11 +528,11 @@ TEST_F(TestExecutor, spin_until_complete_condition_already_complete) {
TEST_F(TestExecutor, spin_until_complete_returns_after_condition) {
DummyExecutor dummy;
auto node = std::make_shared<rclcpp::Node>("node", "ns");
bool spin_called = false;
bool timer_called = false;
auto timer =
node->create_wall_timer(
std::chrono::milliseconds(1), [&]() {
spin_called = true;
timer_called = true;
});
dummy.add_node(node);
// Check that we stop spinning after the condition is ready
@@ -542,10 +542,9 @@ TEST_F(TestExecutor, spin_until_complete_returns_after_condition) {
EXPECT_EQ(
rclcpp::FutureReturnCode::SUCCESS,
dummy.spin_until_complete(condition, std::chrono::seconds(1)));
EXPECT_TRUE(spin_called);
EXPECT_TRUE(timer_called);
const auto end_delay = std::chrono::steady_clock::now() - start;
EXPECT_GE(end_delay, condition_delay);
EXPECT_LT(end_delay, std::chrono::milliseconds(500));
}

TEST_F(TestExecutor, is_spinning) {