| 59 | }; |
| 60 | |
| 61 | int main(int argc, char* argv[]) |
| 62 | { |
| 63 | rclcpp::init(argc, argv); |
| 64 | |
| 65 | rclcpp::NodeOptions options; |
| 66 | auto action_server = std::make_shared<MyActionServer>(options); |
| 67 | |
| 68 | // TODO: This workaround is for a bug in MultiThreadedExecutor where it can deadlock when spinning without a timeout. |
| 69 | // Deadlock is caused when Publishers or Subscribers are dynamically removed as the node is spinning. |
| 70 | rclcpp::executors::MultiThreadedExecutor exec(rclcpp::ExecutorOptions(), 0, false, |
| 71 | std::chrono::milliseconds(250)); |
| 72 | exec.add_node(action_server->node()); |
| 73 | exec.spin(); |
| 74 | exec.remove_node(action_server->node()); |
| 75 | |
| 76 | rclcpp::shutdown(); |
| 77 | } |