ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You need to give the node some processing time. Because you are creating a node here:
auto node = std::make_shared<MyturtleSpawner>();
And then immediately calling rclcpp::shutdown()
on the next line, by the time the thread gets a chance to run and create the client, the ROS context has been cleaned up.
You need to create an executor and spin the node after creating it and before calling rclcpp::shutdown()
. See this tutorial, and look at the main()
function. It has a call to rclcpp::spin()
after creating the node.