19 class RosInitAndShutdownFixture :
public ::testing::Test
22 RosInitAndShutdownFixture()
24 rclcpp::init(0,
nullptr);
27 ~RosInitAndShutdownFixture()
32 RosInitAndShutdownFixture(
const RosInitAndShutdownFixture&) =
delete;
33 RosInitAndShutdownFixture(RosInitAndShutdownFixture&&) =
delete;
34 RosInitAndShutdownFixture& operator=(
const RosInitAndShutdownFixture&) =
delete;
35 RosInitAndShutdownFixture& operator=(RosInitAndShutdownFixture&&) =
delete;
39 class RosExecutorFixture :
public RosInitAndShutdownFixture
42 template <
typename... ExecutorArgs>
43 RosExecutorFixture(ExecutorArgs&&... args)
44 : executor_(std::make_shared<ExecutorT>(std::forward<ExecutorArgs>(args)...)), spin_thread_([
this]() { executor_->spin(); })
46 while (!executor_->is_spinning())
48 using namespace std::chrono_literals;
49 std::cout <<
"Waiting for executor to start...\n" << std::flush;
50 std::this_thread::sleep_for(1ms);
58 if (spin_thread_.joinable())
64 RosExecutorFixture(
const RosExecutorFixture&) =
delete;
65 RosExecutorFixture(RosExecutorFixture&&) =
delete;
66 RosExecutorFixture& operator=(
const RosExecutorFixture&) =
delete;
67 RosExecutorFixture& operator=(RosExecutorFixture&&) =
delete;
69 rclcpp::Executor& get_executor()
75 std::shared_ptr<rclcpp::Executor> executor_;
77 std::jthread spin_thread_;