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

Do not drop future returned by async_send_goal. #3921

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,21 @@ That response is handled by ``goal_response_callback``:

.. literalinclude:: scripts/client.cpp
:language: c++
:lines: 62-71
:lines: 64-71

Assuming the goal was accepted by the server, it will start processing.
Any feedback to the client will be handled by the ``feedback_callback``:

.. literalinclude:: scripts/client.cpp
:language: c++
:lines: 72-83
:lines: 73-83

When the server is finished processing, it will return a result to the client.
The result is handled by the ``result_callback``:

.. literalinclude:: scripts/client.cpp
:language: c++
:lines: 84-107
:lines: 85-107

We now have a fully functioning action client. Let's get it built and running.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ class FibonacciActionClient : public rclcpp::Node
std::bind(&FibonacciActionClient::feedback_callback, this, _1, _2);
send_goal_options.result_callback =
std::bind(&FibonacciActionClient::result_callback, this, _1);
this->client_ptr_->async_send_goal(goal_msg, send_goal_options);
goal_future_ = this->client_ptr_->async_send_goal(goal_msg, send_goal_options);
}

private:
rclcpp_action::Client<Fibonacci>::SharedPtr client_ptr_;
rclcpp::TimerBase::SharedPtr timer_;
std::shared_future<GoalHandleFibonacci::SharedPtr> goal_future_;

void goal_response_callback(const GoalHandleFibonacci::SharedPtr & goal_handle)
{
Expand Down