How to call spin_some or spin_until_future_complete in member functions
Hi together,
my coding style of ROS2 is to put all stuff into an object and member functions. Now I wonder how to use spin_some or spin_until_future_complete inside a member function of my object? I tried with this, but that doesn't work.
Here is how I create the object:
int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<myNode>());
rclcpp::shutdown();
return 0;
}
Example for a service call I want to make:
auto request = std::make_shared<std_srvs::srv::SetBool::Request>();
request->data = true;
auto result = client_->async_send_request(request);
if (rclcpp::spin_until_future_complete(this, result) != rclcpp::executor::FutureReturnCode::SUCCESS)
{
RCLCPP_ERROR(this->get_logger(), "Failed");
}